nichts/modules/style/quickshell/shell/AudioPopup.qml

106 lines
2.5 KiB
QML
Raw Permalink Normal View History

2025-06-26 20:46:50 +02:00
pragma ComponentBehavior: Bound
2025-07-19 00:36:05 +02:00
pragma Singleton
2025-06-26 20:46:50 +02:00
import QtQuick
import Quickshell
import QtQuick.Layouts
import Quickshell.Services.Pipewire
2025-07-19 00:36:05 +02:00
import Quickshell.Wayland
2025-06-26 20:46:50 +02:00
2025-07-19 00:36:05 +02:00
import qs.config
2025-06-26 20:46:50 +02:00
2025-07-19 00:36:05 +02:00
Singleton {
id: root
2025-06-26 20:46:50 +02:00
2025-07-19 00:36:05 +02:00
property real volume: Pipewire.defaultAudioSink?.audio?.volume ?? 0
property real popupOpacity: 0
2025-06-26 20:46:50 +02:00
PwObjectTracker {
2025-07-19 00:36:05 +02:00
objects: [Pipewire.defaultAudioSink]
2025-06-26 20:46:50 +02:00
}
2025-07-19 00:36:05 +02:00
onVolumeChanged: {
root.popupOpacity = 1;
loader.activeAsync = true;
timer.restart();
timer_opacity.restart();
2025-06-26 20:46:50 +02:00
}
LazyLoader {
id: loader
2025-07-19 00:36:05 +02:00
activeAsync: false
2025-06-26 20:46:50 +02:00
PanelWindow {
id: popup
visible: true
2025-07-19 00:36:05 +02:00
implicitWidth: rect.implicitWidth
implicitHeight: 50
color: "transparent"
2025-06-26 20:46:50 +02:00
mask: Region {}
2025-07-19 00:36:05 +02:00
exclusionMode: ExclusionMode.Ignore
2025-06-26 20:46:50 +02:00
WlrLayershell.layer: WlrLayer.Overlay
2025-07-19 00:36:05 +02:00
anchors.bottom: true
margins.bottom: 100
2025-06-26 20:46:50 +02:00
Rectangle {
id: rect
Layout.fillWidth: true
2025-07-19 00:36:05 +02:00
anchors.fill: parent
color: Colors.surface0
implicitWidth: 300
implicitHeight: parent.implicitHeight
2025-06-26 20:46:50 +02:00
radius: 5
2025-07-19 00:36:05 +02:00
opacity: root.popupOpacity
2025-06-26 20:46:50 +02:00
2025-07-19 00:36:05 +02:00
Behavior on opacity {
2025-06-26 20:46:50 +02:00
NumberAnimation {
2025-07-19 00:36:05 +02:00
duration: 500
2025-06-26 20:46:50 +02:00
easing.type: Easing.OutCubic
}
}
Rectangle {
2025-07-19 00:36:05 +02:00
id: bar
color: Colors.blue
implicitWidth: rect.implicitWidth * root.volume - 20
implicitHeight: 30
topRightRadius: 5
bottomRightRadius: 5
2025-06-26 20:46:50 +02:00
anchors {
left: parent.left
2025-07-19 00:36:05 +02:00
verticalCenter: parent.verticalCenter
2025-06-26 20:46:50 +02:00
}
2025-07-19 00:36:05 +02:00
Behavior on implicitWidth {
NumberAnimation {
duration: 300
easing.type: Easing.OutCubic
}
}
2025-06-26 20:46:50 +02:00
}
}
}
}
2025-07-19 00:36:05 +02:00
Timer {
id: timer
interval: 2000
running: false
onTriggered: loader.activeAsync = false
}
Timer {
id: timer_opacity
interval: 1500
running: false
onTriggered: {
root.popupOpacity = 0;
}
}
2025-06-26 20:46:50 +02:00
function init() {
}
}