diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-27 15:52:18 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-27 15:52:18 +1000 |
| commit | 4b9643a80229ecf0cf7e82c67124870fe95198f6 (patch) | |
| tree | 41ef9ed884641dba2346c8ac400e0fc921555a7f /modules/osd | |
| parent | config: allow enable/disable osd brightness (#481) (diff) | |
| download | caelestia-shell-4b9643a80229ecf0cf7e82c67124870fe95198f6.tar.gz caelestia-shell-4b9643a80229ecf0cf7e82c67124870fe95198f6.tar.bz2 caelestia-shell-4b9643a80229ecf0cf7e82c67124870fe95198f6.zip | |
osd: add mic volume
Disabled by default
Diffstat (limited to 'modules/osd')
| -rw-r--r-- | modules/osd/Content.qml | 122 | ||||
| -rw-r--r-- | modules/osd/Wrapper.qml | 5 |
2 files changed, 89 insertions, 38 deletions
diff --git a/modules/osd/Content.qml b/modules/osd/Content.qml index 80fc714..707695d 100644 --- a/modules/osd/Content.qml +++ b/modules/osd/Content.qml @@ -1,73 +1,123 @@ pragma ComponentBehavior: Bound +import qs.components import qs.components.controls import qs.services import qs.config import qs.utils import QtQuick +import QtQuick.Layouts -Column { +Item { id: root required property Brightness.Monitor monitor - - padding: Appearance.padding.large + required property var visibilities anchors.verticalCenter: parent.verticalCenter anchors.left: parent.left - spacing: Appearance.spacing.normal - - // Speaker volume - CustomMouseArea { - implicitWidth: Config.osd.sizes.sliderWidth - implicitHeight: Config.osd.sizes.sliderHeight - - onWheel: event => { - if (event.angleDelta.y > 0) - Audio.incrementVolume(); - else if (event.angleDelta.y < 0) - Audio.decrementVolume(); - } + implicitWidth: layout.implicitWidth + Appearance.padding.large * 2 + implicitHeight: layout.implicitHeight + Appearance.padding.large * 2 - FilledSlider { - anchors.fill: parent - - icon: Icons.getVolumeIcon(value, Audio.muted) - value: Audio.volume - onMoved: Audio.setVolume(value) - } - } + ColumnLayout { + id: layout - // Brightness - WrappedLoader { - active: Config.osd.enableBrightness + anchors.centerIn: parent + spacing: Appearance.spacing.normal - sourceComponent: CustomMouseArea { + // Speaker volume + CustomMouseArea { implicitWidth: Config.osd.sizes.sliderWidth implicitHeight: Config.osd.sizes.sliderHeight onWheel: event => { - const monitor = root.monitor; - if (!monitor) - return; if (event.angleDelta.y > 0) - monitor.setBrightness(monitor.brightness + 0.1); + Audio.incrementVolume(); else if (event.angleDelta.y < 0) - monitor.setBrightness(monitor.brightness - 0.1); + Audio.decrementVolume(); } FilledSlider { anchors.fill: parent - icon: `brightness_${(Math.round(value * 6) + 1)}` - value: root.monitor?.brightness ?? 0 - onMoved: root.monitor?.setBrightness(value) + icon: Icons.getVolumeIcon(value, Audio.muted) + value: Audio.volume + onMoved: Audio.setVolume(value) + } + } + + // Microphone volume + WrappedLoader { + shouldBeActive: Config.osd.enableMicrophone && (!Config.osd.enableBrightness || !root.visibilities.session) + + sourceComponent: CustomMouseArea { + implicitWidth: Config.osd.sizes.sliderWidth + implicitHeight: Config.osd.sizes.sliderHeight + + onWheel: event => { + if (event.angleDelta.y > 0) + Audio.incrementSourceVolume(); + else if (event.angleDelta.y < 0) + Audio.decrementSourceVolume(); + } + + FilledSlider { + anchors.fill: parent + + icon: Icons.getMicVolumeIcon(value, Audio.sourceMuted) + value: Audio.sourceVolume + onMoved: Audio.setSourceVolume(value) + } + } + } + + // Brightness + WrappedLoader { + shouldBeActive: Config.osd.enableBrightness + + sourceComponent: CustomMouseArea { + implicitWidth: Config.osd.sizes.sliderWidth + implicitHeight: Config.osd.sizes.sliderHeight + + onWheel: event => { + const monitor = root.monitor; + if (!monitor) + return; + if (event.angleDelta.y > 0) + monitor.setBrightness(monitor.brightness + 0.1); + else if (event.angleDelta.y < 0) + monitor.setBrightness(monitor.brightness - 0.1); + } + + FilledSlider { + anchors.fill: parent + + icon: `brightness_${(Math.round(value * 6) + 1)}` + value: root.monitor?.brightness ?? 0 + onMoved: root.monitor?.setBrightness(value) + } } } } + component WrappedLoader: Loader { + required property bool shouldBeActive + + Layout.preferredHeight: shouldBeActive ? Config.osd.sizes.sliderHeight : 0 + opacity: shouldBeActive ? 1 : 0 + active: opacity > 0 asynchronous: true visible: active + + Behavior on Layout.preferredHeight { + Anim { + easing.bezierCurve: Appearance.anim.curves.emphasized + } + } + + Behavior on opacity { + Anim {} + } } } diff --git a/modules/osd/Wrapper.qml b/modules/osd/Wrapper.qml index c1e96d6..62d8c4f 100644 --- a/modules/osd/Wrapper.qml +++ b/modules/osd/Wrapper.qml @@ -8,7 +8,7 @@ Item { id: root required property ShellScreen screen - required property bool visibility + required property var visibilities visible: width > 0 implicitWidth: 0 @@ -16,7 +16,7 @@ Item { states: State { name: "visible" - when: root.visibility && Config.osd.enabled + when: root.visibilities.osd && Config.osd.enabled PropertyChanges { root.implicitWidth: content.implicitWidth @@ -50,5 +50,6 @@ Item { id: content monitor: Brightness.getMonitorForScreen(root.screen) + visibilities: root.visibilities } } |