From c0e727a5b6a70d954bb0f13e595e35e43b08d0e8 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Fri, 4 Jun 2021 22:04:00 +0200 Subject: [PATCH] skins/QMLDemo: Factor out toggle() method for buttons --- res/skins/QMLDemo/ControlButton.qml | 6 +++++- res/skins/QMLDemo/InfoBarButton.qml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/res/skins/QMLDemo/ControlButton.qml b/res/skins/QMLDemo/ControlButton.qml index f69ec0d72f1..6a44ef06e2f 100644 --- a/res/skins/QMLDemo/ControlButton.qml +++ b/res/skins/QMLDemo/ControlButton.qml @@ -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; } diff --git a/res/skins/QMLDemo/InfoBarButton.qml b/res/skins/QMLDemo/InfoBarButton.qml index d6944068e9a..51962df1e61 100644 --- a/res/skins/QMLDemo/InfoBarButton.qml +++ b/res/skins/QMLDemo/InfoBarButton.qml @@ -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"