on xenial help sign in
Completed support for non-shaped icon hint, added qmltest.
commit68f5dac904cfacba76715fcf31a362384ecb1579 authorMirco Müller <mirco.mueller@ubuntu.com> dateThu 31 Oct 2013, 13:58 (13 years ago) parentc5af873
3 files changed+67−20
Notifications/Notification.qml+6−20 Notifications/ShapedIcon.qml+23 tests/qmltests/Notifications/tst_Notifications.qml+38
Notifications/Notification.qml+6−20
@@ -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
@@ -101,29 +101,14 @@ UbuntuShape {
101101 right: parent.right
102102 }
103103
104− Image {
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 {
104+ ShapedIcon {
116105 id: icon
117106
118107 objectName: "icon"
119108 width: units.gu(6)
120109 height: units.gu(6)
121− visible: iconSource !== undefined && iconSource !== "" && notification.hints["x-canonical-noshape-icon"] !== "true"
122− image: Image {
123− id: avatarIcon
124−
125− fillMode: Image.PreserveAspectCrop
126− }
110+ shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
111+ visible: iconSource !== undefined && iconSource != ""
127112 }
128113
129114 Image {
@@ -140,7 +125,8 @@ UbuntuShape {
140125 id: labelColumn
141126 width: parent.width - x
142127
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
144130
145131 Label {
146132 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 {
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"
@@ -295,6 +315,24 @@ Row {
295315 secondaryIconVisible: true,
296316 buttonRowVisible: false,
297317 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
298336 }
299337 ]
300338 }