A few small fixes

This commit is contained in:
Ly-sec 2025-07-28 13:17:30 +02:00
parent a36bc33123
commit a15677aadf
8 changed files with 35 additions and 20 deletions

View file

@ -9,19 +9,21 @@ Item {
property var shell
property int volume: 0
// The total width will match the pill's width
width: pillIndicator.width
height: pillIndicator.height
PillIndicator {
id: pillIndicator
icon: shell && shell.defaultAudioSink && shell.defaultAudioSink.audio && shell.defaultAudioSink.audio.muted ? "volume_off" : (volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up"))
icon: shell && shell.defaultAudioSink && shell.defaultAudioSink.audio && shell.defaultAudioSink.audio.muted
? "volume_off"
: (volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up"))
text: volume + "%"
pillColor: Theme.surfaceVariant
iconCircleColor: Theme.accentPrimary
iconTextColor: Theme.backgroundPrimary
textColor: Theme.textPrimary
StyledTooltip {
id: volumeTooltip
text: "Volume: " + volume + "%\nScroll up/down to change volume.\nLeft click to open the input/output selection."
@ -47,31 +49,36 @@ Item {
Connections {
target: shell ?? null
function onVolumeChanged() {
if (shell && shell.volume !== volume) {
volume = shell.volume
pillIndicator.text = volume + "%"
pillIndicator.icon = shell && shell.defaultAudioSink && shell.defaultAudioSink.audio && shell.defaultAudioSink.audio.muted ? "volume_off" : (volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up"))
pillIndicator.show()
if (shell) {
const clampedVolume = Math.max(0, Math.min(100, shell.volume));
if (clampedVolume !== volume) {
volume = clampedVolume;
pillIndicator.text = volume + "%";
pillIndicator.icon = shell.defaultAudioSink && shell.defaultAudioSink.audio && shell.defaultAudioSink.audio.muted
? "volume_off"
: (volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up"));
pillIndicator.show();
}
}
}
}
Component.onCompleted: {
if (shell && shell.volume !== undefined) {
volume = shell.volume
pillIndicator.show()
volume = Math.max(0, Math.min(100, shell.volume));
pillIndicator.show();
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.NoButton // Accept wheel events only
acceptedButtons: Qt.NoButton
propagateComposedEvents: true
onEntered: volumeDisplay.containsMouse = true
onExited: volumeDisplay.containsMouse = false
cursorShape: Qt.PointingHandCursor
onWheel:(wheel) => {
onWheel: (wheel) => {
if (!shell) return;
let step = 5;
if (wheel.angleDelta.y > 0) {