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