From 91dcf51a0cda029519c917c93f330a6ced531784 Mon Sep 17 00:00:00 2001 From: Quinten Kock Date: Wed, 21 Jun 2023 21:03:15 +0200 Subject: [PATCH] Put volume change logic centrally in VolumeSlider This commit puts the volume change logic in one place, to prevent issues related to changing the volume twice. Without this commit there are issues such as dragging from 100%/100% to 100%/50% and then the mixer changing the volume to 50%/25%. I'm not sure I'm entirely happy with this, but it seems to work. (cherry picked from commit fec28d12c086a13038f6c40f10d3c25bb7517660) --- src/kcm/package/contents/ui/DeviceListItem.qml | 18 ++---------------- src/kcm/package/contents/ui/VolumeSlider.qml | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/kcm/package/contents/ui/DeviceListItem.qml b/src/kcm/package/contents/ui/DeviceListItem.qml index 09feea71..ab0ce6f0 100644 --- a/src/kcm/package/contents/ui/DeviceListItem.qml +++ b/src/kcm/package/contents/ui/DeviceListItem.qml @@ -178,12 +178,6 @@ ColumnLayout { Layout.columnSpan: 2 Layout.alignment: Qt.AlignVCenter visible: !balanceButton.checked - - value: Volume - onMoved: { - Volume = value; - Muted = (value === 0); - } } Repeater { @@ -203,16 +197,8 @@ ColumnLayout { Layout.fillWidth: true value: ChannelVolumes[index] - onMoved: { - delegate.pulseObject.setChannelVolume(index, value); - - // volumes are updated async, so we'll just assume it worked here - let newChannelVolumes = ChannelVolumes; - newChannelVolumes[index] = value; - Muted = newChannelVolumes.every((volume) => { - return volume === 0; - }); - } + + channel: index } } } diff --git a/src/kcm/package/contents/ui/VolumeSlider.qml b/src/kcm/package/contents/ui/VolumeSlider.qml index c2cf0a31..fc0c4a6c 100644 --- a/src/kcm/package/contents/ui/VolumeSlider.qml +++ b/src/kcm/package/contents/ui/VolumeSlider.qml @@ -19,6 +19,8 @@ RowLayout { property alias value: slider.value + property int channel: -1 + QQC2.Slider { id: slider @@ -35,7 +37,19 @@ RowLayout { onMoved: { // Since it is not possible to use stepSize without tickmarks being displayed, force 1% steps // Unfortunately without stepSize, it cannot snap visually whilst scrolling by changing value instead of Volume as it breaks the binding - Volume = Math.round(value * 100 / PulseAudio.NormalVolume) * PulseAudio.NormalVolume / 100 + let volume = Math.round(value * 100 / PulseAudio.NormalVolume) * PulseAudio.NormalVolume / 100 + if (channel == -1) { + Volume = volume + Muted = volume === 0; + } else { + delegate.pulseObject.setChannelVolume(channel, volume); + + // volumes are updated async, so we'll just assume it worked here + let newChannelVolumes = ChannelVolumes; + newChannelVolumes[index] = value; + Muted = newChannelVolumes.every(volume => volume === 0); + } + sliderRow.moved() } -- GitLab