@@ -1,5 +1,5 @@
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -17,11 +17,11 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtMultimedia 5.0
18import QtMultimedia 5.0
19import Powerd 0.1
19import Powerd 0.1
20−import Ubuntu.Components 1.1
20+import Ubuntu.Components 1.2
21import Unity.Notifications 1.0
21import Unity.Notifications 1.0
22import QMenuModel 0.1
22import QMenuModel 0.1
23import Utils 0.1
23import Utils 0.1
24−
24+import "../Components/UnityInputInfo"
25import Ubuntu.Components.ListItems 0.1 as ListItem
25import Ubuntu.Components.ListItems 0.1 as ListItem
@@ -49,6 +49,8 @@ Item {
49 readonly property color sdDarkGrey: "#dddddd"
49 readonly property color sdDarkGrey: "#dddddd"
50 readonly property color sdFontColor: "#5d5d5d"
50 readonly property color sdFontColor: "#5d5d5d"
51 readonly property real contentSpacing: units.gu(2)
51 readonly property real contentSpacing: units.gu(2)
52+ readonly property bool canBeClosed: type === Notification.Ephemeral
53+ property bool clickToClose
53 objectName: "background"
55 objectName: "background"
54 implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height - shapedBack.anchors.topMargin + contentSpacing * 2) : 0
56 implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height - shapedBack.anchors.topMargin + contentSpacing * 2) : 0
@@ -59,12 +61,12 @@ Item {
60 var result = "";
62 var result = "";
62− if (type == Notification.SnapDecision) {
64+ if (type === Notification.SnapDecision) {
63− if (ListView.view.currentIndex == index) {
65+ if (ListView.view.currentIndex === index) {
64 result = "expanded";
66 result = "expanded";
66 if (ListView.view.count > 2) {
68 if (ListView.view.count > 2) {
67− if (ListView.view.currentIndex == -1 && index == 1) {
69+ if (ListView.view.currentIndex === -1 && index == 1) {
68 result = "expanded";
70 result = "expanded";
70 result = "contracted";
72 result = "contracted";
@@ -82,7 +84,7 @@ Item {
83 objectName: "sound"
85 objectName: "sound"
84 audioRole: MediaPlayer.alert
86 audioRole: MediaPlayer.alert
85− source: hints["suppress-sound"] !== "true" && hints["sound-file"] !== undefined ? hints["sound-file"] : ""
87+ source: hints["suppress-sound"] !== "true" && !!hints["sound-file"] ? hints["sound-file"] : ""
88 Component.onCompleted: {
90 Component.onCompleted: {
@@ -139,7 +141,7 @@ Item {
140 clip: fullscreen ? false : true
142 clip: fullscreen ? false : true
142− visible: type != Notification.PlaceHolder
144+ visible: type !== Notification.PlaceHolder
144 UbuntuShape {
146 UbuntuShape {
145 id: shapedBack
147 id: shapedBack
@@ -195,7 +197,7 @@ Item {
195 actions: paths.actions
197 actions: paths.actions
196 menuObjectPath: paths.menuObjectPath
198 menuObjectPath: paths.menuObjectPath
197 onNameOwnerChanged: {
199 onNameOwnerChanged: {
198− if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) {
200+ if (lastNameOwner !== "" && nameOwner === "" && !!notification.notification) {
199 notification.notification.close()
201 notification.notification.close()
201 lastNameOwner = nameOwner
203 lastNameOwner = nameOwner
@@ -214,8 +216,10 @@ Item {
214 drag.maximumX: notification.width
216 drag.maximumX: notification.width
216 onClicked: {
218 onClicked: {
217− if (notification.type == Notification.Interactive) {
219+ if (notification.type === Notification.Interactive) {
218 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
220 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
221+ } else if (clickToClose && canBeClosed) {
222+ notification.notification.close()
220 notificationList.currentIndex = index;
224 notificationList.currentIndex = index;
@@ -256,10 +260,10 @@ Item {
258 objectName: "icon"
262 objectName: "icon"
259− width: type == Notification.Ephemeral && !bodyLabel.visible ? units.gu(3) : units.gu(6)
263+ width: type === Notification.Ephemeral && !bodyLabel.visible ? units.gu(3) : units.gu(6)
260 height: width
264 height: width
261− shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
265+ shaped: notification.hints["x-canonical-non-shaped-icon"] === "true" ? false : true
262− visible: iconSource !== undefined && iconSource !== "" && type !== Notification.Confirmation
266+ visible: !!iconSource && iconSource !== "" && type !== Notification.Confirmation
@@ -280,7 +284,7 @@ Item {
280 fontSize: "medium"
284 fontSize: "medium"
281 color: darkOnBright ? sdFontColor : Theme.palette.selected.backgroundText
285 color: darkOnBright ? sdFontColor : Theme.palette.selected.backgroundText
282 elide: Text.ElideRight
286 elide: Text.ElideRight
283− textFormat: Text.PlainText
287+ textFormat: Text.StyledText
@@ -295,9 +299,9 @@ Item {
295 fontSize: "small"
299 fontSize: "small"
296 color: darkOnBright ? sdFontColor : Theme.palette.selected.backgroundText
300 color: darkOnBright ? sdFontColor : Theme.palette.selected.backgroundText
297 wrapMode: Text.WordWrap
301 wrapMode: Text.WordWrap
298− maximumLineCount: type == Notification.SnapDecision ? 12 : 2
302+ maximumLineCount: type === Notification.SnapDecision ? 12 : 2
299 elide: Text.ElideRight
303 elide: Text.ElideRight
300− textFormat: Text.PlainText
304+ textFormat: Text.StyledText
@@ -313,7 +317,7 @@ Item {
315 ListItem.ThinDivider {
319 ListItem.ThinDivider {
316− visible: type == Notification.SnapDecision
320+ visible: type === Notification.SnapDecision
319 ShapedIcon {
323 ShapedIcon {
@@ -321,9 +325,9 @@ Item {
321 objectName: "centeredIcon"
325 objectName: "centeredIcon"
322 width: units.gu(5)
326 width: units.gu(5)
323 height: width
327 height: width
324− shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
328+ shaped: notification.hints["x-canonical-non-shaped-icon"] === "true" ? false : true
325 fileSource: icon.fileSource
329 fileSource: icon.fileSource
326− visible: fileSource !== undefined && fileSource !== "" && type === Notification.Confirmation
330+ visible: !!fileSource && fileSource !== "" && type === Notification.Confirmation
327 anchors.horizontalCenter: parent.horizontalCenter
331 anchors.horizontalCenter: parent.horizontalCenter
@@ -439,7 +443,7 @@ Item {
439 objectName: "notify_oot_button" + index
443 objectName: "notify_oot_button" + index
440 width: oneOverTwoCase.width
444 width: oneOverTwoCase.width
441 text: oneOverTwoLoaderTop.actionLabel
445 text: oneOverTwoLoaderTop.actionLabel
442− color: notification.hints["x-canonical-private-affirmative-tint"] == "true" ? green : sdDarkGrey
446+ color: notification.hints["x-canonical-private-affirmative-tint"] === "true" ? green : sdDarkGrey
443 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
447 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
@@ -467,11 +471,11 @@ Item {
467 objectName: "notify_oot_button" + index
471 objectName: "notify_oot_button" + index
468 width: oneOverTwoCase.width / 2 - spacing * 2
472 width: oneOverTwoCase.width / 2 - spacing * 2
469 text: oneOverTwoLoaderBottom.actionLabel
473 text: oneOverTwoLoaderBottom.actionLabel
470− color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true" ? red : sdDarkGrey
474+ color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true" ? red : sdDarkGrey
471 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
475 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
474− sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
478+ sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
@@ -499,6 +503,7 @@ Item {
499 width: buttonRow.width
503 width: buttonRow.width
500 leftIconName: "call-end"
504 leftIconName: "call-end"
501 rightIconName: "call-start"
505 rightIconName: "call-start"
506+ clickToAct: notification.clickToClose
502 onRightTriggered: {
507 onRightTriggered: {
503 notification.notification.invokeAction(notification.actions.data(0, ActionModel.RoleActionId))
508 notification.notification.invokeAction(notification.actions.data(0, ActionModel.RoleActionId))
@@ -528,10 +533,10 @@ Item {
528 text: loader.actionLabel
533 text: loader.actionLabel
530 var result = sdDarkGrey;
535 var result = sdDarkGrey;
531− if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] == "true") {
536+ if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] === "true") {
532 result = green;
537 result = green;
534− if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true") {
539+ if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true") {
535 result = red;
540 result = red;
537 return result;
542 return result;
@@ -554,7 +559,7 @@ Item {
554 margins: contentSpacing
559 margins: contentSpacing
557− visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
562+ visible: notification.type === Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
558 model: notification.actions
563 model: notification.actions
559 expanded: false
564 expanded: false
560 startIndex: 2
565 startIndex: 2