Fix: Scale bar volume scroll by distance for touchpads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-16 03:40:27 +01:00
parent 90d0e2bed0
commit 954dedf7cd

View File

@@ -137,15 +137,25 @@ Item {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
// Scroll distance is accumulated rather than stepping per event:
// a mouse wheel sends one 120-unit event per notch, but a touchpad
// sends a stream of tiny events, which at a fixed step per event
// made touchpad scrolling far too fast. One notch's worth (120) of
// scrolling = one volume step, regardless of input device.
property real wheelAccum: 0
readonly property real volumeStep: 0.05
readonly property real unitsPerStep: 120
onClicked: { onClicked: {
panel.visible = !panel.visible panel.visible = !panel.visible
grab.active = panel.visible grab.active = panel.visible
} }
onWheel: (wheel) => { onWheel: (wheel) => {
if (!root.sink || !root.sink.audio) return if (!root.sink || !root.sink.audio) return
const step = 0.05 wheelAccum += wheel.angleDelta.y
const delta = wheel.angleDelta.y > 0 ? step : -step const steps = Math.trunc(wheelAccum / unitsPerStep)
root.sink.audio.volume = Math.max(0, Math.min(1, root.sink.audio.volume + delta)) if (steps === 0) return
wheelAccum -= steps * unitsPerStep
root.sink.audio.volume = Math.max(0, Math.min(1, root.sink.audio.volume + steps * volumeStep))
} }
} }