Brightness: Multi-monitor working (no external modification detected)
This commit is contained in:
parent
0223e3d9d1
commit
4225cbe704
2 changed files with 29 additions and 83 deletions
|
|
@ -14,73 +14,10 @@ Singleton {
|
|||
readonly property list<Monitor> monitors: variants.instances
|
||||
property bool appleDisplayPresent: false
|
||||
|
||||
// Public properties for backward compatibility
|
||||
readonly property real brightness: focusedMonitor ? focusedMonitor.brightness * 100 : Settings.data.brightness.lastBrightness
|
||||
readonly property bool available: focusedMonitor !== null
|
||||
readonly property string currentMethod: focusedMonitor ? focusedMonitor.method : Settings.data.brightness.lastMethod
|
||||
readonly property var detectedDisplays: monitors.map(m => ({
|
||||
"name": m.modelData.name,
|
||||
"type": m.isDdc ? "external" : "internal",
|
||||
"method": m.method,
|
||||
"index": m.busNum
|
||||
}))
|
||||
|
||||
// Get the currently focused monitor
|
||||
readonly property Monitor focusedMonitor: {
|
||||
if (monitors.length === 0)
|
||||
return null
|
||||
// For now, return the first monitor. Could be enhanced to detect focused monitor
|
||||
return monitors[0]
|
||||
}
|
||||
|
||||
function getMonitorForScreen(screen: ShellScreen): var {
|
||||
return monitors.find(m => m.modelData === screen)
|
||||
}
|
||||
|
||||
function increaseBrightness(step = null): void {
|
||||
if (focusedMonitor) {
|
||||
var stepSize = step !== null ? step : Settings.data.brightness.brightnessStep
|
||||
focusedMonitor.setBrightness(focusedMonitor.brightness + (stepSize / 100))
|
||||
}
|
||||
}
|
||||
|
||||
function decreaseBrightness(step = null): void {
|
||||
if (focusedMonitor) {
|
||||
var stepSize = step !== null ? step : Settings.data.brightness.brightnessStep
|
||||
focusedMonitor.setBrightness(focusedMonitor.brightness - (stepSize / 100))
|
||||
}
|
||||
}
|
||||
|
||||
function setBrightness(newBrightness: real): void {
|
||||
if (focusedMonitor) {
|
||||
focusedMonitor.setBrightness(newBrightness / 100)
|
||||
}
|
||||
}
|
||||
|
||||
function setBrightnessDebounced(newBrightness: real): void {
|
||||
if (focusedMonitor) {
|
||||
focusedMonitor.setBrightnessDebounced(newBrightness / 100)
|
||||
}
|
||||
}
|
||||
|
||||
// Backward compatibility functions
|
||||
function updateBrightness(): void {// No longer needed with the new architecture
|
||||
}
|
||||
|
||||
function setDisplay(displayIndex: int): bool {
|
||||
// No longer needed with the new architecture
|
||||
return true
|
||||
}
|
||||
|
||||
function getDisplayInfo(): var {
|
||||
return focusedMonitor ? {
|
||||
"name": focusedMonitor.modelData.name,
|
||||
"type": focusedMonitor.isDdc ? "external" : "internal",
|
||||
"method": focusedMonitor.method,
|
||||
"index": focusedMonitor.busNum
|
||||
} : null
|
||||
}
|
||||
|
||||
function getAvailableMethods(): list<string> {
|
||||
var methods = []
|
||||
if (monitors.some(m => m.isDdc))
|
||||
|
|
@ -147,6 +84,7 @@ Singleton {
|
|||
readonly property string method: isAppleDisplay ? "apple" : (isDdc ? "ddcutil" : "internal")
|
||||
|
||||
property real brightness: getStoredBrightness()
|
||||
property real lastBrightness: 0
|
||||
property real queuedBrightness: NaN
|
||||
|
||||
// Signal for brightness changes
|
||||
|
|
@ -207,6 +145,14 @@ Singleton {
|
|||
}
|
||||
}
|
||||
|
||||
function increaseBrightness(): void {
|
||||
setBrightness(brightness + 0.1)
|
||||
}
|
||||
|
||||
function decreaseBrightness(): void {
|
||||
setBrightness(monitor.brightness - 0.1)
|
||||
}
|
||||
|
||||
function getStoredBrightness(): real {
|
||||
// Try to get stored brightness for this specific monitor
|
||||
var stored = Settings.data.brightness.monitorBrightness.find(m => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue