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

Proposed by Lars Karlitski
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
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz (community) Needs Resubmitting
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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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: Needs Resubmitting
77. By Lars Karlitski

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.

Revision history for this message
Lars Karlitski (larsu) wrote :

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

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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

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

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
=== modified file 'SettingsComponents.qml'
--- SettingsComponents.qml 2014-07-04 14:07:50 +0000
+++ SettingsComponents.qml 2014-08-26 15:38:35 +0000
@@ -256,35 +256,6 @@
256 }256 }
257 }257 }
258 }258 }
259
260 Row {
261 anchors {
262 left: parent.left
263 right: parent.right
264 }
265
266 spacing: units.gu(1)
267
268 Label {
269 text: "StatusIcon"
270 anchors.verticalCenter: parent.verticalCenter
271 }
272
273 StatusIcon {
274 height: units.gu(5)
275 source: "image://theme/gps"
276 }
277
278 StatusIcon {
279 height: units.gu(5)
280 source: "image://theme/battery-caution"
281 }
282
283 StatusIcon {
284 height: units.gu(5)
285 source: "image://theme/missing,gpm-battery-000-charging"
286 }
287 }
288 }259 }
289 }260 }
290 }261 }
291262
=== removed file 'Ubuntu/Settings/Components/StatusIcon.qml'
--- Ubuntu/Settings/Components/StatusIcon.qml 2014-07-01 12:10:32 +0000
+++ Ubuntu/Settings/Components/StatusIcon.qml 1970-01-01 00:00:00 +0000
@@ -1,129 +0,0 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18
19Item {
20 id: root
21
22 /*!
23 The source of the icon to display.
24 \qmlproperty url source
25 */
26 property url source
27
28 /*!
29 The color that all pixels that originally are of color \l keyColor should take.
30 \qmlproperty color color
31 */
32 property alias color: colorizedImage.keyColorOut
33
34 /*!
35 The color of the pixels that should be colorized.
36 By default it is set to #808080.
37 \qmlproperty color keyColor
38 */
39 property alias keyColor: colorizedImage.keyColorIn
40
41 // FIXME: should only be "status", but overriding in settings app doesn't work.
42 property var sets: ["status","apps"]
43
44 implicitWidth: image.width
45
46 Image {
47 id: image
48 objectName: "image"
49 anchors { top: parent.top; bottom: parent.bottom }
50 sourceSize.height: height
51
52 visible: !colorizedImage.active
53
54 property string iconPath: "/usr/share/icons/suru/%1/scalable/%2.svg"
55 property var icons: {
56 if (String(root.source).match(/^image:\/\/theme/)) {
57 return String(root.source).replace("image://theme/", "").split(",");
58 } else return null;
59 }
60 property int fallback: 0
61 property int setFallback: 0
62
63 Component.onCompleted: updateSource()
64 onStatusChanged: if (status == Image.Error) bump();
65 onIconsChanged: reset()
66
67 Connections {
68 target: root
69 onSetsChanged: image.reset()
70 }
71
72 function reset() {
73 fallback = 0;
74 setFallback = 0;
75
76 updateSource();
77 }
78
79 function bump() {
80 if (icons === null) return;
81 if (fallback < icons.length - 1) fallback += 1;
82 else if (setFallback < root.sets.length - 1) {
83 setFallback += 1;
84 fallback = 0;
85 } else {
86 console.warn("Could not load StatusIcon with source \"%1\" and sets %2.".arg(root.source).arg(root.sets));
87 return;
88 }
89
90 updateSource();
91 }
92
93 function updateSource() {
94 if (icons === null) {
95 source = root.source;
96 } else {
97 source = (root.sets && root.sets.length > setFallback) && (icons && icons.length > fallback) ?
98 iconPath.arg(root.sets[setFallback]).arg(icons[fallback]) : "";
99 }
100 }
101 }
102
103 ShaderEffect {
104 id: colorizedImage
105
106 anchors.fill: parent
107 visible: active && image.status == Image.Ready
108
109 // Whether or not a color has been set.
110 property bool active: keyColorOut != Qt.rgba(0.0, 0.0, 0.0, 0.0)
111
112 property Image source: visible ? image : null
113 property color keyColorOut: Qt.rgba(0.0, 0.0, 0.0, 0.0)
114 property color keyColorIn: "#808080"
115 property real threshold: 0.1
116
117 fragmentShader: "
118 varying highp vec2 qt_TexCoord0;
119 uniform sampler2D source;
120 uniform highp vec4 keyColorOut;
121 uniform highp vec4 keyColorIn;
122 uniform lowp float threshold;
123 uniform lowp float qt_Opacity;
124 void main() {
125 lowp vec4 sourceColor = texture2D(source, qt_TexCoord0);
126 gl_FragColor = mix(vec4(keyColorOut.rgb, 1.0) * sourceColor.a, sourceColor, step(threshold, distance(sourceColor.rgb / sourceColor.a, keyColorIn.rgb))) * qt_Opacity;
127 }"
128 }
129}
1300
=== modified file 'Ubuntu/Settings/Components/qmldir'
--- Ubuntu/Settings/Components/qmldir 2014-06-30 15:36:05 +0000
+++ Ubuntu/Settings/Components/qmldir 2014-08-26 15:38:35 +0000
@@ -5,4 +5,3 @@
5HeroMessageHeader 0.1 HeroMessageHeader.qml5HeroMessageHeader 0.1 HeroMessageHeader.qml
6IconVisual 0.1 IconVisual.qml6IconVisual 0.1 IconVisual.qml
7QuickReply 0.1 QuickReply.qml7QuickReply 0.1 QuickReply.qml
8StatusIcon 0.1 StatusIcon.qml
98
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2014-07-04 14:07:50 +0000
+++ tests/qmltests/CMakeLists.txt 2014-08-26 15:38:35 +0000
@@ -11,7 +11,6 @@
11)11)
1212
13add_qml_test(Components Calendar)13add_qml_test(Components Calendar)
14add_qml_test(Components StatusIcon)
1514
16add_qml_test(Menus AccessPointMenu)15add_qml_test(Menus AccessPointMenu)
17add_qml_test(Menus ButtonMenu)16add_qml_test(Menus ButtonMenu)
1817
=== removed file 'tests/qmltests/Components/tst_StatusIcon.qml'
--- tests/qmltests/Components/tst_StatusIcon.qml 2014-07-01 10:41:39 +0000
+++ tests/qmltests/Components/tst_StatusIcon.qml 1970-01-01 00:00:00 +0000
@@ -1,80 +0,0 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import QtTest 1.0
19import Ubuntu.Components 0.1
20import Ubuntu.Settings.Components 0.1
21import "../utils.js" as UtilsJS
22
23Item {
24 width: units.gu(40)
25 height: units.gu(70)
26
27 StatusIcon {
28 id: icon
29
30 height: units.gu(3)
31 }
32
33 TestCase {
34 name: "StatusIcon"
35 when: windowShown
36
37 function init() {
38 icon.source = "";
39 icon.sets = [ "status" ]
40 waitForRendering(icon)
41 }
42
43 function test_icon() {
44 icon.source = "image://theme/bar,gps,baz";
45
46 var image = UtilsJS.findChild(icon, "image");
47 tryCompare(image, "source", "file://" + image.iconPath.arg("status").arg("gps"));
48 }
49
50 function test_iconFallback() {
51 icon.source = "image://theme/foo,bar,baz";
52
53 var image = UtilsJS.findChild(icon, "image");
54 tryCompare(image, "source", "file://" + image.iconPath.arg("status").arg("baz"));
55 }
56
57 function test_iconSets() {
58 icon.source = "image://theme/bar,add,baz";
59 icon.sets = [ "foo", "actions", "bar" ]
60
61 var image = UtilsJS.findChild(icon, "image");
62 tryCompare(image, "source", "file://" + image.iconPath.arg("actions").arg("add"));
63 }
64
65 function test_iconSetsFallback() {
66 icon.source = "image://theme/add,bar,baz";
67 icon.sets = [ "foo", "bar", "baz" ]
68
69 var image = UtilsJS.findChild(icon, "image");
70 tryCompare(image, "source", "file://" + image.iconPath.arg("baz").arg("baz"));
71 }
72
73 function test_iconSource() {
74 var image = UtilsJS.findChild(icon, "image");
75 icon.source = image.iconPath.arg("status").arg("gps");
76
77 tryCompare(image, "source", "file://" + image.iconPath.arg("status").arg("gps"));
78 }
79 }
80}

Subscribers

People subscribed via source and target branches

to all changes: