on xenial help sign in
Started adding support for the ComboButton SDK-element being used for snap-decisions using more than 2 actions.
ebe3c65Mirco Müller
qml/Notifications/Notification.qml+84−79
@@ -15,11 +15,13 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18−import Ubuntu.Components 0.1
18+import Ubuntu.Components 1.1
19import Unity.Notifications 1.0
19import Unity.Notifications 1.0
20import QMenuModel 0.1
20import QMenuModel 0.1
21import Utils 0.1
21import Utils 0.1
22
22
23+import Ubuntu.Components.ListItems 0.1 as ListItem
24+
23Item {
25Item {
24 id: notification
26 id: notification
25
27
@@ -36,6 +38,14 @@ Item {
36 property bool fullscreen
38 property bool fullscreen
37 property int maxHeight
39 property int maxHeight
38 property int margins
40 property int margins
41+ property Gradient greenGradient : Gradient {
42+ GradientStop { position: 0.0; color: "#39b44a" }
43+ GradientStop { position: 1.0; color: "#50be61" }
44+ }
45+ property Gradient darkgreyGradient: Gradient {
46+ GradientStop { position: 0.0; color: "#534e4b" }
47+ GradientStop { position: 1.0; color: "#5d5856" }
48+ }
39
49
40 fullscreen: false
50 fullscreen: false
41 objectName: "background"
51 objectName: "background"
@@ -278,7 +288,7 @@ Item {
278 }
288 }
279 }
289 }
280
290
281− Item {
291+ Row {
282 id: buttonRow
292 id: buttonRow
283
293
284 objectName: "buttonRow"
294 objectName: "buttonRow"
@@ -287,70 +297,8 @@ Item {
287 right: parent.right
297 right: parent.right
288 }
298 }
289 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
299 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 0
290− height: units.gu(5)
300+ spacing: units.gu(1)
291−
301+ layoutDirection: Qt.RightToLeft
292− property real buttonWidth: (width - contentColumn.spacing) / 2
293− property bool expanded
294−
295− Button {
296− id: leftButton
297−
298− objectName: "button1"
299− width: parent.expanded ? parent.width : parent.buttonWidth
300− anchors {
301− top: parent.top
302− bottom: parent.bottom
303− }
304− text: notification.type == Notification.SnapDecision && actionRepeater.count >= 2 ? actionRepeater.itemAt(1).actionLabel : ""
305− gradient: UbuntuColors.greyGradient
306− onClicked: {
307− if (actionRepeater.count > 2) {
308− buttonRow.expanded = !buttonRow.expanded
309− } else {
310− notification.notification.invokeAction(actionRepeater.itemAt(1).actionId)
311− }
312− }
313−
314− Behavior on width {
315− UbuntuNumberAnimation {
316− duration: UbuntuAnimation.SnapDuration
317− }
318− }
319− }
320−
321− Button {
322− id: rightButton
323−
324− objectName: "button0"
325− anchors {
326− left: leftButton.right
327− leftMargin: contentColumn.spacing
328− right: parent.right
329− }
330− text: notification.type == Notification.SnapDecision && actionRepeater.count >= 1 ? actionRepeater.itemAt(0).actionLabel : ""
331− anchors {
332− top: parent.top
333− bottom: parent.bottom
334− }
335− gradient: notification.hints["x-canonical-private-button-tint"] == "true" ? UbuntuColors.orangeGradient : UbuntuColors.greyGradient
336− visible: width > 0
337− onClicked: notification.notification.invokeAction(actionRepeater.itemAt(0).actionId)
338− }
339− }
340−
341− Column {
342− objectName: "buttonColumn"
343− spacing: contentColumn.spacing
344− anchors {
345− left: parent.left
346− right: parent.right
347− }
348−
349− // calculate initial position before Column takes over
350− y: buttonRow.y + buttonRow.height + contentColumn.spacing
351−
352− visible: notification.type == Notification.SnapDecision && buttonRow.expanded
353− height: buttonRow.expanded ? implicitHeight : 0
354
302
355 Repeater {
303 Repeater {
356 id: actionRepeater
304 id: actionRepeater
@@ -362,28 +310,85 @@ Item {
362 property string actionId: id
310 property string actionId: id
363 property string actionLabel: label
311 property string actionLabel: label
364
312
365− anchors {
366− left: parent.left
367− right: parent.right
368− }
369−
370 Component {
313 Component {
371 id: actionButton
314 id: actionButton
372
315
373 Button {
316 Button {
374 objectName: "button" + index
317 objectName: "button" + index
375− anchors {
318+ width: buttonRow.width / 2 - spacing
376− left: parent.left
377− right: parent.right
378− }
379−
380 text: loader.actionLabel
319 text: loader.actionLabel
381− height: units.gu(5)
320+ gradient: notification.hints["x-canonical-private-button-tint"] == "true" && index == 0 ? greenGradient : darkgreyGradient
382− gradient: UbuntuColors.greyGradient
383 onClicked: notification.notification.invokeAction(loader.actionId)
321 onClicked: notification.notification.invokeAction(loader.actionId)
384 }
322 }
385 }
323 }
386− sourceComponent: (index == 0 || index == 1) ? undefined : actionButton
324+ sourceComponent: (index == 0 || index == 1) ? actionButton : undefined
325+ }
326+ }
327+ }
328+
329+ ComboButton {
330+ width: parent.width
331+ text: "Decline"
332+ visible: notification.type == Notification.SnapDecision && actionRepeater.count > 2
333+ gradient: darkgreyGradient
334+ onClicked: print ("Clicked on " + text)
335+ expanded: false
336+ expandedHeight: (actionRepeater.count - 2) * units.gu(4) + units.gu(4.5)
337+ comboList: ListView {
338+ id: myView
339+
340+ width: parent.width
341+ interactive: false
342+
343+ model: notification.actions
344+ delegate: Column {
345+ id: myDelegate
346+
347+ width: parent.width
348+
349+ ListItem.ThinDivider {
350+ visible: index != 0
351+ }
352+
353+ MouseArea {
354+ x: delegateRow.x
355+ y: delegateRow.y
356+ width: delegateRow.width
357+ height: delegateRow.height
358+
359+ onClicked: {
360+ print ("Clicked on: " + label)
361+ }
362+
363+ Row {
364+ id: delegateRow
365+ /*Rectangle {
366+ id: frame
367+
368+ color: Qt.rgba(0.0, 0.0, 0.0, 0.0)
369+ width: myDelegate.height
370+ height: width
371+
372+ Icon {
373+ anchors.fill: parent
374+ anchors.margins: units.gu(1)
375+ width: units.gu(3)
376+ height: units.gu(3)
377+ name: icon
378+ color: "white"
379+ }
380+ }*/
381+
382+ Label {
383+ //height: frame.height
384+ height: units.gu(3)
385+ verticalAlignment: Text.AlignVCenter
386+ fontSize: "small"
387+ color: "white"
388+ text: label
389+ }
390+ }
391+ }
387 }
392 }
388 }
393 }
389 }
394 }