on xenial help sign in
Fixes bug #1200569. Fixes: https://bugs.launchpad.net/bugs/1200569.
d7a2fd9Mirco Müller
Notifications/Notification.qml+3−7
@@ -23,7 +23,7 @@ import Utils 0.1
23UbuntuShape {
23UbuntuShape {
24 id: notification
24 id: notification
25
25
26− property alias iconSource: avatarIcon.source
26+ property alias iconSource: icon.fileSource
27 property alias secondaryIconSource: secondaryIcon.source
27 property alias secondaryIconSource: secondaryIcon.source
28 property alias summary: summaryLabel.text
28 property alias summary: summaryLabel.text
29 property alias body: bodyLabel.text
29 property alias body: bodyLabel.text
@@ -102,18 +102,14 @@ UbuntuShape {
102 right: parent.right
102 right: parent.right
103 }
103 }
104
104
105− UbuntuShape {
105+ ShapedIcon {
106 id: icon
106 id: icon
107
107
108 objectName: "icon"
108 objectName: "icon"
109 width: units.gu(6)
109 width: units.gu(6)
110 height: units.gu(6)
110 height: units.gu(6)
111+ shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
111 visible: iconSource !== undefined && iconSource != ""
112 visible: iconSource !== undefined && iconSource != ""
112− image: Image {
113− id: avatarIcon
114−
115− fillMode: Image.PreserveAspectCrop
116− }
117 }
113 }
118
114
119 Image {
115 Image {
Notifications/ShapedIcon.qmlnew file+40
@@ -0,0 +1,40 @@
1+/*
2+ * Copyright (C) 2013 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+
17+import QtQuick 2.0
18+import Ubuntu.Components 0.1
19+
20+Item {
21+ property string fileSource
22+ property bool shaped
23+
24+ UbuntuShape {
25+ objectName: "shapedIcon"
26+ anchors.fill: parent
27+ visible: shaped
28+ image: realImage
29+ }
30+
31+ Image {
32+ id: realImage
33+
34+ objectName: "nonShapedIcon"
35+ anchors.fill: parent
36+ visible: !shaped
37+ source: fileSource
38+ fillMode: Image.PreserveAspectCrop
39+ }
40+}
tests/qmltests/Notifications/tst_Notifications.qml+56
@@ -76,6 +76,20 @@ Row {
76 mockModel.append(n)
76 mockModel.append(n)
77 }
77 }
78
78
79+ function addEphemeralNonShapedIconNotification() {
80+ var n = {
81+ type: Notification.Ephemeral,
82+ hints: {"x-canonical-non-shaped-icon": "true"},
83+ summary: "Contacts",
84+ body: "Synchronised contacts-database with cloud-storage.",
85+ icon: "../graphics/applicationIcons/contacts-app.png",
86+ secondaryIcon: "",
87+ actions: []
88+ }
89+
90+ mockModel.append(n)
91+ }
92+
79 function addEphemeralIconSummaryNotification() {
93 function addEphemeralIconSummaryNotification() {
80 var n = {
94 var n = {
81 type: Notification.Ephemeral,
95 type: Notification.Ephemeral,
@@ -156,6 +170,12 @@ Row {
156 onClicked: addEphemeralNotification()
170 onClicked: addEphemeralNotification()
157 }
171 }
158
172
173+ Button {
174+ width: parent.width
175+ text: "add an non-shaped-icon-summary-body"
176+ onClicked: addEphemeralNonShapedIconNotification()
177+ }
178+
159 Button {
179 Button {
160 width: parent.width
180 width: parent.width
161 text: "add an icon-summary"
181 text: "add an icon-summary"
@@ -206,6 +226,8 @@ Row {
206 bodyVisible: true,
226 bodyVisible: true,
207 interactiveAreaEnabled: false,
227 interactiveAreaEnabled: false,
208 iconVisible: true,
228 iconVisible: true,
229+ shapedIcon: true,
230+ nonShapedIcon: false,
209 secondaryIconVisible: true,
231 secondaryIconVisible: true,
210 buttonRowVisible: true,
232 buttonRowVisible: true,
211 buttonTinted: true
233 buttonTinted: true
@@ -223,6 +245,8 @@ Row {
223 bodyVisible: false,
245 bodyVisible: false,
224 interactiveAreaEnabled: false,
246 interactiveAreaEnabled: false,
225 iconVisible: false,
247 iconVisible: false,
248+ shapedIcon: false,
249+ nonShapedIcon: false,
226 secondaryIconVisible: true,
250 secondaryIconVisible: true,
227 buttonRowVisible: false,
251 buttonRowVisible: false,
228 buttonTinted: false
252 buttonTinted: false
@@ -240,6 +264,8 @@ Row {
240 bodyVisible: false,
264 bodyVisible: false,
241 interactiveAreaEnabled: false,
265 interactiveAreaEnabled: false,
242 iconVisible: false,
266 iconVisible: false,
267+ shapedIcon: false,
268+ nonShapedIcon: false,
243 secondaryIconVisible: true,
269 secondaryIconVisible: true,
244 buttonRowVisible: false,
270 buttonRowVisible: false,
245 buttonTinted: false
271 buttonTinted: false
@@ -257,6 +283,8 @@ Row {
257 bodyVisible: true,
283 bodyVisible: true,
258 interactiveAreaEnabled: true,
284 interactiveAreaEnabled: true,
259 iconVisible: true,
285 iconVisible: true,
286+ shapedIcon: true,
287+ nonShapedIcon: false,
260 secondaryIconVisible: false,
288 secondaryIconVisible: false,
261 buttonRowVisible: false,
289 buttonRowVisible: false,
262 buttonTinted: false
290 buttonTinted: false
@@ -275,6 +303,8 @@ Row {
275 bodyVisible: true,
303 bodyVisible: true,
276 interactiveAreaEnabled: false,
304 interactiveAreaEnabled: false,
277 iconVisible: true,
305 iconVisible: true,
306+ shapedIcon: true,
307+ nonShapedIcon: false,
278 secondaryIconVisible: false,
308 secondaryIconVisible: false,
279 buttonRowVisible: true,
309 buttonRowVisible: true,
280 buttonTinted: false
310 buttonTinted: false
@@ -292,9 +322,31 @@ Row {
292 bodyVisible: true,
322 bodyVisible: true,
293 interactiveAreaEnabled: false,
323 interactiveAreaEnabled: false,
294 iconVisible: true,
324 iconVisible: true,
325+ shapedIcon: true,
326+ nonShapedIcon: false,
295 secondaryIconVisible: true,
327 secondaryIconVisible: true,
296 buttonRowVisible: false,
328 buttonRowVisible: false,
297 buttonTinted: false
329 buttonTinted: false
330+ },
331+ {
332+ tag: "Ephemeral notification with non-shaped icon",
333+ type: Notification.Ephemeral,
334+ hints: {"x-canonical-private-button-tint": "false",
335+ "x-canonical-non-shaped-icon": "true"},
336+ summary: "Contacts",
337+ body: "Synchronised contacts-database with cloud-storage.",
338+ icon: "../graphics/applicationIcons/contacts-app.png",
339+ secondaryIcon: "",
340+ actions: [],
341+ summaryVisible: true,
342+ bodyVisible: true,
343+ interactiveAreaEnabled: false,
344+ iconVisible: true,
345+ shapedIcon: false,
346+ nonShapedIcon: true,
347+ secondaryIconVisible: false,
348+ buttonRowVisible: false,
349+ buttonTinted: false
298 }
350 }
299 ]
351 ]
300 }
352 }
@@ -330,6 +382,8 @@ Row {
330 verify(notification !== undefined, "notification wasn't found");
382 verify(notification !== undefined, "notification wasn't found");
331
383
332 var icon = findChild(notification, "icon")
384 var icon = findChild(notification, "icon")
385+ var shapedIcon = findChild(notification, "shapedIcon")
386+ var nonShapedIcon = findChild(notification, "nonShapedIcon")
333 var interactiveArea = findChild(notification, "interactiveArea")
387 var interactiveArea = findChild(notification, "interactiveArea")
334 var secondaryIcon = findChild(notification, "secondaryIcon")
388 var secondaryIcon = findChild(notification, "secondaryIcon")
335 var summaryLabel = findChild(notification, "summaryLabel")
389 var summaryLabel = findChild(notification, "summaryLabel")
@@ -338,6 +392,8 @@ Row {
338 waitForRendering(buttonRow)
392 waitForRendering(buttonRow)
339
393
340 compare(icon.visible, data.iconVisible, "avatar-icon visibility is incorrect")
394 compare(icon.visible, data.iconVisible, "avatar-icon visibility is incorrect")
395+ compare(shapedIcon.visible, data.shapedIcon, "shaped-icon visibility is incorrect")
396+ compare(nonShapedIcon.visible, data.nonShapedIcon, "non-shaped-icon visibility is incorrect")
341 compare(interactiveArea.enabled, data.interactiveAreaEnabled, "check for interactive area")
397 compare(interactiveArea.enabled, data.interactiveAreaEnabled, "check for interactive area")
342
398
343 if(data.interactiveAreaEnabled) {
399 if(data.interactiveAreaEnabled) {