@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -17,11 +17,11 @@
1717import QtQuick 2.0
1818import QtMultimedia 5.0
1919import Powerd 0.1
20−import Ubuntu.Components 1.1
20+import Ubuntu.Components 1.2
2121import Unity.Notifications 1.0
2222import QMenuModel 0.1
2323import Utils 0.1
24−
24+import "../Components/UnityInputInfo"
2525import Ubuntu.Components.ListItems 0.1 as ListItem
2626
2727Item {
@@ -49,6 +49,8 @@ Item {
4949 readonly property color sdDarkGrey: "#dddddd"
5050 readonly property color sdFontColor: "#5d5d5d"
5151 readonly property real contentSpacing: units.gu(2)
52+ readonly property bool canBeClosed: type === Notification.Ephemeral
53+ property bool clickToClose
5254
5355 objectName: "background"
5456 implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height - shapedBack.anchors.topMargin + contentSpacing * 2) : 0
@@ -59,12 +61,12 @@ Item {
5961 state: {
6062 var result = "";
6163
62− if (type == Notification.SnapDecision) {
63− if (ListView.view.currentIndex == index) {
64+ if (type === Notification.SnapDecision) {
65+ if (ListView.view.currentIndex === index) {
6466 result = "expanded";
6567 } else {
6668 if (ListView.view.count > 2) {
67− if (ListView.view.currentIndex == -1 && index == 1) {
69+ if (ListView.view.currentIndex === -1 && index == 1) {
6870 result = "expanded";
6971 } else {
7072 result = "contracted";
@@ -82,7 +84,7 @@ Item {
8284 id: sound
8385 objectName: "sound"
8486 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"] : ""
8688 }
8789
8890 Component.onCompleted: {
@@ -139,7 +141,7 @@ Item {
139141
140142 clip: fullscreen ? false : true
141143
142− visible: type != Notification.PlaceHolder
144+ visible: type !== Notification.PlaceHolder
143145
144146 UbuntuShape {
145147 id: shapedBack
@@ -195,7 +197,7 @@ Item {
195197 actions: paths.actions
196198 menuObjectPath: paths.menuObjectPath
197199 onNameOwnerChanged: {
198− if (lastNameOwner !== "" && nameOwner === "" && notification.notification !== undefined) {
200+ if (lastNameOwner !== "" && nameOwner === "" && !!notification.notification) {
199201 notification.notification.close()
200202 }
201203 lastNameOwner = nameOwner
@@ -214,8 +216,10 @@ Item {
214216 drag.maximumX: notification.width
215217
216218 onClicked: {
217− if (notification.type == Notification.Interactive) {
219+ if (notification.type === Notification.Interactive) {
218220 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
221+ } else if (clickToClose && canBeClosed) {
222+ notification.notification.close()
219223 } else {
220224 notificationList.currentIndex = index;
221225 }
@@ -256,10 +260,10 @@ Item {
256260 id: icon
257261
258262 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)
260264 height: width
261− shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
262− visible: iconSource !== undefined && iconSource !== "" && type !== Notification.Confirmation
265+ shaped: notification.hints["x-canonical-non-shaped-icon"] === "true" ? false : true
266+ visible: !!iconSource && iconSource !== "" && type !== Notification.Confirmation
263267 }
264268
265269 Column {
@@ -280,7 +284,7 @@ Item {
280284 fontSize: "medium"
281285 color: darkOnBright ? sdFontColor : Theme.palette.selected.backgroundText
282286 elide: Text.ElideRight
283− textFormat: Text.PlainText
287+ textFormat: Text.StyledText
284288 }
285289
286290 Label {
@@ -295,9 +299,9 @@ Item {
295299 fontSize: "small"
296300 color: darkOnBright ? sdFontColor : Theme.palette.selected.backgroundText
297301 wrapMode: Text.WordWrap
298− maximumLineCount: type == Notification.SnapDecision ? 12 : 2
302+ maximumLineCount: type === Notification.SnapDecision ? 12 : 2
299303 elide: Text.ElideRight
300− textFormat: Text.PlainText
304+ textFormat: Text.StyledText
301305 }
302306 }
303307
@@ -313,7 +317,7 @@ Item {
313317 }
314318
315319 ListItem.ThinDivider {
316− visible: type == Notification.SnapDecision
320+ visible: type === Notification.SnapDecision
317321 }
318322
319323 ShapedIcon {
@@ -321,9 +325,9 @@ Item {
321325 objectName: "centeredIcon"
322326 width: units.gu(5)
323327 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
325329 fileSource: icon.fileSource
326− visible: fileSource !== undefined && fileSource !== "" && type === Notification.Confirmation
330+ visible: !!fileSource && fileSource !== "" && type === Notification.Confirmation
327331 anchors.horizontalCenter: parent.horizontalCenter
328332 }
329333
@@ -439,7 +443,7 @@ Item {
439443 objectName: "notify_oot_button" + index
440444 width: oneOverTwoCase.width
441445 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
443447 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
444448 }
445449 }
@@ -467,11 +471,11 @@ Item {
467471 objectName: "notify_oot_button" + index
468472 width: oneOverTwoCase.width / 2 - spacing * 2
469473 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
471475 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
472476 }
473477 }
474− sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
478+ sourceComponent: (index == 1 || index == 2) ? oneOverTwoButtonBottom : undefined
475479 }
476480 }
477481 }
@@ -499,6 +503,7 @@ Item {
499503 width: buttonRow.width
500504 leftIconName: "call-end"
501505 rightIconName: "call-start"
506+ clickToAct: notification.clickToClose
502507 onRightTriggered: {
503508 notification.notification.invokeAction(notification.actions.data(0, ActionModel.RoleActionId))
504509 }
@@ -528,10 +533,10 @@ Item {
528533 text: loader.actionLabel
529534 color: {
530535 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") {
532537 result = green;
533538 }
534− if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true") {
539+ if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true") {
535540 result = red;
536541 }
537542 return result;
@@ -554,7 +559,7 @@ Item {
554559 margins: contentSpacing
555560 }
556561
557− visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
562+ visible: notification.type === Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
558563 model: notification.actions
559564 expanded: false
560565 startIndex: 2