on xenial help sign in
Make OptionToggle emit/trigger the correct actionId passed via the action-model.
9de7855Mirco Müller
qml/Notifications/Notification.qml+4−1
@@ -452,8 +452,11 @@ Item {
452
452
453 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
453 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
454 model: notification.actions
454 model: notification.actions
455− expanded: true
455+ expanded: false
456 startIndex: 2
456 startIndex: 2
457+ onTriggered: {
458+ notification.notification.invokeAction(id)
459+ }
457 }
460 }
458 }
461 }
459 }
462 }
qml/Notifications/OptionToggle.qml+6−10
@@ -11,6 +11,8 @@ UbuntuShape {
11 property int startIndex
11 property int startIndex
12 readonly property double itemHeight: units.gu(5)
12 readonly property double itemHeight: units.gu(5)
13
13
14+ signal triggered(string id)
15+
14 Behavior on height {
16 Behavior on height {
15 UbuntuNumberAnimation {
17 UbuntuNumberAnimation {
16 duration: UbuntuAnimation.SnapDuration
18 duration: UbuntuAnimation.SnapDuration
@@ -19,30 +21,24 @@ UbuntuShape {
19
21
20 color: Theme.palette.normal.base
22 color: Theme.palette.normal.base
21 borderSource: "none"
23 borderSource: "none"
22− height: expanded ? (model.count - startIndex) * itemHeight : itemHeight
24+ height: expanded ? (optionToggleRepeater.count - startIndex) * itemHeight : itemHeight
23 width: parent.width
25 width: parent.width
24 radius: "medium"
26 radius: "medium"
25 clip: true
27 clip: true
26
28
27− onExpandedChanged: {
28− print("expanded changed to:", expanded ? "true" : "false")
29− print("height:", height)
30− print("count:", model.count)
31− optionToggle.height = expanded ? (model.count - startIndex) * itemHeight : itemHeight
32− }
33−
34 Column {
29 Column {
35 id: optionToggleContent
30 id: optionToggleContent
36 width: parent.width
31 width: parent.width
37− //property double itemHeight: units.gu(5)
38
32
39 Repeater {
33 Repeater {
34+ id: optionToggleRepeater
40 model: optionToggle.model
35 model: optionToggle.model
41
36
42 delegate: Loader {
37 delegate: Loader {
43 asynchronous: true
38 asynchronous: true
44 visible: status === Loader.Ready
39 visible: status === Loader.Ready
45 property string actionLabel: label
40 property string actionLabel: label
41+ property string actionId: id
46 readonly property var splitLabel: actionLabel.match(/(^([-a-z0-9]+):)?(.*)$/)
42 readonly property var splitLabel: actionLabel.match(/(^([-a-z0-9]+):)?(.*)$/)
47
43
48 Component {
44 Component {
@@ -56,7 +52,7 @@ UbuntuShape {
56 if (index === startIndex) {
52 if (index === startIndex) {
57 optionToggle.expanded = optionToggle.expanded ? false : true
53 optionToggle.expanded = optionToggle.expanded ? false : true
58 } else {
54 } else {
59− print("clicked on", label)
55+ optionToggle.triggered(actionId)
60 }
56 }
61 }
57 }
62
58