Commit 1868ce38 authored by David Edmundson's avatar David Edmundson

[keyboard layout] Fix scroll with trackpads

onWheel is a bit messy with trackpads. It we just compare > 0 our scroll
rate is effectively determined by the refresh rate of the device. Use of
120 "wheels" is a common pattern used elsewhere.

Code is effectively copied from plasma-pa

The switch to previous/next direction I copied what was existing.
parent 38c61fcb
......@@ -24,11 +24,21 @@ PlasmaComponents3.ToolButton {
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
property int wheelDelta: 0
onWheel: {
if (wheel.angleDelta.y > 0) {
keyboardLayout.switchToPreviousLayout()
} else {
keyboardLayout.switchToNextLayout()
// Magic number 120 for common "one click"
// See: https://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop
var delta = wheel.angleDelta.y || wheel.angleDelta.x;
wheelDelta += delta;
while (wheelDelta >= 120) {
wheelDelta -= 120;
keyboardLayout.switchToPreviousLayout();
}
while (wheelDelta <= -120) {
wheelDelta += 120;
keyboardLayout.switchToNextLayout();
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment