@@ -1,5 +1,5 @@
2− * Copyright (C) 2013, 2015 Canonical, Ltd.
2+ * Copyright (C) 2013-2016 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
@@ -36,38 +36,37 @@ StyledItem {
36 property var type
36 property var type
37 property var hints
37 property var hints
38 property var notification
38 property var notification
39− property color color
39+ property color color: UbuntuColors.silk // TODO theme.palette.normal.overlay
40 property bool fullscreen: false
40 property bool fullscreen: false
41 property int maxHeight
41 property int maxHeight
42− property int margins
42+ property int margins: units.gu(1)
43− readonly property bool draggable: (type === Notification.SnapDecision && state === "contracted") || type === Notification.Interactive || type === Notification.Ephemeral
43+ readonly property bool draggable: (type === Notification.SnapDecision && state === "contracted") ||
44− readonly property bool darkOnBright: inverseMode || type === Notification.SnapDecision
44+ type === Notification.Interactive ||
45− readonly property color sdLightGrey: "#eaeaea"
45+ type === Notification.Ephemeral
46− readonly property real contentSpacing: units.gu(2)
47 readonly property bool canBeClosed: type === Notification.Ephemeral
46 readonly property bool canBeClosed: type === Notification.Ephemeral
47+ readonly property real defaultOpacity: 0.95
48 property bool hasMouse
48 property bool hasMouse
49− property bool inverseMode
50 property url background: ""
49 property url background: ""
52 objectName: "background"
51 objectName: "background"
53− implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height - shapedBack.anchors.topMargin + contentSpacing * 2) : 0
52+ implicitHeight: type !== Notification.PlaceHolder ? (fullscreen ? maxHeight : outterColumn.height + margins * 2) : 0
55− color: (type === Notification.Confirmation && notificationList.useModal && !greeter.shown) || darkOnBright ? sdLightGrey : Qt.rgba(0.132, 0.117, 0.109, 0.97)
56− opacity: 1 - (x / notification.width) // FIXME: non-zero initially because of LP: #1354406 workaround, we want this to start at 0 upon creation eventually
54+ // FIXME: non-zero initially because of LP: #1354406 workaround, we want this to start at 0 upon creation eventually
55+ opacity: defaultOpacity - Math.abs(x / notification.width)
58 theme: ThemeSettings {
57 theme: ThemeSettings {
59− name: darkOnBright ? "Ubuntu.Components.Themes.Ambiance" : "Ubuntu.Components.Themes.SuruDark"
58+ name: "Ubuntu.Components.Themes.Ambiance"
63 var result = "";
62 var result = "";
65− if (type == Notification.SnapDecision) {
64+ if (type === Notification.SnapDecision) {
66− if (ListView.view.currentIndex == index) {
65+ if (ListView.view.currentIndex === index) {
67 result = "expanded";
66 result = "expanded";
69 if (ListView.view.count > 2) {
68 if (ListView.view.count > 2) {
70− if (ListView.view.currentIndex == -1 && index == 1) {
69+ if (ListView.view.currentIndex === -1 && index == 1) {
71 result = "expanded";
70 result = "expanded";
73 result = "contracted";
72 result = "contracted";
@@ -90,39 +89,30 @@ StyledItem {
90 Component.onCompleted: {
89 Component.onCompleted: {
91 // Turn on screen as needed (Powerd.Notification means the screen
90 // Turn on screen as needed (Powerd.Notification means the screen
92 // stays on for a shorter amount of time)
91 // stays on for a shorter amount of time)
93− if (type == Notification.SnapDecision) {
92+ if (type === Notification.SnapDecision) {
94 Powerd.setStatus(Powerd.On, Powerd.SnapDecision);
93 Powerd.setStatus(Powerd.On, Powerd.SnapDecision);
95− } else if (type != Notification.Confirmation) {
94+ } else if (type !== Notification.Confirmation) {
96 Powerd.setStatus(Powerd.On, Powerd.Notification);
95 Powerd.setStatus(Powerd.On, Powerd.Notification);
99 // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
98 // FIXME: using onCompleted because of LP: #1354406 workaround, has to be onOpacityChanged really
100− if (opacity == 1.0 && hints["suppress-sound"] !== "true" && sound.source !== "") {
99+ if (opacity == defaultOpacity && hints["suppress-sound"] !== "true" && sound.source !== "") {
101 sound.play();
100 sound.play();
105 Behavior on x {
104 Behavior on x {
108 enabled: draggable
105 enabled: draggable
109− UbuntuNumberAnimation {
110− duration: UbuntuAnimation.FastDuration
111− easing.type: Easing.OutBounce
106+ UbuntuNumberAnimation { easing.type: Easing.OutBounce }
115 onHintsChanged: {
109 onHintsChanged: {
116− if (type === Notification.Confirmation && opacity == 1.0 && hints["suppress-sound"] !== "true" && sound.source !== "") {
110+ if (type === Notification.Confirmation && opacity == defaultOpacity && hints["suppress-sound"] !== "true" && sound.source !== "") {
117 sound.play();
111 sound.play();
121 Behavior on height {
115 Behavior on height {
122− id: normalHeightBehavior
124− //enabled: menuItemFactory.progress == 1
126 UbuntuNumberAnimation {
116 UbuntuNumberAnimation {
127 duration: UbuntuAnimation.SnapDuration
117 duration: UbuntuAnimation.SnapDuration
@@ -131,7 +121,7 @@ StyledItem {
133 name: "contracted"
123 name: "contracted"
134− PropertyChanges {target: notification; height: units.gu(10)}
124+ PropertyChanges {target: notification; height: topRow.childrenRect.height + notification.margins * 2}
137 name: "expanded"
127 name: "expanded"
@@ -141,7 +131,7 @@ StyledItem {
142 clip: fullscreen ? false : true
132 clip: fullscreen ? false : true
144− visible: type != Notification.PlaceHolder
134+ visible: type !== Notification.PlaceHolder
146 UbuntuShape {
136 UbuntuShape {
147 id: shapedBack
137 id: shapedBack
@@ -149,9 +139,6 @@ StyledItem {
149 visible: !fullscreen
139 visible: !fullscreen
150 anchors {
140 anchors {
151 fill: parent
141 fill: parent
152− leftMargin: notification.margins
153− rightMargin: notification.margins
154− topMargin: type === Notification.Confirmation ? units.gu(.5) : 0
156 backgroundColor: parent.color
143 backgroundColor: parent.color
157 opacity: parent.opacity
144 opacity: parent.opacity
@@ -169,7 +156,7 @@ StyledItem {
171 onXChanged: {
158 onXChanged: {
172− if (draggable && notification.x > 0.75 * notification.width) {
159+ if (draggable && Math.abs(notification.x) > 0.75 * notification.width) {
173 notification.notification.close()
160 notification.notification.close()
@@ -212,11 +199,11 @@ StyledItem {
213 drag.target: draggable ? notification : undefined
200 drag.target: draggable ? notification : undefined
214 drag.axis: Drag.XAxis
201 drag.axis: Drag.XAxis
215− drag.minimumX: 0
202+ drag.minimumX: -notification.width
216 drag.maximumX: notification.width
203 drag.maximumX: notification.width
218 onClicked: {
205 onClicked: {
219− if (notification.type == Notification.Interactive) {
206+ if (notification.type === Notification.Interactive) {
220 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
207 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
221 } else if (hasMouse && canBeClosed) {
208 } else if (hasMouse && canBeClosed) {
222 notification.notification.close()
209 notification.notification.close()
@@ -225,7 +212,7 @@ StyledItem {
227 onReleased: {
214 onReleased: {
228− if (notification.x < notification.width / 2) {
215+ if (Math.abs(notification.x) < notification.width / 2) {
229 notification.x = 0
216 notification.x = 0
231 notification.x = notification.width
218 notification.x = notification.width
@@ -240,30 +227,28 @@ StyledItem {
240 left: parent.left
227 left: parent.left
241 right: parent.right
228 right: parent.right
242 top: parent.top
229 top: parent.top
243− margins: 0
230+ margins: notification.margins
244− topMargin: fullscreen ? 0 : type === Notification.Confirmation ? units.gu(1) : units.gu(2)
247− spacing: type === Notification.Confirmation ? units.gu(1) : units.gu(2)
233+ spacing: notification.margins
250 id: topRow
236 id: topRow
252− spacing: contentSpacing
238+ spacing: notification.margins
253 anchors {
239 anchors {
254 left: parent.left
240 left: parent.left
255 right: parent.right
241 right: parent.right
256− margins: contentSpacing
259 ShapedIcon {
244 ShapedIcon {
262 objectName: "icon"
247 objectName: "icon"
263− width: type == Notification.Ephemeral && !bodyLabel.visible ? units.gu(3) : units.gu(6)
248+ width: units.gu(6)
264 height: width
249 height: width
265− shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
250+ shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
266− visible: iconSource !== undefined && iconSource !== "" && type !== Notification.Confirmation
251+ visible: iconSource !== "" && type !== Notification.Confirmation
@@ -282,6 +267,8 @@ StyledItem {
283 visible: type !== Notification.Confirmation
268 visible: type !== Notification.Confirmation
284 fontSize: "medium"
269 fontSize: "medium"
270+ font.weight: Font.Light
271+ color: theme.palette.normal.backgroundSecondaryText
285 elide: Text.ElideRight
272 elide: Text.ElideRight
286 textFormat: Text.PlainText
273 textFormat: Text.PlainText
@@ -296,8 +283,10 @@ StyledItem {
297 visible: body != "" && type !== Notification.Confirmation
284 visible: body != "" && type !== Notification.Confirmation
298 fontSize: "small"
285 fontSize: "small"
286+ font.weight: Font.Light
287+ color: theme.palette.normal.backgroundTertiaryText
299 wrapMode: Text.Wrap
288 wrapMode: Text.Wrap
300− maximumLineCount: type == Notification.SnapDecision ? 12 : 2
289+ maximumLineCount: type === Notification.SnapDecision ? 12 : 2
301 elide: Text.ElideRight
290 elide: Text.ElideRight
302 textFormat: Text.PlainText
291 textFormat: Text.PlainText
@@ -315,17 +304,17 @@ StyledItem {
317 ListItem.ThinDivider {
306 ListItem.ThinDivider {
318− visible: type == Notification.SnapDecision
307+ visible: type === Notification.SnapDecision && notification.state !== "contracted"
321 ShapedIcon {
310 ShapedIcon {
322 id: centeredIcon
311 id: centeredIcon
323 objectName: "centeredIcon"
312 objectName: "centeredIcon"
324− width: units.gu(5)
313+ width: units.gu(6)
325 height: width
314 height: width
326− shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
315+ shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
327 fileSource: icon.fileSource
316 fileSource: icon.fileSource
328− visible: fileSource !== undefined && fileSource !== "" && type === Notification.Confirmation
317+ visible: fileSource !== "" && type === Notification.Confirmation
329 anchors.horizontalCenter: parent.horizontalCenter
318 anchors.horizontalCenter: parent.horizontalCenter
@@ -336,6 +325,8 @@ StyledItem {
336 anchors.horizontalCenter: parent.horizontalCenter
325 anchors.horizontalCenter: parent.horizontalCenter
337 visible: type === Notification.Confirmation && body !== ""
326 visible: type === Notification.Confirmation && body !== ""
338 fontSize: "medium"
327 fontSize: "medium"
328+ font.weight: Font.Light
329+ color: theme.palette.normal.backgroundSecondaryText
339 wrapMode: Text.WordWrap
330 wrapMode: Text.WordWrap
340 maximumLineCount: 1
331 maximumLineCount: 1
341 elide: Text.ElideRight
332 elide: Text.ElideRight
@@ -351,7 +342,6 @@ StyledItem {
351 anchors {
342 anchors {
352 left: parent.left
343 left: parent.left
353 right: parent.right
344 right: parent.right
354− margins: contentSpacing
357 height: units.gu(1)
347 height: units.gu(1)
@@ -364,7 +354,7 @@ StyledItem {
364 objectName: "innerBar"
354 objectName: "innerBar"
365 width: valueIndicator.width * valueIndicator.value / 100
355 width: valueIndicator.width * valueIndicator.value / 100
366 height: units.gu(1)
356 height: units.gu(1)
367− backgroundColor: notification.hints["x-canonical-value-bar-tint"] === "true" ? theme.palette.normal.activity : theme.palette.highlighted.foreground
357+ backgroundColor: notification.hints["x-canonical-value-bar-tint"] === "true" ? theme.palette.highlighted.activity : theme.palette.normal.activity
368 aspect: UbuntuShape.Flat
358 aspect: UbuntuShape.Flat
369 radius: "small"
359 radius: "small"
@@ -373,7 +363,7 @@ StyledItem {
374 id: dialogColumn
364 id: dialogColumn
375 objectName: "dialogListView"
365 objectName: "dialogListView"
376− spacing: units.gu(2)
366+ spacing: notification.margins
378 visible: count > 0
368 visible: count > 0
@@ -417,12 +407,11 @@ StyledItem {
417 anchors {
407 anchors {
418 left: parent.left
408 left: parent.left
419 right: parent.right
409 right: parent.right
420− margins: contentSpacing
423− spacing: contentSpacing
412+ spacing: notification.margins
425− visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3
414+ visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3 && notification.state === "expanded"
427 Repeater {
416 Repeater {
428 id: oneOverTwoRepeaterTop
417 id: oneOverTwoRepeaterTop
@@ -441,7 +430,8 @@ StyledItem {
441 objectName: "notify_oot_button" + index
430 objectName: "notify_oot_button" + index
442 width: oneOverTwoCase.width
431 width: oneOverTwoCase.width
443 text: oneOverTwoLoaderTop.actionLabel
432 text: oneOverTwoLoaderTop.actionLabel
444− color: notification.hints["x-canonical-private-affirmative-tint"] == "true" ? UbuntuColors.green : theme.palette.normal.baseText
433+ color: notification.hints["x-canonical-private-affirmative-tint"] === "true" ? theme.palette.normal.positive
434+ : theme.palette.normal.baseText
445 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
435 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
@@ -450,7 +440,7 @@ StyledItem {
453− spacing: contentSpacing
443+ spacing: notification.margins
455 Repeater {
445 Repeater {
456 id: oneOverTwoRepeaterBottom
446 id: oneOverTwoRepeaterBottom
@@ -469,7 +459,8 @@ StyledItem {
469 objectName: "notify_oot_button" + index
459 objectName: "notify_oot_button" + index
470 width: oneOverTwoCase.width / 2 - spacing * 2
460 width: oneOverTwoCase.width / 2 - spacing * 2
471 text: oneOverTwoLoaderBottom.actionLabel
461 text: oneOverTwoLoaderBottom.actionLabel
472− color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true" ? UbuntuColors.red : theme.palette.normal.baseText
462+ color: index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true" ? theme.palette.normal.negative
463+ : theme.palette.normal.baseText
473 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
464 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
@@ -486,10 +477,9 @@ StyledItem {
486 anchors {
477 anchors {
487 left: parent.left
478 left: parent.left
488 right: parent.right
479 right: parent.right
489− margins: contentSpacing
491− visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible
481+ visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible && notification.state === "expanded"
492− spacing: contentSpacing
482+ spacing: notification.margins
493 layoutDirection: Qt.RightToLeft
483 layoutDirection: Qt.RightToLeft
@@ -531,11 +521,11 @@ StyledItem {
531 text: loader.actionLabel
521 text: loader.actionLabel
533 var result = theme.palette.normal.baseText;
523 var result = theme.palette.normal.baseText;
534− if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] == "true") {
524+ if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] === "true") {
535− result = UbuntuColors.green;
525+ result = theme.palette.normal.positive;
537− if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true") {
527+ if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true") {
538− result = UbuntuColors.red;
528+ result = theme.palette.normal.negative;
540 return result;
530 return result;
@@ -554,10 +544,9 @@ StyledItem {
554 anchors {
544 anchors {
555 left: parent.left
545 left: parent.left
556 right: parent.right
546 right: parent.right
557− margins: contentSpacing
560− visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
549+ visible: notification.type === Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible && notification.state === "expanded"
561 model: notification.actions
550 model: notification.actions
562 expanded: false
551 expanded: false
563 startIndex: 2
552 startIndex: 2