1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 21:45:38 -05:00

incorporate ddcutil support

This commit is contained in:
bbedward
2025-08-19 11:06:11 -04:00
parent 8eb17c28b1
commit 0d8ae1e09b
4 changed files with 372 additions and 37 deletions

View File

@@ -56,11 +56,18 @@ Item {
}
DankDropdown {
id: deviceDropdown
width: parent.width
height: 40
visible: BrightnessService.devices.length > 1
text: "Device"
description: ""
description: {
const deviceInfo = BrightnessService.getCurrentDeviceInfo();
if (deviceInfo && deviceInfo.class === "ddc") {
return "DDC changes can be slow and unreliable";
}
return "";
}
currentValue: BrightnessService.currentDevice
options: BrightnessService.devices.map(function(d) {
return d.name;
@@ -68,6 +75,9 @@ Item {
optionIcons: BrightnessService.devices.map(function(d) {
if (d.class === "backlight")
return "desktop_windows";
if (d.class === "ddc")
return "tv";
if (d.name.includes("kbd"))
return "keyboard";
@@ -75,7 +85,35 @@ Item {
return "lightbulb";
})
onValueChanged: function(value) {
BrightnessService.setCurrentDevice(value);
BrightnessService.setCurrentDevice(value, true);
}
Connections {
target: BrightnessService
function onDevicesChanged() {
if (BrightnessService.currentDevice) {
deviceDropdown.currentValue = BrightnessService.currentDevice;
}
// Check if saved device is now available
const lastDevice = SessionData.lastBrightnessDevice || "";
if (lastDevice) {
const deviceExists = BrightnessService.devices.some(d => d.name === lastDevice);
if (deviceExists && (!BrightnessService.currentDevice || BrightnessService.currentDevice !== lastDevice)) {
BrightnessService.setCurrentDevice(lastDevice, false);
}
}
}
function onDeviceSwitched() {
// Force update the description when device switches
deviceDropdown.description = Qt.binding(function() {
const deviceInfo = BrightnessService.getCurrentDeviceInfo();
if (deviceInfo && deviceInfo.class === "ddc") {
return "DDC changes can be slow and unreliable";
}
return "";
});
}
}
}
@@ -85,7 +123,8 @@ Item {
value: BrightnessService.brightnessLevel
leftIcon: "brightness_low"
rightIcon: "brightness_high"
enabled: BrightnessService.brightnessAvailable
enabled: BrightnessService.brightnessAvailable && BrightnessService.isCurrentDeviceReady()
opacity: BrightnessService.isCurrentDeviceReady() ? 1.0 : 0.5
onSliderValueChanged: function(newValue) {
brightnessDebounceTimer.pendingValue = newValue;
brightnessDebounceTimer.restart();
@@ -230,7 +269,11 @@ Item {
brightnessDebounceTimer: Timer {
property int pendingValue: 0
interval: 50
interval: {
// Use longer interval for DDC devices since ddcutil is slow
const deviceInfo = BrightnessService.getCurrentDeviceInfo();
return (deviceInfo && deviceInfo.class === "ddc") ? 100 : 50;
}
repeat: false
onTriggered: {
BrightnessService.setBrightnessInternal(pendingValue, BrightnessService.currentDevice);