on xenial help sign in
Completed support for non-shaped icon hint, added qmltest.
68f5dacMirco Müller
Notifications/Notification.qml+6−20
@@ -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
@@ -101,29 +101,14 @@ UbuntuShape {
101 right: parent.right
101 right: parent.right
102 }
102 }
103
103
104− Image {
104+ ShapedIcon {
105− id: noShapeIcon
106−
107− fillMode: Image.PreserveAspectCrop
108− objectName: "noShapeIcon"
109− width: units.gu(6)
110− height: units.gu(6)
111− source: iconSource
112− visible: iconSource !== undefined && iconSource !== "" && notification.hints["x-canonical-noshape-icon"] == "true"
113− }
114−
115− UbuntuShape {
116 id: icon
105 id: icon
117
106
118 objectName: "icon"
107 objectName: "icon"
119 width: units.gu(6)
108 width: units.gu(6)
120 height: units.gu(6)
109 height: units.gu(6)
121− visible: iconSource !== undefined && iconSource !== "" && notification.hints["x-canonical-noshape-icon"] !== "true"
110+ shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
122− image: Image {
111+ visible: iconSource !== undefined && iconSource != ""
123− id: avatarIcon
124−
125− fillMode: Image.PreserveAspectCrop
126− }
127 }
112 }
128
113
129 Image {
114 Image {
@@ -140,7 +125,8 @@ UbuntuShape {
140 id: labelColumn
125 id: labelColumn
141 width: parent.width - x
126 width: parent.width - x
142
127
143− anchors.verticalCenter: ((icon.visible || noShapeIcon.visible) && !bodyLabel.visible) ? (icon.visible ? icon.verticalCenter : noShapeIcon.verticalCenter) : undefined
128+ //anchors.verticalCenter: ((icon.visible || noShapeIcon.visible) && !bodyLabel.visible) ? (icon.visible ? icon.verticalCenter : noShapeIcon.verticalCenter) : undefined
129+ anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
144
130
145 Label {
131 Label {
146 id: summaryLabel
132 id: summaryLabel
Notifications/ShapedIcon.qmlnew file+23
@@ -0,0 +1,23 @@
1+import QtQuick 2.0
2+import Ubuntu.Components 0.1
3+
4+Item {
5+ property string fileSource
6+ property bool shaped
7+
8+ UbuntuShape {
9+ anchors.fill: parent
10+ visible: shaped
11+ image: Image {
12+ source: fileSource
13+ fillMode: Image.PreserveAspectCrop
14+ }
15+ }
16+
17+ Image {
18+ anchors.fill: parent
19+ visible: !shaped
20+ source: fileSource
21+ fillMode: Image.PreserveAspectCrop
22+ }
23+}
tests/qmltests/Notifications/tst_Notifications.qml+38
@@ -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"
@@ -295,6 +315,24 @@ Row {
295 secondaryIconVisible: true,
315 secondaryIconVisible: true,
296 buttonRowVisible: false,
316 buttonRowVisible: false,
297 buttonTinted: false
317 buttonTinted: false
318+ },
319+ {
320+ tag: "Ephemeral notification with non-shaped icon",
321+ type: Notification.Ephemeral,
322+ hints: {"x-canonical-private-button-tint": "false",
323+ "x-canonical-non-shaped-icon": "true"},
324+ summary: "Contacts",
325+ body: "Synchronised contacts-database with cloud-storage.",
326+ icon: "../graphics/applicationIcons/contacts-app.png",
327+ secondaryIcon: "",
328+ actions: [],
329+ summaryVisible: true,
330+ bodyVisible: true,
331+ interactiveAreaEnabled: false,
332+ iconVisible: true,
333+ secondaryIconVisible: false,
334+ buttonRowVisible: false,
335+ buttonTinted: false
298 }
336 }
299 ]
337 ]
300 }
338 }