Files
glassMxrph/quickshell/bar/modules/VolumeModule.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

71 lines
2.7 KiB
QML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import QtQuick
import "../../components"
import "../../core"
import "../../services"
import "../../theme"
// Output volume: scroll to adjust, click to mute, right-click for audio settings.
GlassButton {
id: root
objectName: "volumePill"
readonly property var audio: AudioService.sink ? AudioService.sink.audio : null
readonly property bool muted: !!audio && audio.muted
readonly property real level: audio ? audio.volume : 0
readonly property int step: ConfigService.ready ? ConfigService.data.osd.step : 5
readonly property string glyph: !audio ? "󰖁" : muted || level === 0 ? "󰖁" : level < 0.34 ? "󰕿" : level < 0.67 ? "󰖀" : "󰕾"
enabled: !!audio
accented: false
implicitHeight: ModuleRegistry.pillHeight
// Width comes from the texts directly; the value reserves room for "100%"
// so the pill does not jitter while scrolling.
TextMetrics {
id: widest
font: value.font
text: "100%"
}
contentItem: Item {
implicitWidth: icon.implicitWidth + 6 + valueWidth
implicitHeight: Math.max(icon.implicitHeight, value.implicitHeight)
readonly property real valueWidth: Math.max(widest.advanceWidth, value.implicitWidth)
Text {
id: icon
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
text: Icons.available ? root.glyph : (root.muted ? "×" : "♪")
font.family: Icons.available ? Icons.family : ""
font.pixelSize: 15
color: root.muted ? Theme.urgent : Theme.text
}
Text {
id: value
anchors.left: icon.right
anchors.leftMargin: 6
anchors.verticalCenter: parent.verticalCenter
text: !root.audio ? "—" : root.muted ? "Off" : Math.round(root.level * 100) + "%"
font.pixelSize: 13
font.features: {
"tnum": 1
}
color: root.muted ? Theme.urgent : Theme.text
}
}
implicitWidth: icon.implicitWidth + 6 + Math.max(widest.advanceWidth, value.implicitWidth) + 28
onClicked: AudioService.mute(false)
WheelHandler {
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
onWheel: event => {
if (!root.audio)
return;
const delta = (event.angleDelta.y || -event.angleDelta.x) > 0 ? 1 : -1;
if (delta > 0)
root.audio.muted = false;
AudioService.volume(false, root.level + delta * root.step / 100);
}
}
TapHandler {
acceptedButtons: Qt.RightButton
onTapped: ShellState.openSettings("audio")
}
Accessible.name: "Volume " + (muted ? "muted" : Math.round(level * 100) + "%")
}