@@ -20,7 +20,7 @@ import Unity.Notifications 1.0
2020import QMenuModel 0.1
2121import Utils 0.1
2222
23−UbuntuShape {
23+Item {
2424 id: notification
2525
2626 property alias iconSource: avatarIcon.source
@@ -32,266 +32,297 @@ UbuntuShape {
3232 property var type
3333 property var hints
3434 property var notification
35+ property color color
36+ property bool fullscreen
3537
38+ fullscreen: notification.hints["x-canonical-private-fullscreen"] == "true" ? true : false
3639 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 * 2) : 0
41+
42+ //parent.anchors.leftMargin: fullscreen ? 0 : notificationList.margin
43+ //parent.anchors.rightMargin: fullscreen ? 0 : notificationList.margin
44+ //parent.anchors.topMargin: fullscreen ? notificationList.panelHeight : notificationList.panelHeight + notificationList.margin
45+
3846 color: Qt.rgba(0.132, 0.117, 0.109, 0.97)
3947 opacity: 0
40− radius: "medium"
4148
4249 clip: true
4350 visible: type != Notification.PlaceHolder
4451
45− UnityMenuModelPaths {
46− id: paths
47−
48− source: hints["x-canonical-private-menu-model"]
52+ UbuntuShape {
53+ id: shapedBack
4954
50− busNameHint: "busName"
51− actionsHint: "actions"
52− menuObjectPathHint: "menuPath"
55+ visible: !fullscreen
56+ anchors.fill: parent
57+ color: parent.color
58+ opacity: parent.opacity
59+ radius: "medium"
5360 }
5461
55− UnityMenuModel {
56− id: unityMenuModel
62+ Rectangle {
63+ id: nonShapedBack
5764
58− busName: paths.busName
59− actions: paths.actions
60− menuObjectPath: paths.menuObjectPath
65+ visible: fullscreen
66+ anchors.fill: parent
67+ color: parent.color
68+ opacity: parent.opacity
6169 }
6270
63− Behavior on implicitHeight {
64− id: heightBehavior
71+ Item {
72+ id: contents
73+ anchors.fill: parent
6574
66− enabled: false
67− UbuntuNumberAnimation {
68− duration: UbuntuAnimation.SnapDuration
69− }
70− }
75+ UnityMenuModelPaths {
76+ id: paths
7177
72− // delay enabling height behavior until the add transition is complete
73− onOpacityChanged: if (opacity == 1) heightBehavior.enabled = true
78+ source: hints["x-canonical-private-menu-model"]
7479
75− MouseArea {
76− id: interactiveArea
80+ busNameHint: "busName"
81+ actionsHint: "actions"
82+ menuObjectPathHint: "menuPath"
83+ }
7784
78− anchors.fill: contentColumn
79− objectName: "interactiveArea"
80− enabled: notification.type == Notification.Interactive
81− onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
82− }
85+ UnityMenuModel {
86+ id: unityMenuModel
8387
84− Column {
85− id: contentColumn
88+ busName: paths.busName
89+ actions: paths.actions
90+ menuObjectPath: paths.menuObjectPath
91+ }
8692
87− anchors {
88− left: parent.left
89− right: parent.right
90− top: parent.top
91− margins: spacing
93+ Behavior on implicitHeight {
94+ id: heightBehavior
95+
96+ enabled: false
97+ UbuntuNumberAnimation {
98+ duration: UbuntuAnimation.SnapDuration
99+ }
92100 }
93101
94− spacing: units.gu(1)
102+ // delay enabling height behavior until the add transition is complete
103+ onOpacityChanged: if (opacity == 1) heightBehavior.enabled = true
95104
96− Row {
97− id: topRow
105+ MouseArea {
106+ id: interactiveArea
107+
108+ anchors.fill: contentColumn
109+ objectName: "interactiveArea"
110+ enabled: notification.type == Notification.Interactive
111+ onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
112+ }
113+
114+ Column {
115+ id: contentColumn
98116
99− spacing: contentColumn.spacing
100117 anchors {
101118 left: parent.left
102119 right: parent.right
120+ top: parent.top
121+ margins: spacing
103122 }
104123
105− UbuntuShape {
106− id: icon
124+ spacing: units.gu(1)
107125
108− objectName: "icon"
109− width: units.gu(6)
110− height: units.gu(6)
111− visible: iconSource !== undefined && iconSource != ""
112− image: Image {
113− id: avatarIcon
126+ Row {
127+ id: topRow
114128
115− fillMode: Image.PreserveAspectCrop
129+ spacing: contentColumn.spacing
130+ anchors {
131+ left: parent.left
132+ right: parent.right
116133 }
117− }
118134
119− Image {
120− id: secondaryIcon
135+ UbuntuShape {
136+ id: icon
121137
122− objectName: "secondaryIcon"
123− width: units.gu(2)
124− height: units.gu(2)
125− visible: source !== undefined && source != ""
126− fillMode: Image.PreserveAspectCrop
127− }
138+ objectName: "icon"
139+ width: units.gu(6)
140+ height: units.gu(6)
141+ visible: iconSource !== undefined && iconSource != ""
142+ image: Image {
143+ id: avatarIcon
128144
129− Column {
130− id: labelColumn
131− width: parent.width - x
145+ fillMode: Image.PreserveAspectCrop
146+ }
147+ }
148+
149+ Image {
150+ id: secondaryIcon
151+
152+ objectName: "secondaryIcon"
153+ width: units.gu(2)
154+ height: units.gu(2)
155+ visible: source !== undefined && source != ""
156+ fillMode: Image.PreserveAspectCrop
157+ }
132158
133− anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
159+ Column {
160+ id: labelColumn
161+ width: parent.width - x
134162
135− Label {
136− id: summaryLabel
163+ anchors.verticalCenter: (icon.visible && !bodyLabel.visible) ? icon.verticalCenter : undefined
137164
138− objectName: "summaryLabel"
139− anchors {
140− left: parent.left
141− right: parent.right
165+ Label {
166+ id: summaryLabel
167+
168+ objectName: "summaryLabel"
169+ anchors {
170+ left: parent.left
171+ right: parent.right
172+ }
173+ fontSize: "medium"
174+ font.bold: true
175+ color: Theme.palette.selected.backgroundText
176+ elide: Text.ElideRight
142177 }
143− fontSize: "medium"
144− font.bold: true
145− color: Theme.palette.selected.backgroundText
146− elide: Text.ElideRight
147− }
148178
149− Label {
150− id: bodyLabel
179+ Label {
180+ id: bodyLabel
151181
152− objectName: "bodyLabel"
153− anchors {
154− left: parent.left
155− right: parent.right
182+ objectName: "bodyLabel"
183+ anchors {
184+ left: parent.left
185+ right: parent.right
186+ }
187+ visible: body != ""
188+ fontSize: "small"
189+ color: Theme.palette.selected.backgroundText
190+ opacity: 0.6
191+ wrapMode: Text.WordWrap
192+ maximumLineCount: 10
193+ elide: Text.ElideRight
156194 }
157− visible: body != ""
158− fontSize: "small"
159− color: Theme.palette.selected.backgroundText
160− opacity: 0.6
161− wrapMode: Text.WordWrap
162− maximumLineCount: 10
163− elide: Text.ElideRight
164195 }
165196 }
166− }
167197
168− Column {
169− objectName: "dialogListView"
170− spacing: units.gu(2)
198+ Column {
199+ objectName: "dialogListView"
200+ spacing: units.gu(2)
171201
172− visible: count > 0
202+ visible: count > 0
173203
174− anchors.left: parent.left; anchors.right: parent.right
204+ anchors.left: parent.left; anchors.right: parent.right
175205
176− Repeater {
177− model: unityMenuModel
206+ Repeater {
207+ model: unityMenuModel
178208
179− NotificationMenuItemFactory {
180− anchors.left: parent.left; anchors.right: parent.right
209+ NotificationMenuItemFactory {
210+ anchors.left: parent.left; anchors.right: parent.right
181211
182− menuModel: unityMenuModel
183− menuData: model
184− menuIndex: index
212+ menuModel: unityMenuModel
213+ menuData: model
214+ menuIndex: index
215+ }
185216 }
186217 }
187− }
188218
189− Item {
190− id: buttonRow
219+ Item {
220+ id: buttonRow
191221
192− objectName: "buttonRow"
193− anchors {
194− left: parent.left
195− right: parent.right
196− }
197− visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
198− height: units.gu(5)
222+ objectName: "buttonRow"
223+ anchors {
224+ left: parent.left
225+ right: parent.right
226+ }
227+ visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
228+ height: units.gu(5)
199229
200− property real buttonWidth: (width - contentColumn.spacing) / 2
201− property bool expanded
230+ property real buttonWidth: (width - contentColumn.spacing) / 2
231+ property bool expanded
202232
203− Button {
204− id: leftButton
233+ Button {
234+ id: leftButton
205235
206− objectName: "button1"
207− width: parent.expanded ? parent.width : parent.buttonWidth
208− anchors {
209− top: parent.top
210− bottom: parent.bottom
211− }
212− text: notification.type == Notification.SnapDecision && actionRepeater.count >= 2 ? actionRepeater.itemAt(1).actionLabel : ""
213− gradient: UbuntuColors.greyGradient
214− onClicked: {
215− if (actionRepeater.count > 2) {
216− buttonRow.expanded = !buttonRow.expanded
217− } else {
218− notification.notification.invokeAction(actionRepeater.itemAt(1).actionId)
236+ objectName: "button1"
237+ width: parent.expanded ? parent.width : parent.buttonWidth
238+ anchors {
239+ top: parent.top
240+ bottom: parent.bottom
241+ }
242+ text: notification.type == Notification.SnapDecision && actionRepeater.count >= 2 ? actionRepeater.itemAt(1).actionLabel : ""
243+ gradient: UbuntuColors.greyGradient
244+ onClicked: {
245+ if (actionRepeater.count > 2) {
246+ buttonRow.expanded = !buttonRow.expanded
247+ } else {
248+ notification.notification.invokeAction(actionRepeater.itemAt(1).actionId)
249+ }
250+ }
251+
252+ Behavior on width {
253+ UbuntuNumberAnimation {
254+ duration: UbuntuAnimation.SnapDuration
255+ }
219256 }
220257 }
221258
222− Behavior on width {
223− UbuntuNumberAnimation {
224− duration: UbuntuAnimation.SnapDuration
259+ Button {
260+ id: rightButton
261+
262+ objectName: "button0"
263+ anchors {
264+ left: leftButton.right
265+ leftMargin: contentColumn.spacing
266+ right: parent.right
225267 }
268+ text: notification.type == Notification.SnapDecision && actionRepeater.count >= 1 ? actionRepeater.itemAt(0).actionLabel : ""
269+ anchors {
270+ top: parent.top
271+ bottom: parent.bottom
272+ }
273+ gradient: notification.hints["x-canonical-private-button-tint"] == "true" ? UbuntuColors.orangeGradient : UbuntuColors.greyGradient
274+ visible: width > 0
275+ onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
226276 }
227277 }
228278
229− Button {
230− id: rightButton
231−
232− objectName: "button0"
279+ Column {
280+ objectName: "buttonColumn"
281+ spacing: contentColumn.spacing
233282 anchors {
234− left: leftButton.right
235− leftMargin: contentColumn.spacing
283+ left: parent.left
236284 right: parent.right
237285 }
238− text: notification.type == Notification.SnapDecision && actionRepeater.count >= 1 ? actionRepeater.itemAt(0).actionLabel : ""
239− anchors {
240− top: parent.top
241− bottom: parent.bottom
242− }
243− gradient: notification.hints["x-canonical-private-button-tint"] == "true" ? UbuntuColors.orangeGradient : UbuntuColors.greyGradient
244− visible: width > 0
245− onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
246− }
247− }
248286
249− Column {
250− objectName: "buttonColumn"
251− spacing: contentColumn.spacing
252− anchors {
253− left: parent.left
254− right: parent.right
255− }
287+ // calculate initial position before Column takes over
288+ y: buttonRow.y + buttonRow.height + contentColumn.spacing
256289
257− // calculate initial position before Column takes over
258− y: buttonRow.y + buttonRow.height + contentColumn.spacing
290+ visible: notification.type == Notification.SnapDecision
291+ height: buttonRow.expanded ? implicitHeight : 0
259292
260− visible: notification.type == Notification.SnapDecision
261− height: buttonRow.expanded ? implicitHeight : 0
293+ Repeater {
294+ id: actionRepeater
262295
263− Repeater {
264− id: actionRepeater
296+ model: notification.actions
297+ delegate: Loader {
298+ id: loader
265299
266− model: notification.actions
267− delegate: Loader {
268− id: loader
300+ property string actionId: id
301+ property string actionLabel: label
269302
270− property string actionId: id
271− property string actionLabel: label
303+ anchors {
304+ left: parent.left
305+ right: parent.right
306+ }
272307
273− anchors {
274− left: parent.left
275− right: parent.right
276− }
308+ Component {
309+ id: actionButton
277310
278− Component {
279− id: actionButton
311+ Button {
312+ objectName: "button" + index
313+ anchors {
314+ left: parent.left
315+ right: parent.right
316+ }
280317
281− Button {
282− objectName: "button" + index
283− anchors {
284− left: parent.left
285− right: parent.right
318+ text: loader.actionLabel
319+ height: units.gu(5)
320+ gradient: UbuntuColors.greyGradient
321+ onClicked: notification.notification.invokeAction(loader.actionId)
286322 }
287−
288− text: loader.actionLabel
289− height: units.gu(5)
290− gradient: UbuntuColors.greyGradient
291− onClicked: notification.notification.invokeAction(loader.actionId)
292323 }
324+ sourceComponent: (index == 0 || index == 1) ? undefined : actionButton
293325 }
294− sourceComponent: (index == 0 || index == 1) ? undefined : actionButton
295326 }
296327 }
297328 }