on xenial help sign in
Integrate notifications.

This is the shell-part of the notification integration (frontend+backend) enabling full notification support using the new Qt/QML-based implementation. Approved by PS Jenkins bot, Michael Zanetti, Michał Sawicz.

commita467fa83f27db2c16cc48cac9670c3632b2697d7 authorMirco Müller <mirco.mueller@canonical.com> dateWed 19 Jun 2013, 18:10 (13 years ago) parent32fd687287e74f
8 files changed+86−22
Notifications/Notification.qml+10−7 Notifications/Notifications.qml+4−2 Shell.qml+14 debian/control+2 tests/qmltests/CMakeLists.txt+1−1 tests/qmltests/Notifications/tst_Notifications.qml+30−12 tests/qmltests/plugins/Unity/Notifications/notification.js+23 tests/qmltests/plugins/Unity/Notifications/qmldir+2
Notifications/Notification.qml+10−7
@@ -16,18 +16,19 @@
1616
1717import QtQuick 2.0
1818import Ubuntu.Components 0.1
19+import Unity.Notifications 1.0
1920
2021UbuntuShape {
2122 id: notification
2223
23− property string type
2424 property alias iconSource: avatarIcon.source
2525 property alias secondaryIconSource: secondaryIcon.source
2626 property alias summary: summaryLabel.text
2727 property alias body: bodyLabel.text
2828 property var actions
29−
30− signal actionInvoked(string buttonId)
29+ property var notificationId
30+ property var type
31+ property var notification
3132
3233 implicitHeight: childrenRect.height
3334 color: Qt.rgba(0, 0, 0, 0.85)
@@ -38,8 +39,8 @@ UbuntuShape {
3839
3940 anchors.fill: contentColumn
4041 objectName: "interactiveArea"
41− enabled: notification.type == "Notifications.Type.Interactive"
42− onClicked: notification.actionInvoked(actions.get(0).id)
42+ enabled: notification.type == Notification.Interactive
43+ onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
4344 }
4445
4546 Column {
@@ -130,13 +131,14 @@ UbuntuShape {
130131 objectName: "buttonRow"
131132 spacing: contentColumn.spacing
132133 layoutDirection: Qt.RightToLeft
133− visible: notification.type == "Notifications.Type.SnapDecision"
134+ visible: notification.type == Notification.SnapDecision
134135 anchors {
135136 left: parent.left
136137 right: parent.right
137138 }
138139
139140 Repeater {
141+ id: actionRepeater
140142 model: notification.actions
141143
142144 Button {
@@ -145,7 +147,8 @@ UbuntuShape {
145147 width: (buttonRow.width - buttonRow.spacing) / 2
146148 height: units.gu(4)
147149 text: label
148− onClicked: notification.actionInvoked(id)
150+ property string actionId: id
151+ onClicked: notification.notification.invokeAction(id)
149152 }
150153 }
151154 }
Notifications/Notifications.qml+4−2
@@ -20,9 +20,9 @@ import "../Components"
2020import "timings.js" as Timings
2121
2222ListView {
23− id: notificationRenderer
23+ id: notificationList
2424
25− objectName: "notificationRenderer"
25+ objectName: "notificationList"
2626 interactive: false
2727
2828 spacing: units.gu(.5)
@@ -38,6 +38,8 @@ ListView {
3838 summary: model.summary
3939 body: model.body
4040 actions: model.actions
41+ notificationId: model.id
42+ notification: notificationList.model.getRaw(notificationId)
4143 }
4244
4345 populate: Transition {
Shell.qml+14
@@ -27,6 +27,8 @@ import "Components"
2727import "Components/Math.js" as MathLocal
2828import "Bottombar"
2929import "SideStage"
30+import "Notifications"
31+import Unity.Notifications 1.0 as NotificationBackend
3032
3133FocusScope {
3234 id: shell
@@ -170,6 +172,18 @@ FocusScope {
170172 // greeterRevealer.animatedProgress are not animated
171173 Behavior on disappearingAnimationProgress { SmoothedAnimation { velocity: 5 }}
172174 }
175+
176+ Notifications {
177+ id: notifications
178+
179+ model: NotificationBackend.Model
180+ anchors {
181+ fill: parent
182+ leftMargin: units.gu(1)
183+ rightMargin: units.gu(1)
184+ topMargin: panel.panelHeight + units.gu(1)
185+ }
186+ }
173187 }
174188
175189
debian/control+2
@@ -40,6 +40,8 @@ Architecture: amd64 armhf i386
4040Depends: indicators-client (>= 0.6.1),
4141 qtdeclarative5-dee-plugin,
4242 qtdeclarative5-ubuntu-ui-toolkit-plugin,
43+ qtdeclarative5-unity-notifications-plugin | unity-notifications-impl,
44+ unity-notifications-impl-1,
4345 qtdeclarative5-xmllistmodel-plugin,
4446 qtubuntu,
4547 ${misc:Depends},
tests/qmltests/CMakeLists.txt+1−1
@@ -59,7 +59,7 @@ add_qml_test(Greeter Infographics IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} $
5959add_qml_test(Hud Hud)
6060add_qml_test(Hud Result)
6161add_qml_test(Launcher Launcher IMPORT_PATHS ${CMAKE_BINARY_DIR}/plugins ${qmltest_DEFAULT_IMPORT_PATHS})
62−add_qml_test(Notifications Notifications)
62+add_qml_test(Notifications Notifications IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_CURRENT_SOURCE_DIR}/plugins)
6363add_qml_test(Panel IndicatorRow)
6464add_qml_test(Panel Indicators)
6565add_qml_test(Panel MenuContent)
tests/qmltests/Notifications/tst_Notifications.qml+30−12
@@ -20,17 +20,34 @@ import ".."
2020import "../../../Notifications"
2121import Ubuntu.Components 0.1
2222import Unity.Test 0.1
23+import Unity.Notifications 1.0
2324
2425Row {
2526 id: rootRow
2627
28+ Component {
29+ id: mockNotification
30+
31+ QtObject {
32+ function invokeAction(actionId) {
33+ mockModel.actionInvoked(actionId)
34+ }
35+ }
36+ }
37+
2738 ListModel {
2839 id: mockModel
40+
41+ signal actionInvoked(string actionId)
42+
43+ function getRaw(id) {
44+ return mockNotification.createObject(mockModel)
45+ }
2946 }
3047
3148 function addSnapDecisionNotification() {
3249 var n = {
33− type: "Notifications.Type.SnapDecision",
50+ type: Notification.SnapDecision,
3451 summary: "Tom Ato",
3552 body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
3653 icon: "../graphics/avatars/funky.png",
@@ -44,7 +61,7 @@ Row {
4461
4562 function addEphemeralNotification() {
4663 var n = {
47− type: "Notifications.Type.Ephemeral",
64+ type: Notification.Ephemeral,
4865 summary: "Cole Raby",
4966 body: "I did not expect it to be that late.",
5067 icon: "../graphics/avatars/amanda.png",
@@ -57,7 +74,7 @@ Row {
5774
5875 function addEphemeralIconSummaryNotification() {
5976 var n = {
60− type: "Notifications.Type.Ephemeral",
77+ type: Notification.Ephemeral,
6178 summary: "Photo upload completed",
6279 body: "",
6380 icon: "",
@@ -70,7 +87,7 @@ Row {
7087
7188 function addInteractiveNotification() {
7289 var n = {
73− type: "Notifications.Type.Interactive",
90+ type: Notification.Interactive,
7491 summary: "Interactive notification",
7592 body: "This is a notification that can be clicked",
7693 icon: "../graphics/avatars/anna_olsson.png",
@@ -170,7 +187,7 @@ Row {
170187 return [
171188 {
172189 tag: "Snap Decision with secondary icon",
173− type: "Notifications.Type.SnapDecision",
190+ type: Notification.SnapDecision,
174191 summary: "Tom Ato",
175192 body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
176193 icon: "../graphics/avatars/funky.png",
@@ -186,7 +203,7 @@ Row {
186203 },
187204 {
188205 tag: "Ephemeral notification - icon-summary layout",
189− type: "Notifications.Type.Ephemeral",
206+ type: Notification.Ephemeral,
190207 summary: "Photo upload completed",
191208 body: "",
192209 icon: "",
@@ -201,7 +218,7 @@ Row {
201218 },
202219 {
203220 tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout",
204− type: "Notifications.Type.Ephemeral",
221+ type: Notification.Ephemeral,
205222 summary: "New comment successfully published",
206223 body: "",
207224 icon: "",
@@ -216,7 +233,7 @@ Row {
216233 },
217234 {
218235 tag: "Interactive notification",
219− type: "Notifications.Type.Interactive",
236+ type: Notification.Interactive,
220237 summary: "Interactive notification",
221238 body: "This is a notification that can be clicked",
222239 icon: "../graphics/avatars/amanda.png",
@@ -231,7 +248,7 @@ Row {
231248 },
232249 {
233250 tag: "Snap Decision without secondary icon",
234− type: "Notifications.Type.SnapDecision",
251+ type: Notification.SnapDecision,
235252 summary: "Bro Coly",
236253 body: "At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.",
237254 icon: "../graphics/avatars/anna_olsson.png",
@@ -247,7 +264,7 @@ Row {
247264 },
248265 {
249266 tag: "Ephemeral notification",
250− type: "Notifications.Type.Ephemeral",
267+ type: Notification.Ephemeral,
251268 summary: "Cole Raby",
252269 body: "I did not expect it to be that late.",
253270 icon: "../graphics/avatars/funky.png",
@@ -272,6 +289,8 @@ Row {
272289
273290 SignalSpy {
274291 id: actionSpy
292+
293+ target: mockModel
275294 signalName: "actionInvoked"
276295 }
277296
@@ -303,7 +322,6 @@ Row {
303322 compare(interactiveArea.enabled, data.interactiveAreaEnabled, "check for interactive area")
304323
305324 if(data.interactiveAreaEnabled) {
306− actionSpy.target = notification
307325 mouseClick(notification, notification.width / 2, notification.height / 2)
308326 actionSpy.wait()
309327 compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id for interactive action")
@@ -323,7 +341,6 @@ Row {
323341 var buttonAccept = findChild(buttonRow, "button0")
324342
325343 waitForRendering(notification)
326− actionSpy.target = notification
327344 mouseClick(buttonCancel, buttonCancel.width / 2, buttonCancel.height / 2)
328345 actionSpy.wait()
329346 compare(actionSpy.signalArguments[0][0], data.actions[1]["id"], "got wrong id for negative action")
@@ -332,6 +349,7 @@ Row {
332349 mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2)
333350 actionSpy.wait()
334351 compare(actionSpy.signalArguments[0][0], data.actions[0]["id"], "got wrong id positive action")
352+ actionSpy.clear()
335353 }
336354 }
337355 }
tests/qmltests/plugins/Unity/Notifications/notification.jsnew file+23
@@ -0,0 +1,23 @@
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+.pragma library
18+
19+var Confirmation = 0;
20+var Ephemeral = 1;
21+var Interactive = 2;
22+var SnapDecision = 3;
23+var PlaceHolder = 4;
tests/qmltests/plugins/Unity/Notifications/qmldirnew file+2
@@ -0,0 +1,2 @@
1+module Unity.Notifications
2+Notification 1.0 notification.js