From 45e226a746ead6182d3517a8a81e0e4212755dd8 Mon Sep 17 00:00:00 2001 From: Dan Shick Date: Mon, 1 Mar 2021 19:44:36 -0500 Subject: [PATCH 1/2] Fix #169: stepSize not updated when holding button --- .../launcher/widgets/BetterSpinBox.qml | 2 ++ .../launcher/widgets/SettingsPopup.qml | 34 +++++++++---------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/applications/launcher/widgets/BetterSpinBox.qml b/applications/launcher/widgets/BetterSpinBox.qml index 449d86427..c2ef09d69 100644 --- a/applications/launcher/widgets/BetterSpinBox.qml +++ b/applications/launcher/widgets/BetterSpinBox.qml @@ -5,6 +5,8 @@ SpinBox { id: control property bool upPressed: up.pressed property bool downPressed: down.pressed + property bool lastDirectionUp + property bool ignoreNextValueChange: false up.indicator: Rectangle { x: control.mirrored ? 0 : parent.width - width height: parent.height diff --git a/applications/launcher/widgets/SettingsPopup.qml b/applications/launcher/widgets/SettingsPopup.qml index e299e7df3..646a8514f 100644 --- a/applications/launcher/widgets/SettingsPopup.qml +++ b/applications/launcher/widgets/SettingsPopup.qml @@ -49,28 +49,28 @@ Item { stepSize: 1 value: controller.sleepAfter onDownPressedChanged: { - if(this.value <= 10){ - this.stepSize = 1; - return; - } - if(this.value <= 60){ - this.stepSize = 5; - return; - } - this.stepSize = 15; + this.lastDirectionUp = false; } onUpPressedChanged: { - if(this.value < 10){ - this.stepSize = 1; + this.lastDirectionUp = true; + } + onValueChanged: { + if(this.ignoreNextValueChange){ + this.ignoreNextValueChange = false; return; } - if(this.value < 60){ - this.stepSize = 5; - return; + var offset = 0; + if(this.value > 10){ + offset = 4; } - this.stepSize = 15; - } - onValueChanged: { + if(this.value > 60){ + offset = 14; + } + // this event handler will fire a second time + // if offset is non-zero + this.ignoreNextValueChange = offset !== 0; + this.lastDirectionUp ? + this.value += offset : this.value -= offset; controller.sleepAfter = this.value; } Layout.preferredWidth: 300 From 7741125218fd5580426eaa2fd2e50d52b9980d21 Mon Sep 17 00:00:00 2001 From: Dan Shick Date: Mon, 1 Mar 2021 20:16:14 -0500 Subject: [PATCH 2/2] Move lastDirectionUp logic to BetterSpinBox --- applications/launcher/widgets/BetterSpinBox.qml | 6 ++++++ applications/launcher/widgets/SettingsPopup.qml | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/applications/launcher/widgets/BetterSpinBox.qml b/applications/launcher/widgets/BetterSpinBox.qml index c2ef09d69..d498b1c02 100644 --- a/applications/launcher/widgets/BetterSpinBox.qml +++ b/applications/launcher/widgets/BetterSpinBox.qml @@ -7,6 +7,12 @@ SpinBox { property bool downPressed: down.pressed property bool lastDirectionUp property bool ignoreNextValueChange: false + onDownPressedChanged: { + this.lastDirectionUp = false; + } + onUpPressedChanged: { + this.lastDirectionUp = true; + } up.indicator: Rectangle { x: control.mirrored ? 0 : parent.width - width height: parent.height diff --git a/applications/launcher/widgets/SettingsPopup.qml b/applications/launcher/widgets/SettingsPopup.qml index 646a8514f..3620324e7 100644 --- a/applications/launcher/widgets/SettingsPopup.qml +++ b/applications/launcher/widgets/SettingsPopup.qml @@ -48,12 +48,6 @@ Item { to: 360 stepSize: 1 value: controller.sleepAfter - onDownPressedChanged: { - this.lastDirectionUp = false; - } - onUpPressedChanged: { - this.lastDirectionUp = true; - } onValueChanged: { if(this.ignoreNextValueChange){ this.ignoreNextValueChange = false;