on xenial help sign in
Watch for launcher item icon changes Fixes: #1543290
885b392Lukáš Tinkl
plugins/Unity/Launcher/launcheritem.h+1−1
@@ -32,7 +32,7 @@ class LauncherItem: public LauncherItemInterface
32{
32{
33 Q_OBJECT
33 Q_OBJECT
34public:
34public:
35− LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent = 0);
35+ LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent = nullptr);
36
36
37 QString appId() const override;
37 QString appId() const override;
38 QString name() const override;
38 QString name() const override;
plugins/Unity/Launcher/launchermodel.cpp+13−4
@@ -103,7 +103,7 @@ void LauncherModel::setAlerting(const QString &appId, bool alerting) {
103 LauncherItem *item = m_list.at(index);
103 LauncherItem *item = m_list.at(index);
104 if (!item->focused()) {
104 if (!item->focused()) {
105 item->setAlerting(alerting);
105 item->setAlerting(alerting);
106− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RoleAlerting);
106+ Q_EMIT dataChanged(modelIndex, modelIndex, {RoleAlerting});
107 }
107 }
108 }
108 }
109}
109}
@@ -414,10 +414,19 @@ void LauncherModel::refresh()
414 } else {
414 } else {
415 int idx = m_list.indexOf(item);
415 int idx = m_list.indexOf(item);
416 item->setName(desktopFile.displayName());
416 item->setName(desktopFile.displayName());
417− item->setIcon(desktopFile.icon());
418 item->setPinned(item->pinned()); // update pinned text if needed
417 item->setPinned(item->pinned()); // update pinned text if needed
419 item->setRunning(item->running());
418 item->setRunning(item->running());
420− Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleIcon, RoleRunning});
419+ Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleRunning});
420+
421+ const QString oldIcon = item->icon();
422+ if (oldIcon == desktopFile.icon()) { // same icon file, perhaps different contents, simulate changing the icon name to force reload
423+ item->setIcon(QString());
424+ Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
425+ }
426+
427+ // now set the icon for real
428+ item->setIcon(desktopFile.icon());
429+ Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
421 }
430 }
422 }
431 }
423
432
@@ -489,7 +498,7 @@ void LauncherModel::alert(const QString &appId)
489 if (idx >= 0) {
498 if (idx >= 0) {
490 LauncherItem *item = m_list.at(idx);
499 LauncherItem *item = m_list.at(idx);
491 setAlerting(item->appId(), true);
500 setAlerting(item->appId(), true);
492− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleAlerting);
501+ Q_EMIT dataChanged(index(idx), index(idx), {RoleAlerting});
493 }
502 }
494}
503}
495
504
plugins/Unity/Launcher/launchermodel.h+1−1
@@ -38,7 +38,7 @@ class LauncherModel: public LauncherModelInterface
38 Q_OBJECT
38 Q_OBJECT
39
39
40public:
40public:
41− LauncherModel(QObject *parent = 0);
41+ LauncherModel(QObject *parent = nullptr);
42 ~LauncherModel();
42 ~LauncherModel();
43
43
44 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
44 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
qml/Launcher/LauncherDelegate.qml+1
@@ -149,6 +149,7 @@ Item {
149 sourceSize.width: iconShape.width
149 sourceSize.width: iconShape.width
150 sourceSize.height: iconShape.height
150 sourceSize.height: iconShape.height
151 source: root.iconName
151 source: root.iconName
152+ cache: false // see lpbug#1543290 why no cache
152 }
153 }
153 }
154 }
154
155