summaryrefslogtreecommitdiff
path: root/modules/osd
diff options
context:
space:
mode:
Diffstat (limited to 'modules/osd')
-rw-r--r--modules/osd/Background.qml61
-rw-r--r--modules/osd/Content.qml42
-rw-r--r--modules/osd/Osd.qml89
-rw-r--r--modules/osd/Wrapper.qml62
4 files changed, 254 insertions, 0 deletions
diff --git a/modules/osd/Background.qml b/modules/osd/Background.qml
new file mode 100644
index 0000000..e0383f5
--- /dev/null
+++ b/modules/osd/Background.qml
@@ -0,0 +1,61 @@
+import "root:/config"
+import QtQuick
+import QtQuick.Shapes
+
+Shape {
+ id: root
+
+ required property real realWrapperWidth
+ required property real wrapperHeight
+ readonly property int rounding: Appearance.rounding.large
+ readonly property int roundingX: Math.min(rounding, realWrapperWidth / 2)
+ readonly property real wrapperWidth: realWrapperWidth - 1 // Pixel issues :sob:
+
+ preferredRendererType: Shape.CurveRenderer
+ opacity: Appearance.transparency.enabled ? Appearance.transparency.base : 1
+
+ ShapePath {
+ strokeWidth: -1
+ fillColor: Appearance.colours.m3surfaceContainer
+
+ startX: root.wrapperWidth
+
+ PathArc {
+ relativeX: -root.roundingX
+ relativeY: root.rounding
+ radiusX: root.roundingX
+ radiusY: root.rounding
+ }
+ PathLine {
+ x: root.roundingX
+ relativeY: 0
+ }
+ PathArc {
+ relativeX: -root.roundingX
+ relativeY: root.rounding
+ radiusX: root.roundingX
+ radiusY: root.rounding
+ direction: PathArc.Counterclockwise
+ }
+ PathLine {
+ y: root.wrapperHeight - root.rounding * 2
+ }
+ PathArc {
+ relativeX: root.roundingX
+ relativeY: root.rounding
+ radiusX: root.roundingX
+ radiusY: root.rounding
+ direction: PathArc.Counterclockwise
+ }
+ PathLine {
+ x: root.wrapperWidth - root.roundingX
+ relativeY: 0
+ }
+ PathArc {
+ relativeX: root.roundingX
+ relativeY: root.rounding
+ radiusX: root.roundingX
+ radiusY: root.rounding
+ }
+ }
+}
diff --git a/modules/osd/Content.qml b/modules/osd/Content.qml
new file mode 100644
index 0000000..daab4e2
--- /dev/null
+++ b/modules/osd/Content.qml
@@ -0,0 +1,42 @@
+import "root:/widgets"
+import "root:/services"
+import "root:/config"
+import Quickshell
+import QtQuick
+
+Column {
+ id: root
+
+ required property ShellScreen screen
+
+ padding: Appearance.padding.large
+
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+
+ spacing: Appearance.spacing.normal
+
+ VerticalSlider {
+ icon: {
+ if (Audio.muted)
+ return "no_sound";
+ if (value >= 0.5)
+ return "volume_up";
+ if (value > 0)
+ return "volume_down";
+ return "volume_mute";
+ }
+ value: Audio.volume
+ onMoved: Audio.setVolume(value)
+
+ implicitWidth: OsdConfig.sizes.sliderWidth
+ implicitHeight: OsdConfig.sizes.sliderHeight
+ }
+
+ VerticalSlider {
+ icon: "brightness_6"
+
+ implicitWidth: OsdConfig.sizes.sliderWidth
+ implicitHeight: OsdConfig.sizes.sliderHeight
+ }
+}
diff --git a/modules/osd/Osd.qml b/modules/osd/Osd.qml
new file mode 100644
index 0000000..4d744f6
--- /dev/null
+++ b/modules/osd/Osd.qml
@@ -0,0 +1,89 @@
+import "root:/widgets"
+import "root:/services"
+import "root:/config"
+import Quickshell
+import QtQuick
+
+Scope {
+ id: root
+
+ property bool osdVisible
+
+ function show(): void {
+ root.osdVisible = true;
+ timer.restart();
+ }
+
+ Connections {
+ target: Audio
+
+ function onMutedChanged(): void {
+ root.show();
+ }
+
+ function onVolumeChanged(): void {
+ root.show();
+ }
+ }
+
+ Timer {
+ id: timer
+
+ interval: OsdConfig.hideDelay
+ onTriggered: root.osdVisible = false
+ }
+
+ Variants {
+ model: Quickshell.screens
+
+ LazyLoader {
+ loading: true
+
+ required property ShellScreen modelData
+
+ StyledWindow {
+ id: win
+
+ screen: parent.modelData
+ name: "osd"
+ visible: wrapper.shouldBeVisible
+
+ mask: Region {
+ item: wrapper
+ }
+
+ anchors.left: true
+ anchors.right: true
+ height: wrapper.height
+
+ Background {
+ id: bg
+
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+
+ wrapperHeight: wrapper.height
+ realWrapperWidth: Math.min(wrapper.width, content.width)
+ }
+
+ Wrapper {
+ id: wrapper
+
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+
+ implicitHeight: content.height + bg.rounding * 2
+
+ osdVisible: root.osdVisible
+ contentWidth: content.width
+
+ Content {
+ id: content
+
+ screen: parent.modelData
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/modules/osd/Wrapper.qml b/modules/osd/Wrapper.qml
new file mode 100644
index 0000000..92bd3c2
--- /dev/null
+++ b/modules/osd/Wrapper.qml
@@ -0,0 +1,62 @@
+import "root:/config"
+import QtQuick
+
+Item {
+ id: root
+
+ required property bool osdVisible
+ required property real contentWidth
+ property bool shouldBeVisible
+
+ width: 0
+ clip: true
+
+ states: State {
+ name: "visible"
+ when: root.osdVisible
+
+ PropertyChanges {
+ root.width: contentWidth
+ root.shouldBeVisible: true
+ }
+ }
+
+ transitions: [
+ Transition {
+ from: ""
+ to: "visible"
+
+ SequentialAnimation {
+ PropertyAction {
+ target: root
+ property: "shouldBeVisible"
+ }
+ NumberAnimation {
+ target: root
+ property: "width"
+ duration: Appearance.anim.durations.large
+ easing.type: Easing.BezierSpline
+ easing.bezierCurve: Appearance.anim.curves.emphasizedDecel
+ }
+ }
+ },
+ Transition {
+ from: "visible"
+ to: ""
+
+ SequentialAnimation {
+ NumberAnimation {
+ target: root
+ property: "width"
+ duration: Appearance.anim.durations.normal
+ easing.type: Easing.BezierSpline
+ easing.bezierCurve: Appearance.anim.curves.emphasizedAccel
+ }
+ PropertyAction {
+ target: root
+ property: "shouldBeVisible"
+ }
+ }
+ }
+ ]
+}