@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013, 2015 Canonical, Ltd.
2+ * Copyright (C) 2013-2016 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
@@ -36,38 +36,37 @@ StyledItem {
3636 property var type
3737 property var hints
3838 property var notification
39− property color color
39+ property color color: UbuntuColors.silk // TODO theme.palette.normal.overlay
4040 property bool fullscreen: false
4141 property int maxHeight
42− property int margins
43− readonly property bool draggable: (type === Notification.SnapDecision && state === "contracted") || type === Notification.Interactive || type === Notification.Ephemeral
44− readonly property bool darkOnBright: inverseMode || type === Notification.SnapDecision
45− readonly property color sdLightGrey: "#eaeaea"
46− readonly property real contentSpacing: units.gu(2)
42+ property int margins: units.gu(1)
43+ readonly property bool draggable: (type === Notification.SnapDecision && state === "contracted") ||
44+ type === Notification.Interactive ||
45+ type === Notification.Ephemeral
4746 readonly property bool canBeClosed: type === Notification.Ephemeral
47+ readonly property real defaultOpacity: 0.95
4848 property bool hasMouse
49− property bool inverseMode
5049 property url background: ""
5150
5251 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
5453
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)
5756
5857 theme: ThemeSettings {
59− name: darkOnBright ? "Ubuntu.Components.Themes.Ambiance" : "Ubuntu.Components.Themes.SuruDark"
58+ name: "Ubuntu.Components.Themes.Ambiance"
6059 }
6160
6261 state: {
6362 var result = "";
6463
65− if (type == Notification.SnapDecision) {
66− if (ListView.view.currentIndex == index) {
64+ if (type === Notification.SnapDecision) {
65+ if (ListView.view.currentIndex === index) {
6766 result = "expanded";
6867 } else {
6968 if (ListView.view.count > 2) {
70− if (ListView.view.currentIndex == -1 && index == 1) {
69+ if (ListView.view.currentIndex === -1 && index == 1) {
7170 result = "expanded";
7271 } else {
7372 result = "contracted";
@@ -90,39 +89,30 @@ StyledItem {
9089 Component.onCompleted: {
9190 // Turn on screen as needed (Powerd.Notification means the screen
9291 // stays on for a shorter amount of time)
93− if (type == Notification.SnapDecision) {
92+ if (type === Notification.SnapDecision) {
9493 Powerd.setStatus(Powerd.On, Powerd.SnapDecision);
95− } else if (type != Notification.Confirmation) {
94+ } else if (type !== Notification.Confirmation) {
9695 Powerd.setStatus(Powerd.On, Powerd.Notification);
9796 }
9897
9998 // 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 !== "") {
101100 sound.play();
102101 }
103102 }
104103
105104 Behavior on x {
106− id: normalXBehavior
107−
108105 enabled: draggable
109− UbuntuNumberAnimation {
110− duration: UbuntuAnimation.FastDuration
111− easing.type: Easing.OutBounce
112− }
106+ UbuntuNumberAnimation { easing.type: Easing.OutBounce }
113107 }
114108
115109 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 !== "") {
117111 sound.play();
118112 }
119113 }
120114
121115 Behavior on height {
122− id: normalHeightBehavior
123−
124− //enabled: menuItemFactory.progress == 1
125− enabled: true
126116 UbuntuNumberAnimation {
127117 duration: UbuntuAnimation.SnapDuration
128118 }
@@ -131,7 +121,7 @@ StyledItem {
131121 states:[
132122 State {
133123 name: "contracted"
134− PropertyChanges {target: notification; height: units.gu(10)}
124+ PropertyChanges {target: notification; height: topRow.childrenRect.height + notification.margins * 2}
135125 },
136126 State {
137127 name: "expanded"
@@ -141,7 +131,7 @@ StyledItem {
141131
142132 clip: fullscreen ? false : true
143133
144− visible: type != Notification.PlaceHolder
134+ visible: type !== Notification.PlaceHolder
145135
146136 UbuntuShape {
147137 id: shapedBack
@@ -149,9 +139,6 @@ StyledItem {
149139 visible: !fullscreen
150140 anchors {
151141 fill: parent
152− leftMargin: notification.margins
153− rightMargin: notification.margins
154− topMargin: type === Notification.Confirmation ? units.gu(.5) : 0
155142 }
156143 backgroundColor: parent.color
157144 opacity: parent.opacity
@@ -169,7 +156,7 @@ StyledItem {
169156 }
170157
171158 onXChanged: {
172− if (draggable && notification.x > 0.75 * notification.width) {
159+ if (draggable && Math.abs(notification.x) > 0.75 * notification.width) {
173160 notification.notification.close()
174161 }
175162 }
@@ -212,11 +199,11 @@ StyledItem {
212199
213200 drag.target: draggable ? notification : undefined
214201 drag.axis: Drag.XAxis
215− drag.minimumX: 0
202+ drag.minimumX: -notification.width
216203 drag.maximumX: notification.width
217204
218205 onClicked: {
219− if (notification.type == Notification.Interactive) {
206+ if (notification.type === Notification.Interactive) {
220207 notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
221208 } else if (hasMouse && canBeClosed) {
222209 notification.notification.close()
@@ -225,7 +212,7 @@ StyledItem {
225212 }
226213 }
227214 onReleased: {
228− if (notification.x < notification.width / 2) {
215+ if (Math.abs(notification.x) < notification.width / 2) {
229216 notification.x = 0
230217 } else {
231218 notification.x = notification.width
@@ -240,30 +227,28 @@ StyledItem {
240227 left: parent.left
241228 right: parent.right
242229 top: parent.top
243− margins: 0
244− topMargin: fullscreen ? 0 : type === Notification.Confirmation ? units.gu(1) : units.gu(2)
230+ margins: notification.margins
245231 }
246232
247− spacing: type === Notification.Confirmation ? units.gu(1) : units.gu(2)
233+ spacing: notification.margins
248234
249235 Row {
250236 id: topRow
251237
252− spacing: contentSpacing
238+ spacing: notification.margins
253239 anchors {
254240 left: parent.left
255241 right: parent.right
256− margins: contentSpacing
257242 }
258243
259244 ShapedIcon {
260245 id: icon
261246
262247 objectName: "icon"
263− width: type == Notification.Ephemeral && !bodyLabel.visible ? units.gu(3) : units.gu(6)
248+ width: units.gu(6)
264249 height: width
265− shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
266− visible: iconSource !== undefined && iconSource !== "" && type !== Notification.Confirmation
250+ shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
251+ visible: iconSource !== "" && type !== Notification.Confirmation
267252 }
268253
269254 Column {
@@ -282,6 +267,8 @@ StyledItem {
282267 }
283268 visible: type !== Notification.Confirmation
284269 fontSize: "medium"
270+ font.weight: Font.Light
271+ color: theme.palette.normal.backgroundSecondaryText
285272 elide: Text.ElideRight
286273 textFormat: Text.PlainText
287274 }
@@ -296,8 +283,10 @@ StyledItem {
296283 }
297284 visible: body != "" && type !== Notification.Confirmation
298285 fontSize: "small"
286+ font.weight: Font.Light
287+ color: theme.palette.normal.backgroundTertiaryText
299288 wrapMode: Text.Wrap
300− maximumLineCount: type == Notification.SnapDecision ? 12 : 2
289+ maximumLineCount: type === Notification.SnapDecision ? 12 : 2
301290 elide: Text.ElideRight
302291 textFormat: Text.PlainText
303292 }
@@ -315,17 +304,17 @@ StyledItem {
315304 }
316305
317306 ListItem.ThinDivider {
318− visible: type == Notification.SnapDecision
307+ visible: type === Notification.SnapDecision && notification.state !== "contracted"
319308 }
320309
321310 ShapedIcon {
322311 id: centeredIcon
323312 objectName: "centeredIcon"
324− width: units.gu(5)
313+ width: units.gu(6)
325314 height: width
326− shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
315+ shaped: notification.hints["x-canonical-non-shaped-icon"] !== "true"
327316 fileSource: icon.fileSource
328− visible: fileSource !== undefined && fileSource !== "" && type === Notification.Confirmation
317+ visible: fileSource !== "" && type === Notification.Confirmation
329318 anchors.horizontalCenter: parent.horizontalCenter
330319 }
331320
@@ -336,6 +325,8 @@ StyledItem {
336325 anchors.horizontalCenter: parent.horizontalCenter
337326 visible: type === Notification.Confirmation && body !== ""
338327 fontSize: "medium"
328+ font.weight: Font.Light
329+ color: theme.palette.normal.backgroundSecondaryText
339330 wrapMode: Text.WordWrap
340331 maximumLineCount: 1
341332 elide: Text.ElideRight
@@ -351,7 +342,6 @@ StyledItem {
351342 anchors {
352343 left: parent.left
353344 right: parent.right
354− margins: contentSpacing
355345 }
356346
357347 height: units.gu(1)
@@ -364,7 +354,7 @@ StyledItem {
364354 objectName: "innerBar"
365355 width: valueIndicator.width * valueIndicator.value / 100
366356 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
368358 aspect: UbuntuShape.Flat
369359 radius: "small"
370360 }
@@ -373,7 +363,7 @@ StyledItem {
373363 Column {
374364 id: dialogColumn
375365 objectName: "dialogListView"
376− spacing: units.gu(2)
366+ spacing: notification.margins
377367
378368 visible: count > 0
379369
@@ -417,12 +407,11 @@ StyledItem {
417407 anchors {
418408 left: parent.left
419409 right: parent.right
420− margins: contentSpacing
421410 }
422411
423− spacing: contentSpacing
412+ spacing: notification.margins
424413
425− visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3
414+ visible: notification.type === Notification.SnapDecision && oneOverTwoRepeaterTop.count === 3 && notification.state === "expanded"
426415
427416 Repeater {
428417 id: oneOverTwoRepeaterTop
@@ -441,7 +430,8 @@ StyledItem {
441430 objectName: "notify_oot_button" + index
442431 width: oneOverTwoCase.width
443432 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
445435 onClicked: notification.notification.invokeAction(oneOverTwoLoaderTop.actionId)
446436 }
447437 }
@@ -450,7 +440,7 @@ StyledItem {
450440 }
451441
452442 Row {
453− spacing: contentSpacing
443+ spacing: notification.margins
454444
455445 Repeater {
456446 id: oneOverTwoRepeaterBottom
@@ -469,7 +459,8 @@ StyledItem {
469459 objectName: "notify_oot_button" + index
470460 width: oneOverTwoCase.width / 2 - spacing * 2
471461 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
473464 onClicked: notification.notification.invokeAction(oneOverTwoLoaderBottom.actionId)
474465 }
475466 }
@@ -486,10 +477,9 @@ StyledItem {
486477 anchors {
487478 left: parent.left
488479 right: parent.right
489− margins: contentSpacing
490480 }
491− visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible
492− spacing: contentSpacing
481+ visible: notification.type === Notification.SnapDecision && actionRepeater.count > 0 && !oneOverTwoCase.visible && notification.state === "expanded"
482+ spacing: notification.margins
493483 layoutDirection: Qt.RightToLeft
494484
495485 Loader {
@@ -531,11 +521,11 @@ StyledItem {
531521 text: loader.actionLabel
532522 color: {
533523 var result = theme.palette.normal.baseText;
534− if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] == "true") {
535− result = UbuntuColors.green;
524+ if (index == 0 && notification.hints["x-canonical-private-affirmative-tint"] === "true") {
525+ result = theme.palette.normal.positive;
536526 }
537− if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] == "true") {
538− result = UbuntuColors.red;
527+ if (index == 1 && notification.hints["x-canonical-private-rejection-tint"] === "true") {
528+ result = theme.palette.normal.negative;
539529 }
540530 return result;
541531 }
@@ -554,10 +544,9 @@ StyledItem {
554544 anchors {
555545 left: parent.left
556546 right: parent.right
557− margins: contentSpacing
558547 }
559548
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"
561550 model: notification.actions
562551 expanded: false
563552 startIndex: 2