@@ -20,7 +20,7 @@ import Unity.Notifications 1.0
20import QMenuModel 0.1
20import QMenuModel 0.1
21import Utils 0.1
21import Utils 0.1
23−UbuntuShape {
23+Item {
24 id: notification
24 id: notification
26 property alias iconSource: icon.fileSource
26 property alias iconSource: icon.fileSource
@@ -32,262 +32,292 @@ UbuntuShape {
32 property var type
32 property var type
33 property var hints
33 property var hints
34 property var notification
34 property var notification
36+ property bool fullscreen
36 objectName: "background"
39 objectName: "background"
37− implicitHeight: type != Notification.PlaceHolder ? contentColumn.height + contentColumn.spacing * 2 : 0
40+ implicitHeight: type != Notification.PlaceHolder ? (fullscreen ? notificationList.fullHeight : contentColumn.height + contentColumn.spacing * 4) : 0
38 color: Qt.rgba(0.132, 0.117, 0.109, 0.97)
42 color: Qt.rgba(0.132, 0.117, 0.109, 0.97)
39 opacity: 0
43 opacity: 0
42− clip: true
45+ clip: fullscreen ? false : true
43 visible: type != Notification.PlaceHolder
46 visible: type != Notification.PlaceHolder
45− UnityMenuModelPaths {
48+ UbuntuShape {
46− id: paths
49+ id: shapedBack
48− source: hints["x-canonical-private-menu-model"]
50− busNameHint: "busName"
51+ visible: !fullscreen
51− actionsHint: "actions"
52+ anchors.fill: parent
52− menuObjectPathHint: "menuPath"
53+ anchors.margins: notificationList.margin
55+ opacity: parent.opacity
55− UnityMenuModel {
59+ Rectangle {
56− id: unityMenuModel
60+ id: nonShapedBack
58− busName: paths.busName
62+ visible: fullscreen
59− actions: paths.actions
63+ anchors.fill: parent
60− menuObjectPath: paths.menuObjectPath
64+ color: parent.color
65+ opacity: parent.opacity
63− Behavior on implicitHeight {
68+ Item {
64− id: heightBehavior
69+ id: contents
70+ anchors.fill: fullscreen ? nonShapedBack : shapedBack
66− enabled: false
72+ UnityMenuModelPaths {
67− UbuntuNumberAnimation {
73+ id: paths
68− duration: UbuntuAnimation.SnapDuration
72− // delay enabling height behavior until the add transition is complete
75+ source: hints["x-canonical-private-menu-model"]
73− onOpacityChanged: if (opacity == 1) heightBehavior.enabled = true
75− MouseArea {
77+ busNameHint: "busName"
76− id: interactiveArea
78+ actionsHint: "actions"
79+ menuObjectPathHint: "menuPath"
78− anchors.fill: contentColumn
82+ UnityMenuModel {
79− objectName: "interactiveArea"
83+ id: unityMenuModel
80− enabled: notification.type == Notification.Interactive
84+
81− onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
85+ busName: paths.busName
86+ actions: paths.actions
87+ menuObjectPath: paths.menuObjectPath
84− Column {
90+ Behavior on implicitHeight {
85− id: contentColumn
91+ id: heightBehavior
87− anchors {
93+ enabled: false
88− left: parent.left
94+ UbuntuNumberAnimation {
89− right: parent.right
95+ duration: UbuntuAnimation.SnapDuration
94− spacing: units.gu(1)
99+ // delay enabling height behavior until the add transition is complete
100+ onOpacityChanged: if (opacity == 1) heightBehavior.enabled = true
96− Row {
102+ MouseArea {
97− id: topRow
103+ id: interactiveArea
105+ anchors.fill: contentColumn
106+ objectName: "interactiveArea"
107+ enabled: notification.type == Notification.Interactive
108+ onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
99− spacing: contentColumn.spacing
100 anchors {
114 anchors {
101 left: parent.left
115 left: parent.left
102 right: parent.right
116 right: parent.right
118+ margins: fullscreen ? 0 : spacing
105− ShapedIcon {
121+ spacing: units.gu(1)
108− objectName: "icon"
123+ Row {
109− width: units.gu(6)
124+ id: topRow
111− shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
112− visible: iconSource !== undefined && iconSource != ""
115− Image {
126+ spacing: contentColumn.spacing
116− id: secondaryIcon
127+ anchors {
118− objectName: "secondaryIcon"
132+ ShapedIcon {
119− width: units.gu(2)
133+ id: icon
121− visible: source !== undefined && source != ""
122− fillMode: Image.PreserveAspectCrop
125− Column {
135+ objectName: "icon"
126− id: labelColumn
136+ width: units.gu(6)
127− width: parent.width - x
137+ height: units.gu(6)
138+ shaped: notification.hints["x-canonical-non-shaped-icon"] == "true" ? false : true
139+ visible: iconSource !== undefined && iconSource != ""
129− anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
142+ Image {
131− Label {
145+ objectName: "secondaryIcon"
132− id: summaryLabel
146+ width: units.gu(2)
148+ visible: source !== undefined && source != ""
149+ fillMode: Image.PreserveAspectCrop
154+ width: parent.width - x
156+ anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
134− objectName: "summaryLabel"
161+ objectName: "summaryLabel"
135− anchors {
162+ anchors {
136− left: parent.left
163+ left: parent.left
137− right: parent.right
164+ right: parent.right
168+ color: Theme.palette.selected.backgroundText
169+ elide: Text.ElideRight
141− color: Theme.palette.selected.backgroundText
142− elide: Text.ElideRight
146− id: bodyLabel
173+ id: bodyLabel
148− objectName: "bodyLabel"
175+ objectName: "bodyLabel"
149− anchors {
176+ anchors {
150− left: parent.left
177+ left: parent.left
151− right: parent.right
178+ right: parent.right
182+ color: Theme.palette.selected.backgroundText
184+ wrapMode: Text.WordWrap
185+ maximumLineCount: 10
186+ elide: Text.ElideRight
155− color: Theme.palette.selected.backgroundText
157− wrapMode: Text.WordWrap
158− maximumLineCount: 10
159− elide: Text.ElideRight
164− Column {
191+ Column {
165− objectName: "dialogListView"
192+ objectName: "dialogListView"
166− spacing: units.gu(2)
193+ spacing: units.gu(2)
168− visible: count > 0
195+ visible: count > 0
170− anchors.left: parent.left; anchors.right: parent.right
197+ anchors.left: parent.left; anchors.right: parent.right
198+ anchors.top: fullscreen ? parent.top : undefined
199+ anchors.bottom: fullscreen ? parent.bottom : undefined
172− Repeater {
201+ Repeater {
173− model: unityMenuModel
202+ model: unityMenuModel
175− NotificationMenuItemFactory {
204+ NotificationMenuItemFactory {
176− anchors.left: parent.left; anchors.right: parent.right
205+ anchors.left: parent.left; anchors.right: parent.right
178− menuModel: unityMenuModel
207+ menuModel: unityMenuModel
179− menuData: model
208+ menuData: model
180− menuIndex: index
209+ menuIndex: index
186− id: buttonRow
215+ id: buttonRow
188− objectName: "buttonRow"
217+ objectName: "buttonRow"
189− anchors {
218+ anchors {
190− left: parent.left
219+ left: parent.left
191− right: parent.right
220+ right: parent.right
193− visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
222+ visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
194− height: units.gu(5)
223+ height: units.gu(5)
196− property real buttonWidth: (width - contentColumn.spacing) / 2
225+ property real buttonWidth: (width - contentColumn.spacing) / 2
197− property bool expanded
226+ property bool expanded
199− Button {
228+ Button {
200− id: leftButton
229+ id: leftButton
202− objectName: "button1"
231+ objectName: "button1"
203− width: parent.expanded ? parent.width : parent.buttonWidth
232+ width: parent.expanded ? parent.width : parent.buttonWidth
204− anchors {
233+ anchors {
205− top: parent.top
234+ top: parent.top
206− bottom: parent.bottom
235+ bottom: parent.bottom
208− text: notification.type == Notification.SnapDecision && actionRepeater.count >= 2 ? actionRepeater.itemAt(1).actionLabel : ""
237+ text: notification.type == Notification.SnapDecision && actionRepeater.count >= 2 ? actionRepeater.itemAt(1).actionLabel : ""
209− gradient: UbuntuColors.greyGradient
238+ gradient: UbuntuColors.greyGradient
210− onClicked: {
239+ onClicked: {
211− if (actionRepeater.count > 2) {
240+ if (actionRepeater.count > 2) {
212− buttonRow.expanded = !buttonRow.expanded
241+ buttonRow.expanded = !buttonRow.expanded
213− } else {
242+ } else {
214− notification.notification.invokeAction(actionRepeater.itemAt(1).actionId)
243+ notification.notification.invokeAction(actionRepeater.itemAt(1).actionId)
248+ UbuntuNumberAnimation {
249+ duration: UbuntuAnimation.SnapDuration
218− Behavior on width {
254+ Button {
219− UbuntuNumberAnimation {
255+ id: rightButton
220− duration: UbuntuAnimation.SnapDuration
256+
257+ objectName: "button0"
259+ left: leftButton.right
260+ leftMargin: contentColumn.spacing
263+ text: notification.type == Notification.SnapDecision && actionRepeater.count >= 1 ? actionRepeater.itemAt(0).actionLabel : ""
266+ bottom: parent.bottom
268+ gradient: notification.hints["x-canonical-private-button-tint"] == "true" ? UbuntuColors.orangeGradient : UbuntuColors.greyGradient
270+ onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
225− Button {
274+ Column {
228− objectName: "button0"
275+ objectName: "buttonColumn"
276+ spacing: contentColumn.spacing
229 anchors {
277 anchors {
230− left: leftButton.right
278+ left: parent.left
231− leftMargin: contentColumn.spacing
232 right: parent.right
279 right: parent.right
234− text: notification.type == Notification.SnapDecision && actionRepeater.count >= 1 ? actionRepeater.itemAt(0).actionLabel : ""
237− bottom: parent.bottom
239− gradient: notification.hints["x-canonical-private-button-tint"] == "true" ? UbuntuColors.orangeGradient : UbuntuColors.greyGradient
241− onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
245− Column {
282+ // calculate initial position before Column takes over
246− objectName: "buttonColumn"
247− spacing: contentColumn.spacing
283+ y: buttonRow.y + buttonRow.height + contentColumn.spacing
253− // calculate initial position before Column takes over
285+ visible: notification.type == Notification.SnapDecision && buttonRow.expanded
254− y: buttonRow.y + buttonRow.height + contentColumn.spacing
286+ height: buttonRow.expanded ? implicitHeight : 0
256− visible: notification.type == Notification.SnapDecision
288+ Repeater {
257− height: buttonRow.expanded ? implicitHeight : 0
289+ id: actionRepeater
259− Repeater {
291+ model: notification.actions
260− id: actionRepeater
292+ delegate: Loader {
262− model: notification.actions
295+ property string actionId: id
263− delegate: Loader {
296+ property string actionLabel: label
266− property string actionId: id
298+ anchors {
267− property string actionLabel: label
299+ left: parent.left
269− anchors {
303+ Component {
270− left: parent.left
304+ id: actionButton
274− Component {
306+ Button {
275− id: actionButton
307+ objectName: "button" + index
277− Button {
313+ text: loader.actionLabel
278− objectName: "button" + index
314+ height: units.gu(5)
279− anchors {
315+ gradient: UbuntuColors.greyGradient
280− left: parent.left
316+ onClicked: notification.notification.invokeAction(loader.actionId)
284− text: loader.actionLabel
286− gradient: UbuntuColors.greyGradient
287− onClicked: notification.notification.invokeAction(loader.actionId)
319+ sourceComponent: (index == 0 || index == 1) ? undefined : actionButton
290− sourceComponent: (index == 0 || index == 1) ? undefined : actionButton