parent
bed4c3ca7a
commit
d5c1264797
1 changed files with 12 additions and 12 deletions
|
|
@ -24,12 +24,14 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: shell && shell.defaultAudioSink && shell.defaultAudioSink.audio ? shell.defaultAudioSink.audio : null
|
target: shell ?? null
|
||||||
onVolumeChanged: {
|
function onVolumeChanged() {
|
||||||
volume = Math.round(shell.defaultAudioSink.audio.volume * 100);
|
if (shell && shell.volume !== volume) {
|
||||||
pillIndicator.text = volume + "%";
|
volume = shell.volume
|
||||||
pillIndicator.icon = volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up");
|
pillIndicator.text = volume + "%"
|
||||||
pillIndicator.show();
|
pillIndicator.icon = volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up")
|
||||||
|
pillIndicator.show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,15 +48,13 @@ Item {
|
||||||
acceptedButtons: Qt.NoButton // Accept wheel events only
|
acceptedButtons: Qt.NoButton // Accept wheel events only
|
||||||
propagateComposedEvents: true
|
propagateComposedEvents: true
|
||||||
onWheel: {
|
onWheel: {
|
||||||
if (!shell || !shell.defaultAudioSink || !shell.defaultAudioSink.audio) return;
|
if (!shell) return;
|
||||||
let step = 0.05; // 5% as float
|
let step = 5;
|
||||||
let newVolume = shell.defaultAudioSink.audio.volume;
|
|
||||||
if (wheel.angleDelta.y > 0) {
|
if (wheel.angleDelta.y > 0) {
|
||||||
newVolume = Math.min(1, newVolume + step);
|
shell.volume = Math.min(100, shell.volume + step);
|
||||||
} else if (wheel.angleDelta.y < 0) {
|
} else if (wheel.angleDelta.y < 0) {
|
||||||
newVolume = Math.max(0, newVolume - step);
|
shell.volume = Math.max(0, shell.volume - step);
|
||||||
}
|
}
|
||||||
shell.defaultAudioSink.audio.volume = newVolume;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue