Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/unity-theme-icon-provider into lp:ubuntu-ui-toolkit
- unity-theme-icon-provider
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Zsombor Egri |
Approved revision: | 692 |
Merged at revision: | 725 |
Proposed branch: | lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/unity-theme-icon-provider |
Merge into: | lp:ubuntu-ui-toolkit |
Diff against target: |
147 lines (+88/-2) 5 files modified
modules/Ubuntu/Components/Icon.qml (+1/-1) modules/Ubuntu/Components/plugin/plugin.cpp (+3/-1) modules/Ubuntu/Components/plugin/plugin.pro (+2/-0) modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp (+51/-0) modules/Ubuntu/Components/plugin/unitythemeiconprovider.h (+31/-0) |
To merge this branch: | bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/unity-theme-icon-provider |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Lars Karlitski (community) | Approve | ||
Michał Sawicz | conceptual | Approve | |
Michal Hruby (community) | Approve | ||
Mirco Müller | Pending | ||
Zsombor Egri | Pending | ||
Nick Dedekind | Pending | ||
Antti Kaijanmäki | Pending | ||
Review via email: mp+180805@code.launchpad.net |
This proposal supersedes a proposal from 2013-08-07.
Commit message
Add UnityThemeIconP
Description of the change
Add UnityThemeIconP
A QQuickImageProvider that loads icons from the current icon theme, following the xdg icon spec. It can be used like this:
image:
This is supposed to replace the gicon provider. I left that one in for now because it's still used by some components.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
Antti Kaijanmäki (kaijanmaki) wrote : Posted in a previous version of this proposal | # |
Looks valid! I need this for the Launcher. Somebody, please, top approve.
Zsombor Egri (zsombi) wrote : Posted in a previous version of this proposal | # |
Unit tests testing API and component functionality is missing. The MR cannot be approved without that.
Code wise looks good.
Nick Dedekind (nick-dedekind) wrote : Posted in a previous version of this proposal | # |
Getting fuzzy icons.
Please use available sizes if not provided.
QIcon themedIcon = QIcon::
if (requestedSize.
return themedIcon.
} else {
return themedIcon.
}
Nick Dedekind (nick-dedekind) wrote : Posted in a previous version of this proposal | # |
Actually a more robust solution:
I've proposed these changes to qmenumodel where this provider currently resides.
if (!icon.isNull()) {
if (requestedSize.
return themedIcon.
} else {
if (sizes.count() > 0 && sizes.last(
} else {
}
}
}
return QPixmap();
Antti Kaijanmäki (kaijanmaki) wrote : Posted in a previous version of this proposal | # |
superseding this one with a public branch MR.
Antti Kaijanmäki (kaijanmaki) wrote : | # |
Seems I hit a couple of bugs:
notify-osd and notify-osd-icons packages are not providing index.theme :/
QIcon::themedIcon is not looking up all the base directories. It just takes the first one with matching theme directory and gives up if the requested icon is not found. Thus notify-osd icons are not found (after adding the index.theme).
Both needs fixing.
Antti Kaijanmäki (kaijanmaki) wrote : | # |
FYI, the reason for dealing with notify-osd is to provide the functionality proposed in this MR for gicon:
https:/
Antti Kaijanmäki (kaijanmaki) wrote : | # |
Another QIcon::fromTheme() bug:
QIcon is not loading images from /usr/share/pixmaps correctly as required by the icon-theme-spec.
Just try to load "firefox".
Antti Kaijanmäki (kaijanmaki) wrote : | # |
based on the IRC discussion this provider should also be able to load images with absolute and relative paths. The current code does not support this. simply try to load /usr/share/
Michał Sawicz (saviq) wrote : | # |
Actually the above is incorrect.
I believe the "name" property should only be left as convenience when used directly:
Icon {
name: "some-known-
}
Whenever the icon url is provided by a backend - it should be a "fully-qualified" url, i.e. full image://theme/name path, not just "name", and Icon should have a "source" property to deal with those. No one should need to guess whether it's a themed icon or a full path. IMO Icon should be renamed to "ColourizedIcon" or similar, to denote its real purpose, but Image { } should be enough to use, letting the image providers do their thing.
Nick Dedekind (nick-dedekind) wrote : | # |
Now using maximum available icon size if requested size not set.
Antti Kaijanmäki (kaijanmaki) wrote : | # |
> Now using maximum available icon size if requested size not set.
Thanks! How does this work with SVG images? QIcon probably SHOULD honour the MaxSize specified in index.theme, but for some reason I've lost all hope regarding QImage::fromTheme() ;)
Obviously this has to be tested so we don't get oversized images.
Antti Kaijanmäki (kaijanmaki) wrote : | # |
> Actually the above is incorrect.
>
> I believe the "name" property should only be left as convenience when used
> directly:
>
> Icon {
> name: "some-known-
> }
>
> Whenever the icon url is provided by a backend - it should be a "fully-
> qualified" url, i.e. full image://theme/name path, not just "name", and Icon
> should have a "source" property to deal with those. No one should need to
> guess whether it's a themed icon or a full path. IMO Icon should be renamed to
> "ColourizedIcon" or similar, to denote its real purpose, but Image { } should
> be enough to use, letting the image providers do their thing.
OK, so conclusions from IRC discussions were that theme image provider should only load themed icons. If the developer wants to load absolute or relative icons he should use "file://"
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:685
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:686
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Michal Hruby (mhr3) wrote : | # |
135 + QIcon::
Unnecessary.
69 + engine-
The same provider is registered in libqmenumodel, is that one going to be removed?
Would be nice if someone could fix the conflict too.
Lars Karlitski (larsu) wrote : | # |
> 69 + engine-
> UnityThemeIconP
>
> The same provider is registered in libqmenumodel, is that one going to be
> removed?
>
> Would be nice if someone could fix the conflict too.
I asked about this in #ubuntu-unity the other day and didn't get a clear answer. I think it's easiest if we just make libqmenumodel depend on ubuntu-ui-toolkit and remove its copy of the "theme" provider. I'll propose a merge for that later today.
Michal Hruby (mhr3) : | # |
Michał Sawicz (saviq) wrote : | # |
Yup, this is good as a first step towards "no guessing" around icons.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:688
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Lars Karlitski (larsu) wrote : | # |
The changes on top of my branch look good to me, thanks.
- 689. By Antti Kaijanmäki
-
Test for unity-theme-
icon-provider - 690. By Antti Kaijanmäki
-
merge from upstream
- 691. By Antti Kaijanmäki
-
remove notifyosd icons from gallery.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:691
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Antti Kaijanmäki (kaijanmaki) wrote : | # |
> Seems I hit a couple of bugs:
>
> notify-osd and notify-osd-icons packages are not providing index.theme :/
This is actually not a bug IF the directory is simply extending another theme directory which contains the index.theme. QIconLoader just can't handle themes expanding over multiple base dirs at the moment, so using this loader for notify-osd INSIDE the shell is not possible at the moment.
I removed the remaining notify-osd stuff for now. NotifyOSD has to use it's custom loader.
> QIcon::themedIcon is not looking up all the base directories. It just takes
> the first one with matching theme directory and gives up if the requested icon
> is not found. Thus notify-osd icons are not found (after adding the
> index.theme).
>
> Both needs fixing.
So, this is an upstream bug and not trivial to fix. The whole QIconLoader would need a redesign.
Antti Kaijanmäki (kaijanmaki) wrote : | # |
> Another QIcon::fromTheme() bug:
>
> QIcon is not loading images from /usr/share/pixmaps correctly as required by
> the icon-theme-spec.
>
> Just try to load "firefox".
When these changes get merged to Qt dev we can distro patch them in.
https:/
https:/
Antti Kaijanmäki (kaijanmaki) wrote : | # |
OK, I have a test now, BUT.
The unit tests are run with -platform minimal and this breaks the QIcon::fromTheme().
The only option I see is to create a .qrc and embed an icon theme there and test with that (as :/ is always added to the search paths. this is actually not documented..)
I'm starting to wonder if it's really worth it to write these tests..
- 692. By Antti Kaijanmäki
-
remove test case
Antti Kaijanmäki (kaijanmaki) wrote : | # |
OK, I give up.
There seems to be no way of reliably test the theme icon provider under CI right now.
As all the tests are run with -platform minimal this prevents picking up an actual system theme (which probably is not set properly under Jenkins anyway) and thus preventing loading icons from a system theme (tried to pull in humanity-icon-theme as build-dep for this test).
I also tried to embed a theme as qrc file the same way upstream Qt tests the QIcon::fromTheme() but seems that quick test lib does not load app .qrc files properly so this was a dead end also.
I would either accept this MR as it is or somebody should instruct me how to test this. I'm out of ideas.
Anyone who is interested the test case is available in commit 689. It can be run manually on a standard desktop session and it passes, but as I said I'm unable to get it working with Jenkins environment.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:692
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) : | # |
Preview Diff
1 | === modified file 'modules/Ubuntu/Components/Icon.qml' |
2 | --- modules/Ubuntu/Components/Icon.qml 2013-08-27 09:28:49 +0000 |
3 | +++ modules/Ubuntu/Components/Icon.qml 2013-08-28 20:35:44 +0000 |
4 | @@ -82,7 +82,7 @@ |
5 | Component.onCompleted: ready = true |
6 | |
7 | anchors.fill: parent |
8 | - source: ready && width > 0 && height > 0 && icon.name ? "image://gicon/%1".arg(icon.name) : "" |
9 | + source: ready && width > 0 && height > 0 && icon.name ? "image://theme/%1".arg(icon.name) : "" |
10 | sourceSize { |
11 | width: width |
12 | height: height |
13 | |
14 | === modified file 'modules/Ubuntu/Components/plugin/plugin.cpp' |
15 | --- modules/Ubuntu/Components/plugin/plugin.cpp 2013-08-16 10:16:48 +0000 |
16 | +++ modules/Ubuntu/Components/plugin/plugin.cpp 2013-08-28 20:35:44 +0000 |
17 | @@ -44,6 +44,7 @@ |
18 | #include "ucargument.h" |
19 | #include "ucalarm.h" |
20 | #include "ucalarmmodel.h" |
21 | +#include "unitythemeiconprovider.h" |
22 | |
23 | #include <sys/types.h> |
24 | #include <unistd.h> |
25 | @@ -184,8 +185,9 @@ |
26 | |
27 | engine->addImageProvider(QLatin1String("scaling"), new UCScalingImageProvider); |
28 | |
29 | - // register gicon provider |
30 | + // register icon providers |
31 | engine->addImageProvider(QLatin1String("gicon"), new GIconProvider); |
32 | + engine->addImageProvider(QLatin1String("theme"), new UnityThemeIconProvider); |
33 | |
34 | // Necessary for Screen.orientation (from import QtQuick.Window 2.0) to work |
35 | QGuiApplication::primaryScreen()->setOrientationUpdateMask( |
36 | |
37 | === modified file 'modules/Ubuntu/Components/plugin/plugin.pro' |
38 | --- modules/Ubuntu/Components/plugin/plugin.pro 2013-08-23 11:01:37 +0000 |
39 | +++ modules/Ubuntu/Components/plugin/plugin.pro 2013-08-28 20:35:44 +0000 |
40 | @@ -47,6 +47,7 @@ |
41 | alarmmanager_p_p.h \ |
42 | alarmmanager_p.h \ |
43 | ucalarmmodel.h \ |
44 | + unitythemeiconprovider.h \ |
45 | alarmrequest_p.h \ |
46 | alarmrequest_p_p.h |
47 | |
48 | @@ -72,6 +73,7 @@ |
49 | ucalarm.cpp \ |
50 | alarmmanager_p.cpp \ |
51 | ucalarmmodel.cpp \ |
52 | + unitythemeiconprovider.cpp \ |
53 | alarmrequest_p.cpp |
54 | |
55 | # adapters |
56 | |
57 | === added file 'modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp' |
58 | --- modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp 1970-01-01 00:00:00 +0000 |
59 | +++ modules/Ubuntu/Components/plugin/unitythemeiconprovider.cpp 2013-08-28 20:35:44 +0000 |
60 | @@ -0,0 +1,51 @@ |
61 | +/* |
62 | + * Copyright 2013 Canonical Ltd. |
63 | + * |
64 | + * This program is free software; you can redistribute it and/or modify |
65 | + * it under the terms of the GNU Lesser General Public License as published by |
66 | + * the Free Software Foundation; version 3. |
67 | + * |
68 | + * This program is distributed in the hope that it will be useful, |
69 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
70 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
71 | + * GNU Lesser General Public License for more details. |
72 | + * |
73 | + * You should have received a copy of the GNU Lesser General Public License |
74 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
75 | + * |
76 | + * Authors: Lars Uebernickel <lars.uebernickel@canonical.com> |
77 | + */ |
78 | + |
79 | +#include "unitythemeiconprovider.h" |
80 | + |
81 | +#include <QIcon> |
82 | + |
83 | +UnityThemeIconProvider::UnityThemeIconProvider(): |
84 | + QQuickImageProvider(QQuickImageProvider::Pixmap) |
85 | +{ |
86 | +} |
87 | + |
88 | +QPixmap UnityThemeIconProvider::requestPixmap(const QString &id, QSize *realSize, const QSize &requestedSize) |
89 | +{ |
90 | + QIcon icon; |
91 | + |
92 | + Q_FOREACH (QString name, id.split(",", QString::SkipEmptyParts)) { |
93 | + icon = QIcon::fromTheme(name); |
94 | + if (!icon.isNull()) { |
95 | + if (requestedSize.isValid()) { |
96 | + *realSize =requestedSize; |
97 | + return icon.pixmap(requestedSize); |
98 | + } else { |
99 | + QList<QSize> sizes = icon.availableSizes(); |
100 | + if (sizes.count() > 0 && sizes.last().isValid()) { |
101 | + *realSize = sizes.last(); |
102 | + } else { |
103 | + *realSize = QSize(32,32); |
104 | + } |
105 | + return icon.pixmap(*realSize); |
106 | + } |
107 | + break; |
108 | + } |
109 | + } |
110 | + return QPixmap(); |
111 | +} |
112 | |
113 | === added file 'modules/Ubuntu/Components/plugin/unitythemeiconprovider.h' |
114 | --- modules/Ubuntu/Components/plugin/unitythemeiconprovider.h 1970-01-01 00:00:00 +0000 |
115 | +++ modules/Ubuntu/Components/plugin/unitythemeiconprovider.h 2013-08-28 20:35:44 +0000 |
116 | @@ -0,0 +1,31 @@ |
117 | +/* |
118 | + * Copyright 2013 Canonical Ltd. |
119 | + * |
120 | + * This program is free software; you can redistribute it and/or modify |
121 | + * it under the terms of the GNU Lesser General Public License as published by |
122 | + * the Free Software Foundation; version 3. |
123 | + * |
124 | + * This program is distributed in the hope that it will be useful, |
125 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
126 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
127 | + * GNU Lesser General Public License for more details. |
128 | + * |
129 | + * You should have received a copy of the GNU Lesser General Public License |
130 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
131 | + * |
132 | + * Authors: Lars Uebernickel <lars.uebernickel@canonical.com> |
133 | + */ |
134 | + |
135 | +#ifndef UNITY_THEME_ICON_PROVIDER_H |
136 | +#define UNITY_THEME_ICON_PROVIDER_H |
137 | + |
138 | +#include <QQuickImageProvider> |
139 | + |
140 | +class UnityThemeIconProvider: public QQuickImageProvider |
141 | +{ |
142 | +public: |
143 | + UnityThemeIconProvider(); |
144 | + QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize); |
145 | +}; |
146 | + |
147 | +#endif |
PASSED: Continuous integration, rev:680 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- ci/480/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- saucy/1989 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-amd64- ci/337 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-armhf- ci/337 jenkins. qa.ubuntu. com/job/ ubuntu- ui-toolkit- saucy-armhf- ci/337/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy/1994 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- saucy/1994/ artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ generic- mediumtests- runner- saucy/1698
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ ubuntu- ui-toolkit- ci/480/ rebuild
http://