45 lines
1.3 KiB
QML
45 lines
1.3 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import Quickshell.Services.Pipewire
|
|
import "." as M
|
|
|
|
Row {
|
|
id: root
|
|
spacing: 4
|
|
|
|
PwObjectTracker {
|
|
objects: [Pipewire.defaultAudioSink]
|
|
}
|
|
|
|
readonly property var sink: Pipewire.defaultAudioSink
|
|
readonly property real volume: sink?.audio?.volume ?? 0
|
|
readonly property bool muted: sink?.audio?.muted ?? false
|
|
|
|
M.BarIcon {
|
|
icon: root.muted ? "\uF026" : (root.volume > 0.5 ? "\uF028" : (root.volume > 0 ? "\uF027" : "\uF026"))
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
M.BarLabel {
|
|
label: Math.round(root.volume * 100) + "%"
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
|
|
HoverHandler { id: hover }
|
|
ToolTip {
|
|
visible: hover.hovered
|
|
text: (root.sink?.description ?? root.sink?.name ?? "Unknown sink") +
|
|
"\nVolume: " + Math.round(root.volume * 100) + "%" +
|
|
(root.muted ? "\nMuted" : "")
|
|
}
|
|
|
|
TapHandler {
|
|
onTapped: if (root.sink?.audio) root.sink.audio.muted = !root.sink.audio.muted
|
|
}
|
|
|
|
WheelHandler {
|
|
onWheel: event => {
|
|
if (!root.sink?.audio) return;
|
|
root.sink.audio.volume = Math.max(0, root.sink.audio.volume + (event.angleDelta.y > 0 ? 0.05 : -0.05));
|
|
}
|
|
}
|
|
}
|