From 45e226a746ead6182d3517a8a81e0e4212755dd8 Mon Sep 17 00:00:00 2001 From: Dan Shick Date: Mon, 1 Mar 2021 19:44:36 -0500 Subject: [PATCH] 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