Merge pull request #1694 from Cleboost/fix/ddc-brightness-slider

fix(display): external display brightness slider fluidity
This commit is contained in:
Lemmy
2026-02-06 09:35:54 -05:00
committed by GitHub
2 changed files with 52 additions and 6 deletions
@@ -23,6 +23,41 @@ ColumnLayout {
color: Color.mSurface
property var brightnessMonitor: BrightnessService.getMonitorForScreen(modelData)
property real localBrightness: 0.5
property bool localBrightnessChanging: false
onBrightnessMonitorChanged: {
if (brightnessMonitor && !localBrightnessChanging)
localBrightness = brightnessMonitor.brightness || 0.5;
}
Connections {
target: BrightnessService
function onMonitorBrightnessChanged(monitor, newBrightness) {
if (monitor === brightnessMonitor && !localBrightnessChanging) {
localBrightness = newBrightness;
}
}
}
Connections {
target: brightnessMonitor
ignoreUnknownSignals: true
function onBrightnessUpdated() {
if (brightnessMonitor && !localBrightnessChanging) {
localBrightness = brightnessMonitor.brightness || 0;
}
}
}
Timer {
id: debounceTimer
interval: 120
repeat: false
onTriggered: {
if (brightnessMonitor && brightnessMonitor.brightnessControlAvailable && Math.abs(localBrightness - brightnessMonitor.brightness) >= 0.005) {
brightnessMonitor.setBrightness(localBrightness);
}
}
}
ColumnLayout {
id: contentCol
@@ -80,24 +115,32 @@ ColumnLayout {
id: brightnessSlider
from: 0
to: 1
value: brightnessMonitor ? brightnessMonitor.brightness : 0.5
value: localBrightness
stepSize: 0.01
enabled: brightnessMonitor ? brightnessMonitor.brightnessControlAvailable : false
onMoved: value => {
if (brightnessMonitor && brightnessMonitor.brightnessControlAvailable) {
brightnessMonitor.setBrightness(value);
localBrightness = value;
debounceTimer.restart();
}
}
onPressedChanged: (pressed, value) => {
localBrightnessChanging = pressed;
if (brightnessMonitor && brightnessMonitor.brightnessControlAvailable) {
brightnessMonitor.setBrightness(value);
if (pressed) {
localBrightness = value;
debounceTimer.restart();
} else {
localBrightness = value;
debounceTimer.restart();
}
}
}
Layout.fillWidth: true
}
NText {
text: brightnessMonitor ? Math.round(brightnessSlider.value * 100) + "%" : "N/A"
text: brightnessMonitor ? Math.round(localBrightness * 100) + "%" : "N/A"
Layout.preferredWidth: 55
horizontalAlignment: Text.AlignRight
Layout.alignment: Qt.AlignVCenter
+5 -2
View File
@@ -371,8 +371,11 @@ Singleton {
monitor.commandRunning = true;
monitor.ignoreNextChange = true;
var ddcValue = Math.round(value * monitor.maxBrightness);
setBrightnessProc.command = ["ddcutil", "-b", busNum, "--noverify", "--async", "--sleep-multiplier=0.05", "setvcp", "10", ddcValue];
setBrightnessProc.running = true;
var ddcBus = busNum;
Qt.callLater(() => {
setBrightnessProc.command = ["ddcutil", "-b", ddcBus, "--noverify", "--async", "--sleep-multiplier=0.05", "setvcp", "10", ddcValue];
setBrightnessProc.running = true;
});
} else if (!isDdc) {
monitor.commandRunning = true;
monitor.ignoreNextChange = true;