Skip to content

Commit

Permalink
skins/QMLDemo: Factor out toggle() method for buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Holzhaus committed Jun 4, 2021
1 parent 03e28a0 commit c0e727a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion res/skins/QMLDemo/ControlButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ Skin.Button {
property string key // required
property bool toggleable: false

function toggle() {
control.value = !control.value;
}

highlight: control.value
onPressed: {
if (toggleable)
control.value = !control.value;
toggle();
else
control.value = 1;
}
Expand Down
6 changes: 5 additions & 1 deletion res/skins/QMLDemo/InfoBarButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ AbstractButton {
property color pressedColor: activeColor
property alias highlight: control.value

onPressed: control.value = !control.value
function toggle() {
control.value = !control.value;
}

onPressed: toggle()
states: [
State {
name: "pressed"
Expand Down

0 comments on commit c0e727a

Please sign in to comment.