diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-23 13:50:38 +0800 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-23 13:50:38 +0800 |
| commit | d3462ee56bf689b40738cdf5e9a3b378e9996d4e (patch) | |
| tree | 0eb6b5838193383e787d6d0a889c4460d89d1827 /services/Brightness.qml | |
| parent | dashboard: fix bongo cat playing when no media (diff) | |
| download | caelestia-shell-d3462ee56bf689b40738cdf5e9a3b378e9996d4e.tar.gz caelestia-shell-d3462ee56bf689b40738cdf5e9a3b378e9996d4e.tar.bz2 caelestia-shell-d3462ee56bf689b40738cdf5e9a3b378e9996d4e.zip | |
internal: fix memory leaks
Diffstat (limited to 'services/Brightness.qml')
| -rw-r--r-- | services/Brightness.qml | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/services/Brightness.qml b/services/Brightness.qml index fabac1f..1687878 100644 --- a/services/Brightness.qml +++ b/services/Brightness.qml @@ -10,24 +10,22 @@ Singleton { id: root property var ddcMonitors: [] - readonly property list<Monitor> monitors: Quickshell.screens.map(screen => monitorComp.createObject(root, { - screen - })) + readonly property list<Monitor> monitors: variants.instances function getMonitorForScreen(screen: ShellScreen): var { - return monitors.find(m => m.screen === screen); + return monitors.find(m => m.modelData === screen); } function increaseBrightness(): void { const focusedName = Hyprland.focusedMonitor.name; - const monitor = monitors.find(m => focusedName === m.screen.name); + const monitor = monitors.find(m => focusedName === m.modelData.name); if (monitor) monitor.setBrightness(monitor.brightness + 0.1); } function decreaseBrightness(): void { const focusedName = Hyprland.focusedMonitor.name; - const monitor = monitors.find(m => focusedName === m.screen.name); + const monitor = monitors.find(m => focusedName === m.modelData.name); if (monitor) monitor.setBrightness(monitor.brightness - 0.1); } @@ -39,6 +37,14 @@ Singleton { ddcProc.running = true; } + Variants { + id: variants + + model: Quickshell.screens + + Monitor {} + } + Process { id: ddcProc @@ -75,9 +81,9 @@ Singleton { component Monitor: QtObject { id: monitor - required property ShellScreen screen - readonly property bool isDdc: root.ddcMonitors.some(m => m.model === screen.model) - readonly property string busNum: root.ddcMonitors.find(m => m.model === screen.model)?.busNum ?? "" + required property ShellScreen modelData + readonly property bool isDdc: root.ddcMonitors.some(m => m.model === modelData.model) + readonly property string busNum: root.ddcMonitors.find(m => m.model === modelData.model)?.busNum ?? "" property real brightness readonly property Process initProc: Process { @@ -109,10 +115,4 @@ Singleton { initProc.running = true; } } - - Component { - id: monitorComp - - Monitor {} - } } |