forked from Shinonome/dots-hyprland
qs: handle toggles internally instead of relying on hyprctl dispatch global (#1745)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,12 +12,11 @@ import Quickshell.Hyprland
|
||||
|
||||
Scope {
|
||||
id: root
|
||||
property bool showOsdValues: false
|
||||
property string protectionMessage: ""
|
||||
property var focusedScreen: Quickshell.screens.find(s => s.name === Hyprland.focusedMonitor?.name)
|
||||
|
||||
function triggerOsd() {
|
||||
showOsdValues = true
|
||||
GlobalStates.osdVolumeOpen = true
|
||||
osdTimeout.restart()
|
||||
}
|
||||
|
||||
@@ -27,7 +26,7 @@ Scope {
|
||||
repeat: false
|
||||
running: false
|
||||
onTriggered: {
|
||||
root.showOsdValues = false
|
||||
GlobalStates.osdVolumeOpen = false
|
||||
root.protectionMessage = ""
|
||||
}
|
||||
}
|
||||
@@ -35,7 +34,7 @@ Scope {
|
||||
Connections {
|
||||
target: Brightness
|
||||
function onBrightnessChanged() {
|
||||
showOsdValues = false
|
||||
GlobalStates.osdVolumeOpen = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +60,7 @@ Scope {
|
||||
|
||||
Loader {
|
||||
id: osdLoader
|
||||
active: showOsdValues
|
||||
active: GlobalStates.osdVolumeOpen
|
||||
|
||||
sourceComponent: PanelWindow {
|
||||
id: osdRoot
|
||||
@@ -103,7 +102,7 @@ Scope {
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: root.showOsdValues = false
|
||||
onEntered: GlobalStates.osdVolumeOpen = false
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
@@ -177,11 +176,11 @@ Scope {
|
||||
}
|
||||
|
||||
function hide() {
|
||||
showOsdValues = false
|
||||
GlobalStates.osdVolumeOpen = false
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
showOsdValues = !showOsdValues
|
||||
GlobalStates.osdVolumeOpen = !GlobalStates.osdVolumeOpen
|
||||
}
|
||||
}
|
||||
GlobalShortcut {
|
||||
@@ -197,7 +196,7 @@ Scope {
|
||||
description: "Hides volume OSD on press"
|
||||
|
||||
onPressed: {
|
||||
root.showOsdValues = false
|
||||
GlobalStates.osdVolumeOpen = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user