Merge lp:~larsu/ubuntu-settings-components/remove-icon-lookup-hack into lp:~registry/ubuntu-settings-components/trunk

Proposed by Lars Karlitski on 2014-08-25
Status: Needs review
Proposed branch: lp:~larsu/ubuntu-settings-components/remove-icon-lookup-hack
Merge into: lp:~registry/ubuntu-settings-components/trunk
Diff against target: 279 lines (+0/-240)
5 files modified
SettingsComponents.qml (+0/-29)
Ubuntu/Settings/Components/StatusIcon.qml (+0/-129)
Ubuntu/Settings/Components/qmldir (+0/-1)
tests/qmltests/CMakeLists.txt (+0/-1)
tests/qmltests/Components/tst_StatusIcon.qml (+0/-80)
To merge this branch: bzr merge lp:~larsu/ubuntu-settings-components/remove-icon-lookup-hack
Reviewer Review Type Date Requested Status
Unity8 CI Bot (community) continuous-integration Needs Fixing on 2016-03-24
PS Jenkins bot (community) continuous-integration Approve on 2014-08-26
Michał Sawicz (community) 2014-08-25 Resubmit on 2014-08-25
Review via email: mp+232116@code.launchpad.net

Commit message

StatusIcon: remove icon loading hack

StatusIcon loads icons itself to make sure rectangular icons preserve their aspect ratio. It doesn't follow the fdo spec for this, but hard-codes some of the suru icon theme subdirectories. This breaks when someone requests an icon from a different subdirectory or doesn't have suru installed in /usr/share.

UnityThemeIconProvider supports rectangular icons now, making this workaround unnecessary.

Description of the change

StatusIcon: remove icon loading hack

This depends on lp:~larsu/ubuntu-ui-toolkit/custom-icon-lookup.

To post a comment you must log in.
Michał Sawicz (saviq) wrote :

This component should just go away completely, as well as its uses in unity8 and ubuntu-settings-components, once the UITK fix is in.

review: Resubmit
77. By Lars Karlitski on 2014-08-26

Remove StatusIcon

It worked around the fact that rectangular icons didn't work. The image
provider in ubuntu-ui-toolkit supports those now and people can just use its
Icon component instead.

Lars Karlitski (larsu) wrote :

Ok, removed it. I'm in the process of removing StatusIcon in Unity8 and System Settings as well.

Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Michał Sawicz (saviq) wrote :

Text conflict in examples/SettingsComponents.qml
Contents conflict in plugins/Ubuntu/Settings/Components/StatusIcon.qml
Text conflict in plugins/Ubuntu/Settings/Components/qmldir
Text conflict in tests/qmltests/CMakeLists.txt
Contents conflict in tests/qmltests/Components/tst_StatusIcon.qml
5 conflicts encountered.

Unmerged revisions

77. By Lars Karlitski on 2014-08-26

Remove StatusIcon

It worked around the fact that rectangular icons didn't work. The image
provider in ubuntu-ui-toolkit supports those now and people can just use its
Icon component instead.

76. By Lars Karlitski on 2014-08-25

StatusIcon: remove icon loading hack

StatusIcon loads icons itself to make sure rectangular icons preserve their
aspect ratio. It doesn't follow the fdo spec for this, but hard-codes some of
the suru icon theme subdirectories. This breaks when someone requests an icon
from a different subdirectory or doesn't have suru installed in /usr/share.

UnityThemeIconProvider supports rectangular icons now, making this workaround
unnecessary.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'SettingsComponents.qml'
2--- SettingsComponents.qml 2014-07-04 14:07:50 +0000
3+++ SettingsComponents.qml 2014-08-26 15:38:35 +0000
4@@ -256,35 +256,6 @@
5 }
6 }
7 }
8-
9- Row {
10- anchors {
11- left: parent.left
12- right: parent.right
13- }
14-
15- spacing: units.gu(1)
16-
17- Label {
18- text: "StatusIcon"
19- anchors.verticalCenter: parent.verticalCenter
20- }
21-
22- StatusIcon {
23- height: units.gu(5)
24- source: "image://theme/gps"
25- }
26-
27- StatusIcon {
28- height: units.gu(5)
29- source: "image://theme/battery-caution"
30- }
31-
32- StatusIcon {
33- height: units.gu(5)
34- source: "image://theme/missing,gpm-battery-000-charging"
35- }
36- }
37 }
38 }
39 }
40
41=== removed file 'Ubuntu/Settings/Components/StatusIcon.qml'
42--- Ubuntu/Settings/Components/StatusIcon.qml 2014-07-01 12:10:32 +0000
43+++ Ubuntu/Settings/Components/StatusIcon.qml 1970-01-01 00:00:00 +0000
44@@ -1,129 +0,0 @@
45-/*
46- * Copyright 2014 Canonical Ltd.
47- *
48- * This program is free software; you can redistribute it and/or modify
49- * it under the terms of the GNU General Public License as published by
50- * the Free Software Foundation; version 3.
51- *
52- * This program is distributed in the hope that it will be useful,
53- * but WITHOUT ANY WARRANTY; without even the implied warranty of
54- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55- * GNU General Public License for more details.
56- *
57- * You should have received a copy of the GNU General Public License
58- * along with this program. If not, see <http://www.gnu.org/licenses/>.
59- */
60-
61-import QtQuick 2.0
62-
63-Item {
64- id: root
65-
66- /*!
67- The source of the icon to display.
68- \qmlproperty url source
69- */
70- property url source
71-
72- /*!
73- The color that all pixels that originally are of color \l keyColor should take.
74- \qmlproperty color color
75- */
76- property alias color: colorizedImage.keyColorOut
77-
78- /*!
79- The color of the pixels that should be colorized.
80- By default it is set to #808080.
81- \qmlproperty color keyColor
82- */
83- property alias keyColor: colorizedImage.keyColorIn
84-
85- // FIXME: should only be "status", but overriding in settings app doesn't work.
86- property var sets: ["status","apps"]
87-
88- implicitWidth: image.width
89-
90- Image {
91- id: image
92- objectName: "image"
93- anchors { top: parent.top; bottom: parent.bottom }
94- sourceSize.height: height
95-
96- visible: !colorizedImage.active
97-
98- property string iconPath: "/usr/share/icons/suru/%1/scalable/%2.svg"
99- property var icons: {
100- if (String(root.source).match(/^image:\/\/theme/)) {
101- return String(root.source).replace("image://theme/", "").split(",");
102- } else return null;
103- }
104- property int fallback: 0
105- property int setFallback: 0
106-
107- Component.onCompleted: updateSource()
108- onStatusChanged: if (status == Image.Error) bump();
109- onIconsChanged: reset()
110-
111- Connections {
112- target: root
113- onSetsChanged: image.reset()
114- }
115-
116- function reset() {
117- fallback = 0;
118- setFallback = 0;
119-
120- updateSource();
121- }
122-
123- function bump() {
124- if (icons === null) return;
125- if (fallback < icons.length - 1) fallback += 1;
126- else if (setFallback < root.sets.length - 1) {
127- setFallback += 1;
128- fallback = 0;
129- } else {
130- console.warn("Could not load StatusIcon with source \"%1\" and sets %2.".arg(root.source).arg(root.sets));
131- return;
132- }
133-
134- updateSource();
135- }
136-
137- function updateSource() {
138- if (icons === null) {
139- source = root.source;
140- } else {
141- source = (root.sets && root.sets.length > setFallback) && (icons && icons.length > fallback) ?
142- iconPath.arg(root.sets[setFallback]).arg(icons[fallback]) : "";
143- }
144- }
145- }
146-
147- ShaderEffect {
148- id: colorizedImage
149-
150- anchors.fill: parent
151- visible: active && image.status == Image.Ready
152-
153- // Whether or not a color has been set.
154- property bool active: keyColorOut != Qt.rgba(0.0, 0.0, 0.0, 0.0)
155-
156- property Image source: visible ? image : null
157- property color keyColorOut: Qt.rgba(0.0, 0.0, 0.0, 0.0)
158- property color keyColorIn: "#808080"
159- property real threshold: 0.1
160-
161- fragmentShader: "
162- varying highp vec2 qt_TexCoord0;
163- uniform sampler2D source;
164- uniform highp vec4 keyColorOut;
165- uniform highp vec4 keyColorIn;
166- uniform lowp float threshold;
167- uniform lowp float qt_Opacity;
168- void main() {
169- lowp vec4 sourceColor = texture2D(source, qt_TexCoord0);
170- gl_FragColor = mix(vec4(keyColorOut.rgb, 1.0) * sourceColor.a, sourceColor, step(threshold, distance(sourceColor.rgb / sourceColor.a, keyColorIn.rgb))) * qt_Opacity;
171- }"
172- }
173-}
174
175=== modified file 'Ubuntu/Settings/Components/qmldir'
176--- Ubuntu/Settings/Components/qmldir 2014-06-30 15:36:05 +0000
177+++ Ubuntu/Settings/Components/qmldir 2014-08-26 15:38:35 +0000
178@@ -5,4 +5,3 @@
179 HeroMessageHeader 0.1 HeroMessageHeader.qml
180 IconVisual 0.1 IconVisual.qml
181 QuickReply 0.1 QuickReply.qml
182-StatusIcon 0.1 StatusIcon.qml
183
184=== modified file 'tests/qmltests/CMakeLists.txt'
185--- tests/qmltests/CMakeLists.txt 2014-07-04 14:07:50 +0000
186+++ tests/qmltests/CMakeLists.txt 2014-08-26 15:38:35 +0000
187@@ -11,7 +11,6 @@
188 )
189
190 add_qml_test(Components Calendar)
191-add_qml_test(Components StatusIcon)
192
193 add_qml_test(Menus AccessPointMenu)
194 add_qml_test(Menus ButtonMenu)
195
196=== removed file 'tests/qmltests/Components/tst_StatusIcon.qml'
197--- tests/qmltests/Components/tst_StatusIcon.qml 2014-07-01 10:41:39 +0000
198+++ tests/qmltests/Components/tst_StatusIcon.qml 1970-01-01 00:00:00 +0000
199@@ -1,80 +0,0 @@
200-/*
201- * Copyright 2014 Canonical Ltd.
202- *
203- * This program is free software; you can redistribute it and/or modify
204- * it under the terms of the GNU General Public License as published by
205- * the Free Software Foundation; version 3.
206- *
207- * This program is distributed in the hope that it will be useful,
208- * but WITHOUT ANY WARRANTY; without even the implied warranty of
209- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
210- * GNU General Public License for more details.
211- *
212- * You should have received a copy of the GNU General Public License
213- * along with this program. If not, see <http://www.gnu.org/licenses/>.
214- */
215-
216-import QtQuick 2.0
217-import QtTest 1.0
218-import Ubuntu.Components 0.1
219-import Ubuntu.Settings.Components 0.1
220-import "../utils.js" as UtilsJS
221-
222-Item {
223- width: units.gu(40)
224- height: units.gu(70)
225-
226- StatusIcon {
227- id: icon
228-
229- height: units.gu(3)
230- }
231-
232- TestCase {
233- name: "StatusIcon"
234- when: windowShown
235-
236- function init() {
237- icon.source = "";
238- icon.sets = [ "status" ]
239- waitForRendering(icon)
240- }
241-
242- function test_icon() {
243- icon.source = "image://theme/bar,gps,baz";
244-
245- var image = UtilsJS.findChild(icon, "image");
246- tryCompare(image, "source", "file://" + image.iconPath.arg("status").arg("gps"));
247- }
248-
249- function test_iconFallback() {
250- icon.source = "image://theme/foo,bar,baz";
251-
252- var image = UtilsJS.findChild(icon, "image");
253- tryCompare(image, "source", "file://" + image.iconPath.arg("status").arg("baz"));
254- }
255-
256- function test_iconSets() {
257- icon.source = "image://theme/bar,add,baz";
258- icon.sets = [ "foo", "actions", "bar" ]
259-
260- var image = UtilsJS.findChild(icon, "image");
261- tryCompare(image, "source", "file://" + image.iconPath.arg("actions").arg("add"));
262- }
263-
264- function test_iconSetsFallback() {
265- icon.source = "image://theme/add,bar,baz";
266- icon.sets = [ "foo", "bar", "baz" ]
267-
268- var image = UtilsJS.findChild(icon, "image");
269- tryCompare(image, "source", "file://" + image.iconPath.arg("baz").arg("baz"));
270- }
271-
272- function test_iconSource() {
273- var image = UtilsJS.findChild(icon, "image");
274- icon.source = image.iconPath.arg("status").arg("gps");
275-
276- tryCompare(image, "source", "file://" + image.iconPath.arg("status").arg("gps"));
277- }
278- }
279-}

Subscribers

People subscribed via source and target branches

to all changes: