diff options
Diffstat (limited to 'desktop/Switch.qml')
| -rw-r--r-- | desktop/Switch.qml | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/desktop/Switch.qml b/desktop/Switch.qml index f14c986..63de4ba 100644 --- a/desktop/Switch.qml +++ b/desktop/Switch.qml @@ -21,7 +21,10 @@ Rectangle { property bool checked: false property bool enabled: true - signal toggled + // The new state. The switch never sets checked itself: that would break + // the caller's binding, so a draft discarded or a state that failed to + // change left the switch showing the click. The caller's binding moves it. + signal toggled(bool on) implicitWidth: 42 implicitHeight: 24 @@ -42,6 +45,6 @@ Rectangle { MouseArea { anchors.fill: parent cursorShape: sw.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor - onClicked: if (sw.enabled) { sw.checked = !sw.checked; sw.toggled(); } + onClicked: if (sw.enabled) sw.toggled(!sw.checked) } } |
