mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-02 01:34:46 +00:00
actiondrawer: Smoothen the brightness slider so that it doesn't jump when sending events
This commit is contained in:
parent
b0d45d8409
commit
95d1ec87b1
1 changed files with 33 additions and 2 deletions
|
|
@ -35,7 +35,9 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onScreenBrightnessChanged: {
|
onScreenBrightnessChanged: {
|
||||||
brightnessSlider.value = root.screenBrightness
|
if (!brightnessSlider.pressed && !brightnessTimer.running) {
|
||||||
|
brightnessSlider.value = root.screenBrightness;
|
||||||
|
}
|
||||||
|
|
||||||
if (!disableBrightnessUpdate) {
|
if (!disableBrightnessUpdate) {
|
||||||
var service = pmSource.serviceForSource("PowerDevil");
|
var service = pmSource.serviceForSource("PowerDevil");
|
||||||
|
|
@ -62,6 +64,22 @@ Item {
|
||||||
}
|
}
|
||||||
onDataChanged: root.updateBrightnessUI()
|
onDataChanged: root.updateBrightnessUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we want to smoothen the slider so it doesn't jump immediately after you let go
|
||||||
|
Timer {
|
||||||
|
id: brightnessTimer
|
||||||
|
interval: 500
|
||||||
|
onTriggered: {
|
||||||
|
brightnessSlider.value = root.screenBrightness;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// send brightness events a maximum of 5 times a second
|
||||||
|
Timer {
|
||||||
|
id: sendEventTimer
|
||||||
|
interval: 200
|
||||||
|
onTriggered: root.screenBrightness = brightnessSlider.value
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: brightnessRow
|
id: brightnessRow
|
||||||
|
|
@ -87,7 +105,20 @@ Item {
|
||||||
to: root.maximumScreenBrightness
|
to: root.maximumScreenBrightness
|
||||||
value: root.screenBrightness
|
value: root.screenBrightness
|
||||||
|
|
||||||
onMoved: root.screenBrightness = value;
|
onMoved: {
|
||||||
|
if (!sendEventTimer.running) {
|
||||||
|
root.screenBrightness = value;
|
||||||
|
sendEventTimer.restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onPressedChanged: {
|
||||||
|
if (!pressed) {
|
||||||
|
brightnessTimer.restart();
|
||||||
|
} else {
|
||||||
|
brightnessTimer.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaCore.IconItem {
|
PlasmaCore.IconItem {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue