Skip to content

Commit

Permalink
Fix Eeems-Org#169: stepSize not updated when holding button
Browse files Browse the repository at this point in the history
  • Loading branch information
danshick committed Mar 2, 2021
1 parent 8fcc675 commit 45e226a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions applications/launcher/widgets/BetterSpinBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions applications/launcher/widgets/SettingsPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 45e226a

Please sign in to comment.