on xenial help sign in
Make OptionToggle emit/trigger the correct actionId passed via the action-model.
commit9de78553fd659fd9fd84bc3840218171fb4b67dc authorMirco Müller <mirco.mueller@canonical.com> dateFri 31 Oct 2014, 16:11 (12 years ago) parent36cd49c
2 files changed+10−11
qml/Notifications/Notification.qml+4−1 qml/Notifications/OptionToggle.qml+6−10
qml/Notifications/Notification.qml+4−1
@@ -452,8 +452,11 @@ Item {
452452
453453 visible: notification.type == Notification.SnapDecision && actionRepeater.count > 3 && !oneOverTwoCase.visible
454454 model: notification.actions
455− expanded: true
455+ expanded: false
456456 startIndex: 2
457+ onTriggered: {
458+ notification.notification.invokeAction(id)
459+ }
457460 }
458461 }
459462 }
qml/Notifications/OptionToggle.qml+6−10
@@ -11,6 +11,8 @@ UbuntuShape {
1111 property int startIndex
1212 readonly property double itemHeight: units.gu(5)
1313
14+ signal triggered(string id)
15+
1416 Behavior on height {
1517 UbuntuNumberAnimation {
1618 duration: UbuntuAnimation.SnapDuration
@@ -19,30 +21,24 @@ UbuntuShape {
1921
2022 color: Theme.palette.normal.base
2123 borderSource: "none"
22− height: expanded ? (model.count - startIndex) * itemHeight : itemHeight
24+ height: expanded ? (optionToggleRepeater.count - startIndex) * itemHeight : itemHeight
2325 width: parent.width
2426 radius: "medium"
2527 clip: true
2628
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−
3429 Column {
3530 id: optionToggleContent
3631 width: parent.width
37− //property double itemHeight: units.gu(5)
3832
3933 Repeater {
34+ id: optionToggleRepeater
4035 model: optionToggle.model
4136
4237 delegate: Loader {
4338 asynchronous: true
4439 visible: status === Loader.Ready
4540 property string actionLabel: label
41+ property string actionId: id
4642 readonly property var splitLabel: actionLabel.match(/(^([-a-z0-9]+):)?(.*)$/)
4743
4844 Component {
@@ -56,7 +52,7 @@ UbuntuShape {
5652 if (index === startIndex) {
5753 optionToggle.expanded = optionToggle.expanded ? false : true
5854 } else {
59− print("clicked on", label)
55+ optionToggle.triggered(actionId)
6056 }
6157 }
6258