on xenial help sign in
Fixes bug #1200569. Fixes: https://bugs.launchpad.net/bugs/1200569.

Approved by PS Jenkins bot, Michael Zanetti.

commitd7a2fd9c04183b465ddacb22f5b800a0ffa8f574 authorMirco Müller <mirco.mueller@ubuntu.com> dateThu 21 Nov 2013, 20:18 (13 years ago) parent9b2a564a520b9e
3 files changed+99−7
Notifications/Notification.qml+3−7 Notifications/ShapedIcon.qml+40 tests/qmltests/Notifications/tst_Notifications.qml+56
Notifications/Notification.qml+3−7
@@ -23,7 +23,7 @@ import Utils 0.1
2323UbuntuShape {
2424 id: notification
2525
26− property alias iconSource: avatarIcon.source
26+ property alias iconSource: icon.fileSource
2727 property alias secondaryIconSource: secondaryIcon.source
2828 property alias summary: summaryLabel.text
2929 property alias body: bodyLabel.text
@@ -102,18 +102,14 @@ UbuntuShape {
102102 right: parent.right
103103 }
104104
105− UbuntuShape {
105+ ShapedIcon {
106106 id: icon
107107
108108 objectName: "icon"
109109 width: units.gu(6)
110110 height: units.gu(6)
111+ shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
111112 visible: iconSource !== undefined && iconSource != ""
112− image: Image {
113− id: avatarIcon
114−
115− fillMode: Image.PreserveAspectCrop
116− }
117113 }
118114
119115 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 {
7676 mockModel.append(n)
7777 }
7878
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+
7993 function addEphemeralIconSummaryNotification() {
8094 var n = {
8195 type: Notification.Ephemeral,
@@ -156,6 +170,12 @@ Row {
156170 onClicked: addEphemeralNotification()
157171 }
158172
173+ Button {
174+ width: parent.width
175+ text: "add an non-shaped-icon-summary-body"
176+ onClicked: addEphemeralNonShapedIconNotification()
177+ }
178+
159179 Button {
160180 width: parent.width
161181 text: "add an icon-summary"
@@ -206,6 +226,8 @@ Row {
206226 bodyVisible: true,
207227 interactiveAreaEnabled: false,
208228 iconVisible: true,
229+ shapedIcon: true,
230+ nonShapedIcon: false,
209231 secondaryIconVisible: true,
210232 buttonRowVisible: true,
211233 buttonTinted: true
@@ -223,6 +245,8 @@ Row {
223245 bodyVisible: false,
224246 interactiveAreaEnabled: false,
225247 iconVisible: false,
248+ shapedIcon: false,
249+ nonShapedIcon: false,
226250 secondaryIconVisible: true,
227251 buttonRowVisible: false,
228252 buttonTinted: false
@@ -240,6 +264,8 @@ Row {
240264 bodyVisible: false,
241265 interactiveAreaEnabled: false,
242266 iconVisible: false,
267+ shapedIcon: false,
268+ nonShapedIcon: false,
243269 secondaryIconVisible: true,
244270 buttonRowVisible: false,
245271 buttonTinted: false
@@ -257,6 +283,8 @@ Row {
257283 bodyVisible: true,
258284 interactiveAreaEnabled: true,
259285 iconVisible: true,
286+ shapedIcon: true,
287+ nonShapedIcon: false,
260288 secondaryIconVisible: false,
261289 buttonRowVisible: false,
262290 buttonTinted: false
@@ -275,6 +303,8 @@ Row {
275303 bodyVisible: true,
276304 interactiveAreaEnabled: false,
277305 iconVisible: true,
306+ shapedIcon: true,
307+ nonShapedIcon: false,
278308 secondaryIconVisible: false,
279309 buttonRowVisible: true,
280310 buttonTinted: false
@@ -292,9 +322,31 @@ Row {
292322 bodyVisible: true,
293323 interactiveAreaEnabled: false,
294324 iconVisible: true,
325+ shapedIcon: true,
326+ nonShapedIcon: false,
295327 secondaryIconVisible: true,
296328 buttonRowVisible: false,
297329 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
298350 }
299351 ]
300352 }
@@ -330,6 +382,8 @@ Row {
330382 verify(notification !== undefined, "notification wasn't found");
331383
332384 var icon = findChild(notification, "icon")
385+ var shapedIcon = findChild(notification, "shapedIcon")
386+ var nonShapedIcon = findChild(notification, "nonShapedIcon")
333387 var interactiveArea = findChild(notification, "interactiveArea")
334388 var secondaryIcon = findChild(notification, "secondaryIcon")
335389 var summaryLabel = findChild(notification, "summaryLabel")
@@ -338,6 +392,8 @@ Row {
338392 waitForRendering(buttonRow)
339393
340394 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")
341397 compare(interactiveArea.enabled, data.interactiveAreaEnabled, "check for interactive area")
342398
343399 if(data.interactiveAreaEnabled) {