scrolling: speeding up wheel scrolling by x4 on all NxxxView widgets

This commit is contained in:
Lemmy
2026-02-08 17:41:22 -05:00
parent 3a9d42d99a
commit 0ea0019c48
3 changed files with 23 additions and 2 deletions
+1 -1
View File
@@ -269,7 +269,7 @@ Item {
enabled: root.wheelScrollMultiplier !== 1.0
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
onWheel: event => {
const delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y : event.angleDelta.y / 8;
const delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y : event.angleDelta.y / 2;
const newY = gridView.contentY - (delta * root.wheelScrollMultiplier);
gridView.contentY = Math.max(0, Math.min(newY, gridView.contentHeight - gridView.height));
event.accepted = true;
+1 -1
View File
@@ -193,7 +193,7 @@ Item {
enabled: root.wheelScrollMultiplier !== 1.0
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
onWheel: event => {
const delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y : event.angleDelta.y / 8;
const delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y : event.angleDelta.y / 2;
const newY = listView.contentY - (delta * root.wheelScrollMultiplier);
listView.contentY = Math.max(0, Math.min(newY, listView.contentHeight - listView.height));
event.accepted = true;
+21
View File
@@ -24,6 +24,9 @@ T.ScrollView {
property bool reserveScrollbarSpace: true
property real userRightPadding: 0
// Scroll speed multiplier for mouse wheel (1.0 = default, higher = faster)
property real wheelScrollMultiplier: 2.0
rightPadding: userRightPadding + (reserveScrollbarSpace && verticalScrollable ? handleWidth + Style.marginXS : 0)
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, contentWidth + leftPadding + rightPadding)
@@ -83,6 +86,9 @@ T.ScrollView {
`, root, "bottomGradient");
}
// Reference to the internal Flickable for wheel handling
property Flickable _internalFlickable: null
// Function to configure the underlying Flickable
function configureFlickable() {
// Find the internal Flickable (it's usually the first child)
@@ -91,6 +97,7 @@ T.ScrollView {
if (child.toString().indexOf("Flickable") !== -1) {
// Configure the flickable to prevent horizontal scrolling
child.boundsBehavior = root.boundsBehavior;
root._internalFlickable = child;
if (root.preventHorizontalScroll) {
child.flickableDirection = Flickable.VerticalFlick;
@@ -101,6 +108,20 @@ T.ScrollView {
}
}
WheelHandler {
enabled: root.wheelScrollMultiplier !== 1.0 && root._internalFlickable !== null
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
onWheel: event => {
if (!root._internalFlickable)
return;
const flickable = root._internalFlickable;
const delta = event.pixelDelta.y !== 0 ? event.pixelDelta.y : event.angleDelta.y / 2;
const newY = flickable.contentY - (delta * root.wheelScrollMultiplier);
flickable.contentY = Math.max(0, Math.min(newY, flickable.contentHeight - flickable.height));
event.accepted = true;
}
}
// Watch for changes in horizontalPolicy
onHorizontalPolicyChanged: {
preventHorizontalScroll = (horizontalPolicy === ScrollBar.AlwaysOff);