From c48f411bcbc34afca9cdef713ef020767bd08430 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Wed, 17 Sep 2025 19:46:42 +1000 Subject: osd: fix anim when appear on change --- modules/osd/Content.qml | 16 ++++++---- modules/osd/Interactions.qml | 48 ------------------------------ modules/osd/Wrapper.qml | 71 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 81 insertions(+), 54 deletions(-) delete mode 100644 modules/osd/Interactions.qml (limited to 'modules/osd') diff --git a/modules/osd/Content.qml b/modules/osd/Content.qml index f2bb51c..639de77 100644 --- a/modules/osd/Content.qml +++ b/modules/osd/Content.qml @@ -14,6 +14,12 @@ Item { required property Brightness.Monitor monitor required property var visibilities + required property real volume + required property bool muted + required property real sourceVolume + required property bool sourceMuted + required property real brightness + implicitWidth: layout.implicitWidth + Appearance.padding.large * 2 implicitHeight: layout.implicitHeight + Appearance.padding.large * 2 @@ -38,8 +44,8 @@ Item { FilledSlider { anchors.fill: parent - icon: Icons.getVolumeIcon(value, Audio.muted) - value: Audio.volume + icon: Icons.getVolumeIcon(value, root.muted) + value: root.volume onMoved: Audio.setVolume(value) } } @@ -62,8 +68,8 @@ Item { FilledSlider { anchors.fill: parent - icon: Icons.getMicVolumeIcon(value, Audio.sourceMuted) - value: Audio.sourceVolume + icon: Icons.getMicVolumeIcon(value, root.sourceMuted) + value: root.sourceVolume onMoved: Audio.setSourceVolume(value) } } @@ -91,7 +97,7 @@ Item { anchors.fill: parent icon: `brightness_${(Math.round(value * 6) + 1)}` - value: root.monitor?.brightness ?? 0 + value: root.brightness onMoved: root.monitor?.setBrightness(value) } } diff --git a/modules/osd/Interactions.qml b/modules/osd/Interactions.qml deleted file mode 100644 index a58287a..0000000 --- a/modules/osd/Interactions.qml +++ /dev/null @@ -1,48 +0,0 @@ -import qs.services -import qs.config -import Quickshell -import QtQuick - -Scope { - id: root - - required property ShellScreen screen - required property PersistentProperties visibilities - required property bool hovered - readonly property Brightness.Monitor monitor: Brightness.getMonitorForScreen(screen) - - function show(): void { - root.visibilities.osd = true; - timer.restart(); - } - - Connections { - target: Audio - - function onMutedChanged(): void { - root.show(); - } - - function onVolumeChanged(): void { - root.show(); - } - } - - Connections { - target: root.monitor - - function onBrightnessChanged(): void { - root.show(); - } - } - - Timer { - id: timer - - interval: Config.osd.hideDelay - onTriggered: { - if (!root.hovered) - root.visibilities.osd = false; - } - } -} diff --git a/modules/osd/Wrapper.qml b/modules/osd/Wrapper.qml index d4fae76..0e37edc 100644 --- a/modules/osd/Wrapper.qml +++ b/modules/osd/Wrapper.qml @@ -11,6 +11,27 @@ Item { required property ShellScreen screen required property var visibilities + property bool hovered + readonly property Brightness.Monitor monitor: Brightness.getMonitorForScreen(root.screen) + + property real volume + property bool muted + property real sourceVolume + property bool sourceMuted + property real brightness + + function show(): void { + visibilities.osd = true; + timer.restart(); + } + + Component.onCompleted: { + volume = Audio.volume; + muted = Audio.muted; + sourceVolume = Audio.sourceVolume; + sourceMuted = Audio.sourceMuted; + brightness = root.monitor?.brightness ?? 0; + } visible: width > 0 implicitWidth: 0 @@ -48,6 +69,49 @@ Item { } ] + Connections { + target: Audio + + function onMutedChanged(): void { + root.show(); + root.muted = Audio.muted; + } + + function onVolumeChanged(): void { + root.show(); + root.volume = Audio.volume; + } + + function onSourceMutedChanged(): void { + root.show(); + root.sourceMuted = Audio.sourceMuted; + } + + function onSourceVolumeChanged(): void { + root.show(); + root.sourceVolume = Audio.sourceVolume; + } + } + + Connections { + target: root.monitor + + function onBrightnessChanged(): void { + root.show(); + root.brightness = root.monitor?.brightness ?? 0; + } + } + + Timer { + id: timer + + interval: Config.osd.hideDelay + onTriggered: { + if (!root.hovered) + root.visibilities.osd = false; + } + } + Loader { id: content @@ -57,8 +121,13 @@ Item { Component.onCompleted: active = Qt.binding(() => (root.visibilities.osd && Config.osd.enabled) || root.visible) sourceComponent: Content { - monitor: Brightness.getMonitorForScreen(root.screen) + monitor: root.monitor visibilities: root.visibilities + volume: root.volume + muted: root.muted + sourceVolume: root.sourceVolume + sourceMuted: root.sourceMuted + brightness: root.brightness } } } -- cgit v1.2.3-freya