fix #264,introduce lastValidSourceName

--during closing a task the decoration
from libtaskmanager returns no valid strings.
The problem was first observed with the
remove window animation. To solve it
introduced at our iconitem a lastValidIconName
that contains the last valid iconName.
v0.6
Michail Vourlakos 8 years ago
parent 09753f705d
commit e0be8d41cc

@ -39,6 +39,7 @@ namespace Latte {
IconItem::IconItem(QQuickItem *parent)
: QQuickItem(parent),
m_lastValidSourceName(QString()),
m_smooth(false),
m_active(false),
m_textureChanged(false),
@ -77,6 +78,7 @@ void IconItem::setSource(const QVariant &source)
// If the QIcon was created with QIcon::fromTheme(), try to load it as svg
if (source.canConvert<QIcon>() && !source.value<QIcon>().name().isEmpty()) {
sourceString = source.value<QIcon>().name();
setLastValidSourceName(sourceString);
}
if (!sourceString.isEmpty()) {
@ -170,6 +172,22 @@ QVariant IconItem::source() const
return m_source;
}
QString IconItem::lastValidSourceName()
{
return m_lastValidSourceName;
}
void IconItem::setLastValidSourceName(QString name)
{
if (m_lastValidSourceName == name || name == "" || name == "application-x-executable") {
return;
}
m_lastValidSourceName = name;
emit lastValidSourceNameChanged();
}
void IconItem::setOverlays(const QStringList &overlays)
{
if (overlays == m_overlays) {

@ -83,6 +83,11 @@ class IconItem : public QQuickItem {
*/
Q_PROPERTY(int paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
/**
* Contains the last valid icon name
*/
Q_PROPERTY(QString lastValidSourceName READ lastValidSourceName NOTIFY lastValidSourceNameChanged)
public:
IconItem(QQuickItem *parent = nullptr);
virtual ~IconItem();
@ -104,6 +109,8 @@ public:
int paintedWidth() const;
int paintedHeight() const;
QString lastValidSourceName();
void updatePolish() Q_DECL_OVERRIDE;
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
@ -115,6 +122,7 @@ public:
signals:
void overlaysChanged();
void activeChanged();
void lastValidSourceNameChanged();
void sourceChanged();
void smoothChanged();
void validChanged();
@ -126,11 +134,13 @@ private slots:
private:
void loadPixmap();
void setLastValidSourceName(QString name);
QIcon m_icon;
QPixmap m_iconPixmap;
QImage m_imageIcon;
std::unique_ptr<Plasma::Svg> m_svgIcon;
QString m_lastValidSourceName;
QString m_svgIconName;
QStringList m_overlays;
//this contains the raw variant it was passed

@ -142,11 +142,14 @@ Item{
//icon: decoration
source: decoration
onLastValidSourceNameChanged: console.log(lastValidSourceName);
//visible: !root.enableShadows
onValidChanged: {
if (!valid && (source === decoration || source === "unknown"))
source = "application-x-executable"
if (!valid && (source === decoration || source === "unknown")) {
source = "application-x-executable";
}
}
property int zoomedSize: root.zoomFactor * root.iconSize
@ -694,7 +697,7 @@ Item{
id:removingAnimation
function init(){
var relavantPoint = root.mapFromItem(iconImageBuffer,0,0);
var relavantPoint = root.mapFromItem(centralItem,0,0);
var removingItem = removeTaskComponent.createObject(root);
removingItem.x = relavantPoint.x;
@ -720,20 +723,45 @@ Item{
id: removeTaskComponent
Item{
id: removeTask
width: iconImageBuffer.width
height: iconImageBuffer.height
//parent: panel
width: centralItem.width
height: centralItem.height
visible: false
Latte.IconItem{
id: tempRemoveIcon
anchors.centerIn: parent
anchors.rightMargin: root.position === PlasmaCore.Types.LeftPositioned ? root.thickMarginBase : 0
anchors.leftMargin: root.position === PlasmaCore.Types.RightPositioned ? root.thickMarginBase : 0
anchors.topMargin: root.position === PlasmaCore.Types.BottomPositioned ? root.thickMarginBase : 0
anchors.bottomMargin: root.position === PlasmaCore.Types.TopPositioned ? root.thickMarginBase : 0
anchors.horizontalCenter: !root.vertical ? parent.horizontalCenter : undefined;
anchors.verticalCenter: root.vertical ? parent.verticalCenter : undefined;
anchors.right: root.position === PlasmaCore.Types.LeftPositioned ? parent.right : undefined;
anchors.left: root.position === PlasmaCore.Types.RightPositioned ? parent.left : undefined;
anchors.top: root.position === PlasmaCore.Types.BottomPositioned ? parent.top : undefined;
anchors.bottom: root.position === PlasmaCore.Types.TopPositioned ? parent.bottom : undefined;
width: iconImageBuffer.width
height: width
visible: root.enableShadows ? false : true
source: decoration
source: iconImageBuffer.lastValidSourceName
}
Loader{
id: tempTaskShadow
anchors.fill: tempRemoveIcon
active: root.enableShadows
sourceComponent: DropShadow{
anchors.fill: parent
color: "#ff080808"
samples: 2 * radius
source: tempRemoveIcon
radius: centralItem.shadowSize
verticalOffset: 2
}
}
Colorize{
@ -791,6 +819,12 @@ Item{
}
visible = true;
if (mainItemContainer.isWindow && !mainItemContainer.isGroupParent) {
iconImageBuffer.visible = false;
taskWithShadow.visible = false;
}
componentRemoveAnimation.start();
}

Loading…
Cancel
Save