qs: handle toggles internally instead of relying on hyprctl dispatch global (#1745)

This commit is contained in:
end-4
2025-07-31 12:35:16 +07:00
parent 968e8195ef
commit a08a39b620
21 changed files with 77 additions and 63 deletions
@@ -12,12 +12,11 @@ import Quickshell.Wayland
Scope {
id: root
property bool showOsdValues: false
property var focusedScreen: Quickshell.screens.find(s => s.name === Hyprland.focusedMonitor?.name)
property var brightnessMonitor: Brightness.getMonitorForScreen(focusedScreen)
function triggerOsd() {
showOsdValues = true
GlobalStates.osdBrightnessOpen = true
osdTimeout.restart()
}
@@ -27,7 +26,7 @@ Scope {
repeat: false
running: false
onTriggered: {
showOsdValues = false
GlobalStates.osdBrightnessOpen = false
}
}
@@ -35,7 +34,7 @@ Scope {
target: Audio.sink?.audio ?? null
function onVolumeChanged() {
if (!Audio.ready) return
root.showOsdValues = false
GlobalStates.osdBrightnessOpen = false
}
}
@@ -49,7 +48,7 @@ Scope {
Loader {
id: osdLoader
active: showOsdValues
active: GlobalStates.osdBrightnessOpen
sourceComponent: PanelWindow {
id: osdRoot
@@ -91,7 +90,7 @@ Scope {
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: root.showOsdValues = false
onEntered: GlobalStates.osdBrightnessOpen = false
}
Behavior on implicitHeight {
@@ -125,11 +124,11 @@ Scope {
}
function hide() {
showOsdValues = false
GlobalStates.osdBrightnessOpen = false
}
function toggle() {
showOsdValues = !showOsdValues
GlobalStates.osdBrightnessOpen = !GlobalStates.osdBrightnessOpen
}
}
@@ -146,7 +145,7 @@ Scope {
description: "Hides brightness OSD on press"
onPressed: {
root.showOsdValues = false
GlobalStates.osdBrightnessOpen = false
}
}