diff --git a/.config/quickshell/ii/modules/common/Config.qml b/.config/quickshell/ii/modules/common/Config.qml index bcbbd1e33..d2b979c6a 100644 --- a/.config/quickshell/ii/modules/common/Config.qml +++ b/.config/quickshell/ii/modules/common/Config.qml @@ -181,6 +181,14 @@ Singleton { property list ignoredAppRegexes: [] } + property JsonObject interactions: JsonObject { + property JsonObject scrolling: JsonObject { + property int mouseScrollDeltaThreshold: 120 // delta >= this then it gets detected as mouse scroll rather than touchpad + property int mouseScrollFactor: 50 + property int touchpadScrollFactor: 100 + } + } + property JsonObject language: JsonObject { property JsonObject translator: JsonObject { property string engine: "auto" // Run `trans -list-engines` for available engines. auto should use google diff --git a/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml b/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml index b077e141d..bde7bff9b 100644 --- a/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml +++ b/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml @@ -1,21 +1,23 @@ import QtQuick +import qs.modules.common Flickable { id: root maximumFlickVelocity: 3500 boundsBehavior: Flickable.DragOverBounds - property real touchpadScrollFactor: 100 - property real mouseScrollFactor: 50 + property real touchpadScrollFactor: Config?.options.interactions.scrolling.touchpadScrollFactor ?? 100 + property real mouseScrollFactor: Config?.options.interactions.scrolling.mouseScrollFactor ?? 50 + property real mouseScrollDeltaThreshold: Config?.options.interactions.scrolling.mouseScrollDeltaThreshold ?? 120 MouseArea { anchors.fill: parent acceptedButtons: Qt.NoButton onWheel: function(wheelEvent) { - var delta = wheelEvent.angleDelta.y / 120; + const delta = wheelEvent.angleDelta.y / root.mouseScrollDeltaThreshold; // The angleDelta.y of a touchpad is usually small and continuous, // while that of a mouse wheel is typically in multiples of ±120. - var scrollFactor = Math.abs(wheelEvent.angleDelta.y) >= 120 ? root.mouseScrollFactor : root.touchpadScrollFactor; + var scrollFactor = Math.abs(wheelEvent.angleDelta.y) >= root.mouseScrollDeltaThreshold ? root.mouseScrollFactor : root.touchpadScrollFactor; var targetY = root.contentY - delta * scrollFactor; targetY = Math.max(0, Math.min(targetY, root.contentHeight - root.height)); root.contentY = targetY; diff --git a/.config/quickshell/ii/modules/common/widgets/StyledListView.qml b/.config/quickshell/ii/modules/common/widgets/StyledListView.qml index c6119fcc0..61e6740fc 100644 --- a/.config/quickshell/ii/modules/common/widgets/StyledListView.qml +++ b/.config/quickshell/ii/modules/common/widgets/StyledListView.qml @@ -15,8 +15,9 @@ ListView { property real dragDistance: 0 property bool popin: true - property real touchpadScrollFactor: 100 - property real mouseScrollFactor: 50 + property real touchpadScrollFactor: Config?.options.interactions.scrolling.touchpadScrollFactor ?? 100 + property real mouseScrollFactor: Config?.options.interactions.scrolling.mouseScrollFactor ?? 50 + property real mouseScrollDeltaThreshold: Config?.options.interactions.scrolling.mouseScrollDeltaThreshold ?? 120 function resetDrag() { root.dragIndex = -1 @@ -30,10 +31,10 @@ ListView { anchors.fill: parent acceptedButtons: Qt.NoButton onWheel: function(wheelEvent) { - var delta = wheelEvent.angleDelta.y / 120; + const delta = wheelEvent.angleDelta.y / root.mouseScrollDeltaThreshold; // The angleDelta.y of a touchpad is usually small and continuous, // while that of a mouse wheel is typically in multiples of ±120. - var scrollFactor = Math.abs(wheelEvent.angleDelta.y) >= 120 ? root.mouseScrollFactor : root.touchpadScrollFactor; + var scrollFactor = Math.abs(wheelEvent.angleDelta.y) >= root.mouseScrollDeltaThreshold ? root.mouseScrollFactor : root.touchpadScrollFactor; var targetY = root.contentY - delta * scrollFactor; targetY = Math.max(0, Math.min(targetY, root.contentHeight - root.height)); root.contentY = targetY;