Merge lp:~lukas-kde/unity8/dynamicLauncherIcons into lp:unity8

Proposed by Lukáš Tinkl
Status: Merged
Approved by: Michael Zanetti
Approved revision: 2210
Merged at revision: 2266
Proposed branch: lp:~lukas-kde/unity8/dynamicLauncherIcons
Merge into: lp:unity8
Diff against target: 80 lines (+16/-6)
4 files modified
plugins/Unity/Launcher/launcheritem.h (+1/-1)
plugins/Unity/Launcher/launchermodel.cpp (+13/-4)
plugins/Unity/Launcher/launchermodel.h (+1/-1)
qml/Launcher/LauncherDelegate.qml (+1/-0)
To merge this branch: bzr merge lp:~lukas-kde/unity8/dynamicLauncherIcons
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Approve
Michael Zanetti (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+287649@code.launchpad.net

This proposal supersedes a proposal from 2016-02-09.

Commit message

Watch for launcher item icon changes

Description of the change

Watch for launcher item icon changes

Fixes #1543290 - Icons of apps pinned in the launcher don't update if app got updated and has a new icon

Checklist:

* Are there any related MPs required for this MP to build/function as expected? Please list.

No

* Did you perform an exploratory manual test run of your code change and any related functionality?

Yes

* Did you make sure that your branch does not contain spurious tags?

Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

Yes

* If you changed the UI, has there been a design review?

N/A

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

hmm... We already have a file system watcher for launcher stuff... Check out data/unity8-filewatcher.conf

The reason for not using a QFileSystemWatcher directly for that was there is a limited number of watches that a process can set up. Can we update the icons on that UpdateLauncher call too?

review: Needs Fixing
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

The existing watcher is observing changes in the desktop files only (applications being added/removed) using:

data/unity8-filewatcher.conf:

start on (file FILE=/home/phablet/.local/share/applications/*.desktop) or (file FILE=/usr/share/applications/*.desktop)

Here we have to watch icons' actual contents changes which is doable only from the model where we have the path to the icon (the .desktop file doesn't have the full icon path).

Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

I don't think an app icon can change without it's desktop file being touched too. (Except, obviously, if the user replaces the file manually in the file system). But during app updates the .desktop file is always overwritten (even if sometimes with the same content) which then would always call the UpdateLauncher D-Bus method.

If possible, I'd like to try hooking into that mechanism instead of setting up more FSWatchers.

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

OK done, reused the the existing upstart watcher. I have to reset the whole model when the refresh() method is called tho... otherwise QML won't notice the change and won't redraw the icon because the "icon" property stays the same (unlike its contents).

Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

resetting the model will mess up scrolling positions, it would destroy opened quicklists and what not.

Which I understand that some sort of hack will be needed, I'd suggest something easier for the view. Perhaps like this?

QString tmp = m_icon;
m_icon.clear();
emit dataChanged({RoleIcon});
m_icon = tmp;
emit dataChanged({RoleIcon});

review: Needs Information
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

Done, still works if I simulate the model reset by setting the icon twice

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

two small inline comments

Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

something's wrong with merging... has some conflicts

review: Needs Fixing
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

Submitted on top of trunk, should be good now

Revision history for this message
Michael Zanetti (mzanetti) wrote :

hmm... for some reason it doesn't seem to work for me...

I've tested with manually installing this app [1] and then upgrading to the latest version in the systemsettings:

[1] http://notyetthere.org/data/com.ubuntu.developer.majster-pl.utorch_2.7.5_all.click

review: Needs Fixing
2210. By Lukáš Tinkl

no cache, more fun

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

> hmm... for some reason it doesn't seem to work for me...
>
> I've tested with manually installing this app [1] and then upgrading to the
> latest version in the systemsettings:
>
> [1] http://notyetthere.org/data/com.ubuntu.developer.majster-
> pl.utorch_2.7.5_all.click

OK, it was the cache after all :) Fixed

Revision history for this message
Michael Zanetti (mzanetti) wrote :

I'm still not a big fan of generally disabling the cache, but ok... it seems to be required in order to reload the picture and everything else (e.g. a Loader around the shape or similar) actually seems overkill too for the fact that we only have a limited number of items in the launcher.

 * Did you perform an exploratory manual test run of the code change and any related functionality?

yes

 * Did CI run pass? If not, please explain why.

yes

 * Did you make sure that the branch does not contain spurious tags?

yes

review: Approve
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2210
https://unity8-jenkins.ubuntu.com/job/lp-unity8-1-ci/550/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/308
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial,testname=qmluitests.sh/308
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=phone-armhf,release=vivid+overlay,testname=autopilot.sh/308
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/739
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/758
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/758
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/754
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/754/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/754
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/754/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/754
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/754/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/754
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/754/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/754
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/754/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/754
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/754/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-1-ci/550/rebuild

review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/Launcher/launcheritem.h'
2--- plugins/Unity/Launcher/launcheritem.h 2015-07-23 14:13:57 +0000
3+++ plugins/Unity/Launcher/launcheritem.h 2016-03-02 13:12:05 +0000
4@@ -32,7 +32,7 @@
5 {
6 Q_OBJECT
7 public:
8- LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent = 0);
9+ LauncherItem(const QString &appId, const QString &name, const QString &icon, QObject *parent = nullptr);
10
11 QString appId() const override;
12 QString name() const override;
13
14=== modified file 'plugins/Unity/Launcher/launchermodel.cpp'
15--- plugins/Unity/Launcher/launchermodel.cpp 2015-09-14 09:11:08 +0000
16+++ plugins/Unity/Launcher/launchermodel.cpp 2016-03-02 13:12:05 +0000
17@@ -103,7 +103,7 @@
18 LauncherItem *item = m_list.at(index);
19 if (!item->focused()) {
20 item->setAlerting(alerting);
21- Q_EMIT dataChanged(modelIndex, modelIndex, QVector<int>() << RoleAlerting);
22+ Q_EMIT dataChanged(modelIndex, modelIndex, {RoleAlerting});
23 }
24 }
25 }
26@@ -414,10 +414,19 @@
27 } else {
28 int idx = m_list.indexOf(item);
29 item->setName(desktopFile.displayName());
30- item->setIcon(desktopFile.icon());
31 item->setPinned(item->pinned()); // update pinned text if needed
32 item->setRunning(item->running());
33- Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleIcon, RoleRunning});
34+ Q_EMIT dataChanged(index(idx), index(idx), {RoleName, RoleRunning});
35+
36+ const QString oldIcon = item->icon();
37+ if (oldIcon == desktopFile.icon()) { // same icon file, perhaps different contents, simulate changing the icon name to force reload
38+ item->setIcon(QString());
39+ Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
40+ }
41+
42+ // now set the icon for real
43+ item->setIcon(desktopFile.icon());
44+ Q_EMIT dataChanged(index(idx), index(idx), {RoleIcon});
45 }
46 }
47
48@@ -489,7 +498,7 @@
49 if (idx >= 0) {
50 LauncherItem *item = m_list.at(idx);
51 setAlerting(item->appId(), true);
52- Q_EMIT dataChanged(index(idx), index(idx), QVector<int>() << RoleAlerting);
53+ Q_EMIT dataChanged(index(idx), index(idx), {RoleAlerting});
54 }
55 }
56
57
58=== modified file 'plugins/Unity/Launcher/launchermodel.h'
59--- plugins/Unity/Launcher/launchermodel.h 2015-07-29 12:32:57 +0000
60+++ plugins/Unity/Launcher/launchermodel.h 2016-03-02 13:12:05 +0000
61@@ -38,7 +38,7 @@
62 Q_OBJECT
63
64 public:
65- LauncherModel(QObject *parent = 0);
66+ LauncherModel(QObject *parent = nullptr);
67 ~LauncherModel();
68
69 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
70
71=== modified file 'qml/Launcher/LauncherDelegate.qml'
72--- qml/Launcher/LauncherDelegate.qml 2015-11-19 16:55:31 +0000
73+++ qml/Launcher/LauncherDelegate.qml 2016-03-02 13:12:05 +0000
74@@ -135,6 +135,7 @@
75 sourceSize.width: iconShape.width
76 sourceSize.height: iconShape.height
77 source: root.iconName
78+ cache: false // see lpbug#1543290 why no cache
79 }
80 }
81

Subscribers

People subscribed via source and target branches