Fix: Scale bar volume scroll by distance for touchpads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user