on xenial help sign in
merge ~lukas-kde/unity8/dynamicLauncherIcons as prereq
commit2fe0e67c7ae034c5868a179eba54aaaa69850d2d authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 10 Mar 2016, 14:07 (11 years ago) parentc77deef94190f7
3 files changed+15−5
plugins/Unity/Launcher/launchermodel.cpp+13−4 plugins/Unity/Launcher/launchermodel.h+1−1 qml/Launcher/LauncherDelegate.qml+1
plugins/Unity/Launcher/launchermodel.cpp+13−4
@@ -103,7 +103,7 @@ void LauncherModel::setAlerting(const QString &appId, bool alerting) {
103103 LauncherItem *item = m_list.at(index);
104104 if (!item->focused()) {
105105 item->setAlerting(alerting);
106− Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RoleAlerting);
106+ Q_EMIT dataChanged(modelIndex, modelIndex, {RoleAlerting});
107107 }
108108 }
109109}
@@ -415,10 +415,19 @@ void LauncherModel::refresh()
415415 } else {
416416 int idx = m_list.indexOf(item);
417417 item->setName(desktopFile.displayName());
418− item->setIcon(desktopFile.icon());
419418 item->setPinned(item->pinned()); // update pinned text if needed
420419 item->setRunning(item->running());
421− Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleIcon, RoleRunning});
420+ Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleRunning});
421+
422+ const QString oldIcon = item->icon();
423+ if (oldIcon == desktopFile.icon()) { // same icon file, perhaps different contents, simulate changing the icon name to force reload
424+ item->setIcon(QString());
425+ Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
426+ }
427+
428+ // now set the icon for real
429+ item->setIcon(desktopFile.icon());
430+ Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
422431 }
423432 }
424433
@@ -490,7 +499,7 @@ void LauncherModel::alert(const QString &appId)
490499 if (idx >= 0) {
491500 LauncherItem *item = m_list.at(idx);
492501 setAlerting(item->appId(), true);
493− Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleAlerting);
502+ Q_EMIT dataChanged(index(idx), index(idx), {RoleAlerting});
494503 }
495504}
496505
plugins/Unity/Launcher/launchermodel.h+1−1
@@ -38,7 +38,7 @@ class LauncherModel: public LauncherModelInterface
3838 Q_OBJECT
3939
4040public:
41− LauncherModel(QObject *parent = 0);
41+ LauncherModel(QObject *parent = nullptr);
4242 ~LauncherModel();
4343
4444 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
qml/Launcher/LauncherDelegate.qml+1
@@ -135,6 +135,7 @@ Item {
135135 sourceSize.width: iconShape.width
136136 sourceSize.height: iconShape.height
137137 source: root.iconName
138+ cache: false // see lpbug#1543290 why no cache
138139 }
139140 }
140141