on xenial help sign in
Added the frontend-part of sound-hint support for notifications with updated QML-tests.
commite990826b762615d61c5e567b9e6237d265f68081 authorMirco Müller <mirco.mueller@ubuntu.com> dateMon 23 Jun 2014, 11:16 (12 years ago) parente82a90128cb8d8
2 files changed+42−12
qml/Notifications/Notification.qml+13 tests/qmltests/Notifications/tst_Notifications.qml+29−12
qml/Notifications/Notification.qml+13
@@ -15,6 +15,7 @@
1515 */
1616
1717import QtQuick 2.0
18+import QtMultimedia 5.0
1819import Ubuntu.Components 0.1
1920import Unity.Notifications 1.0
2021import QMenuModel 0.1
@@ -66,6 +67,18 @@ Item {
6667 return result;
6768 }
6869
70+ Audio {
71+ id: sound
72+ objectName: "sound"
73+ source: hints["suppress-sound"] != "" ? hints["sound-file"] : undefined
74+ }
75+
76+ onOpacityChanged: {
77+ if (opacity == 1.0 && hints["suppress-sound"] != "true" && sound.source) {
78+ sound.play();
79+ }
80+ }
81+
6982 Behavior on height {
7083 id: normalHeightBehavior
7184
tests/qmltests/Notifications/tst_Notifications.qml+29−12
@@ -21,6 +21,7 @@ import "../../../qml/Notifications"
2121import Ubuntu.Components 0.1
2222import Unity.Test 0.1
2323import Unity.Notifications 1.0
24+import QtMultimedia 5.0
2425
2526Row {
2627 id: rootRow
@@ -245,7 +246,8 @@ Row {
245246 nonShapedIcon: false,
246247 secondaryIconVisible: true,
247248 buttonRowVisible: true,
248− buttonTinted: true
249+ buttonTinted: true,
250+ hasSound: false
249251 },
250252 {
251253 tag: "Ephemeral notification - icon-summary layout",
@@ -263,12 +265,15 @@ Row {
263265 nonShapedIcon: false,
264266 secondaryIconVisible: true,
265267 buttonRowVisible: false,
266− buttonTinted: false
268+ buttonTinted: false,
269+ hasSound: false
267270 },
268271 {
269272 tag: "Ephemeral notification - check suppression of secondary icon for icon-summary layout",
270273 type: Notification.Ephemeral,
271− hints: {"x-canonical-private-button-tint": "false"},
274+ hints: {"x-canonical-private-button-tint": "false",
275+ "sound-file": "dummy.ogg",
276+ "suppress-sound": "true"},
272277 summary: "New comment successfully published",
273278 body: "",
274279 icon: "",
@@ -282,12 +287,14 @@ Row {
282287 nonShapedIcon: false,
283288 secondaryIconVisible: true,
284289 buttonRowVisible: false,
285− buttonTinted: false
290+ buttonTinted: false,
291+ hasSound: false
286292 },
287293 {
288294 tag: "Interactive notification",
289295 type: Notification.Interactive,
290− hints: {"x-canonical-private-button-tint": "false"},
296+ hints: {"x-canonical-private-button-tint": "false",
297+ "sound-file": "dummy.ogg"},
291298 summary: "Interactive notification",
292299 body: "This is a notification that can be clicked",
293300 icon: "../graphics/avatars/amanda.png",
@@ -300,12 +307,14 @@ Row {
300307 nonShapedIcon: false,
301308 secondaryIconVisible: false,
302309 buttonRowVisible: false,
303− buttonTinted: false
310+ buttonTinted: false,
311+ hasSound: true
304312 },
305313 {
306314 tag: "Snap Decision without secondary icon and no button-tint",
307315 type: Notification.SnapDecision,
308− hints: {"x-canonical-private-button-tint": "false"},
316+ hints: {"x-canonical-private-button-tint": "false",
317+ "sound-file": "dummy.ogg"},
309318 summary: "Bro Coly",
310319 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.",
311320 icon: "../graphics/avatars/anna_olsson.png",
@@ -319,12 +328,14 @@ Row {
319328 nonShapedIcon: false,
320329 secondaryIconVisible: false,
321330 buttonRowVisible: true,
322− buttonTinted: false
331+ buttonTinted: false,
332+ hasSound: true
323333 },
324334 {
325335 tag: "Ephemeral notification",
326336 type: Notification.Ephemeral,
327− hints: {"x-canonical-private-button-tint": "false"},
337+ hints: {"x-canonical-private-button-tint": "false",
338+ "sound-file": "dummy.ogg"},
328339 summary: "Cole Raby",
329340 body: "I did not expect it to be that late.",
330341 icon: "../graphics/avatars/funky.png",
@@ -337,13 +348,15 @@ Row {
337348 nonShapedIcon: false,
338349 secondaryIconVisible: true,
339350 buttonRowVisible: false,
340− buttonTinted: false
351+ buttonTinted: false,
352+ hasSound: true
341353 },
342354 {
343355 tag: "Ephemeral notification with non-shaped icon",
344356 type: Notification.Ephemeral,
345357 hints: {"x-canonical-private-button-tint": "false",
346− "x-canonical-non-shaped-icon": "true"},
358+ "x-canonical-non-shaped-icon": "true",
359+ "sound-file": "dummy.ogg"},
347360 summary: "Contacts",
348361 body: "Synchronised contacts-database with cloud-storage.",
349362 icon: "../graphics/applicationIcons/contacts-app.png",
@@ -356,7 +369,8 @@ Row {
356369 nonShapedIcon: true,
357370 secondaryIconVisible: false,
358371 buttonRowVisible: false,
359− buttonTinted: false
372+ buttonTinted: false,
373+ hasSound: true
360374 }
361375 ]
362376 }
@@ -419,6 +433,9 @@ Row {
419433 compare(bodyLabel.visible, data.bodyVisible, "body-text visibility is incorrect")
420434 compare(buttonRow.visible, data.buttonRowVisible, "button visibility is incorrect")
421435
436+ var audioItem = findInvisibleChild(notification, "sound")
437+ tryCompare(audioItem, "playbackState", data.hasSound ? Audio.PlayingState : Audio.StoppedState)
438+
422439 if(data.buttonRowVisible) {
423440 var buttonCancel = findChild(buttonRow, "button1")
424441 var buttonAccept = findChild(buttonRow, "button0")