From 86ddb61a3ff4da07f434f8441cf21e87fce0d6fc Mon Sep 17 00:00:00 2001 From: Runze Date: Thu, 7 Aug 2025 22:26:26 +0800 Subject: [PATCH 1/5] fix(touchpad): differentiate scroll speed between touchpad and mouse wheel --- .../modules/common/widgets/StyledFlickable.qml | 18 ++++++++++++++++++ .../modules/common/widgets/StyledListView.qml | 17 +++++++++++++++++ .../ii/modules/sidebarLeft/AiChat.qml | 3 +++ .../ii/modules/sidebarLeft/Anime.qml | 3 +++ 4 files changed, 41 insertions(+) diff --git a/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml b/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml index 14b3af03c..b077e141d 100644 --- a/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml +++ b/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml @@ -1,6 +1,24 @@ import QtQuick Flickable { + id: root maximumFlickVelocity: 3500 boundsBehavior: Flickable.DragOverBounds + + property real touchpadScrollFactor: 100 + property real mouseScrollFactor: 50 + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton + onWheel: function(wheelEvent) { + var delta = wheelEvent.angleDelta.y / 120; + // 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 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 7021f24a4..c6119fcc0 100644 --- a/.config/quickshell/ii/modules/common/widgets/StyledListView.qml +++ b/.config/quickshell/ii/modules/common/widgets/StyledListView.qml @@ -15,6 +15,9 @@ ListView { property real dragDistance: 0 property bool popin: true + property real touchpadScrollFactor: 100 + property real mouseScrollFactor: 50 + function resetDrag() { root.dragIndex = -1 root.dragDistance = 0 @@ -23,6 +26,20 @@ ListView { maximumFlickVelocity: 3500 boundsBehavior: Flickable.DragOverBounds + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton + onWheel: function(wheelEvent) { + var delta = wheelEvent.angleDelta.y / 120; + // 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 targetY = root.contentY - delta * scrollFactor; + targetY = Math.max(0, Math.min(targetY, root.contentHeight - root.height)); + root.contentY = targetY; + } + } + add: Transition { animations: [ Appearance?.animation.elementMove.numberAnimation.createObject(this, { diff --git a/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml b/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml index dcbff893e..9120a8f72 100644 --- a/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml +++ b/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml @@ -282,6 +282,9 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\) spacing: 10 popin: false + touchpadScrollFactor: 600 + mouseScrollFactor: 200 + property int lastResponseLength: 0 clip: true diff --git a/.config/quickshell/ii/modules/sidebarLeft/Anime.qml b/.config/quickshell/ii/modules/sidebarLeft/Anime.qml index a72837725..07575ca36 100644 --- a/.config/quickshell/ii/modules/sidebarLeft/Anime.qml +++ b/.config/quickshell/ii/modules/sidebarLeft/Anime.qml @@ -137,6 +137,9 @@ Item { anchors.fill: parent spacing: 10 + touchpadScrollFactor: 600 + mouseScrollFactor: 200 + property int lastResponseLength: 0 clip: true From f1c1ed833c28a455bfc5056b0fd9fcd830a57bc5 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 7 Aug 2025 22:31:19 +0700 Subject: [PATCH 2/5] use StyledListView for SelectionDialog --- .../quickshell/ii/modules/common/widgets/SelectionDialog.qml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.config/quickshell/ii/modules/common/widgets/SelectionDialog.qml b/.config/quickshell/ii/modules/common/widgets/SelectionDialog.qml index 72da7ec5e..6044cbfea 100644 --- a/.config/quickshell/ii/modules/common/widgets/SelectionDialog.qml +++ b/.config/quickshell/ii/modules/common/widgets/SelectionDialog.qml @@ -63,7 +63,7 @@ Item { Layout.rightMargin: dialogPadding } - ListView { + StyledListView { id: choiceListView Layout.fillWidth: true Layout.fillHeight: true @@ -71,9 +71,6 @@ Item { currentIndex: root.defaultChoice !== undefined ? root.items.indexOf(root.defaultChoice) : -1 spacing: 6 - maximumFlickVelocity: 3500 - boundsBehavior: Flickable.DragOverBounds - model: ScriptModel { id: choiceModel } From 199b23d14a929125a40c9e6ddfda8184f000e912 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 7 Aug 2025 22:32:02 +0700 Subject: [PATCH 3/5] add config options for scroll factors and threshold --- .config/quickshell/ii/modules/common/Config.qml | 8 ++++++++ .../ii/modules/common/widgets/StyledFlickable.qml | 10 ++++++---- .../ii/modules/common/widgets/StyledListView.qml | 9 +++++---- 3 files changed, 19 insertions(+), 8 deletions(-) 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; From a31733e2db5651e6d14743160b2534031f7c49b0 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 7 Aug 2025 22:39:30 +0700 Subject: [PATCH 4/5] move scrolling animation to styled components --- .../ii/modules/common/widgets/StyledFlickable.qml | 9 +++++++++ .../ii/modules/common/widgets/StyledListView.qml | 9 +++++++++ .config/quickshell/ii/modules/sidebarLeft/AiChat.qml | 9 --------- .config/quickshell/ii/modules/sidebarLeft/Anime.qml | 9 --------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml b/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml index bde7bff9b..7fcf7be88 100644 --- a/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml +++ b/.config/quickshell/ii/modules/common/widgets/StyledFlickable.qml @@ -23,4 +23,13 @@ Flickable { root.contentY = targetY; } } + + Behavior on contentY { + NumberAnimation { + id: scrollAnim + duration: Appearance.animation.scroll.duration + easing.type: Appearance.animation.scroll.type + easing.bezierCurve: Appearance.animation.scroll.bezierCurve + } + } } diff --git a/.config/quickshell/ii/modules/common/widgets/StyledListView.qml b/.config/quickshell/ii/modules/common/widgets/StyledListView.qml index 61e6740fc..6a9cf258f 100644 --- a/.config/quickshell/ii/modules/common/widgets/StyledListView.qml +++ b/.config/quickshell/ii/modules/common/widgets/StyledListView.qml @@ -41,6 +41,15 @@ ListView { } } + Behavior on contentY { + NumberAnimation { + id: scrollAnim + duration: Appearance.animation.scroll.duration + easing.type: Appearance.animation.scroll.type + easing.bezierCurve: Appearance.animation.scroll.bezierCurve + } + } + add: Transition { animations: [ Appearance?.animation.elementMove.numberAnimation.createObject(this, { diff --git a/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml b/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml index 9120a8f72..f3a1dae8f 100644 --- a/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml +++ b/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml @@ -299,15 +299,6 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\) add: null // Prevent function calls from being janky - Behavior on contentY { - NumberAnimation { - id: scrollAnim - duration: Appearance.animation.scroll.duration - easing.type: Appearance.animation.scroll.type - easing.bezierCurve: Appearance.animation.scroll.bezierCurve - } - } - model: ScriptModel { values: Ai.messageIDs.filter(id => { const message = Ai.messageByID[id]; diff --git a/.config/quickshell/ii/modules/sidebarLeft/Anime.qml b/.config/quickshell/ii/modules/sidebarLeft/Anime.qml index 07575ca36..68d4947b8 100644 --- a/.config/quickshell/ii/modules/sidebarLeft/Anime.qml +++ b/.config/quickshell/ii/modules/sidebarLeft/Anime.qml @@ -152,15 +152,6 @@ Item { } } - Behavior on contentY { - NumberAnimation { - id: scrollAnim - duration: Appearance.animation.scroll.duration - easing.type: Appearance.animation.scroll.type - easing.bezierCurve: Appearance.animation.scroll.bezierCurve - } - } - model: ScriptModel { values: { if(root.responses.length > booruResponseListView.lastResponseLength) { From 7013b459a3884376e35272ded87c73ee654e2251 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Thu, 7 Aug 2025 23:13:07 +0700 Subject: [PATCH 5/5] adjust scrolling speed --- .config/quickshell/ii/modules/common/Appearance.qml | 3 +-- .config/quickshell/ii/modules/common/Config.qml | 4 ++-- .config/quickshell/ii/modules/sidebarLeft/AiChat.qml | 4 ++-- .config/quickshell/ii/modules/sidebarLeft/Anime.qml | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.config/quickshell/ii/modules/common/Appearance.qml b/.config/quickshell/ii/modules/common/Appearance.qml index 9c9374860..cfc9e1cae 100644 --- a/.config/quickshell/ii/modules/common/Appearance.qml +++ b/.config/quickshell/ii/modules/common/Appearance.qml @@ -266,7 +266,6 @@ Singleton { easing.bezierCurve: root.animation.elementMoveFast.bezierCurve }} } - property QtObject clickBounce: QtObject { property int duration: 200 property int type: Easing.BezierSpline @@ -279,7 +278,7 @@ Singleton { }} } property QtObject scroll: QtObject { - property int duration: 400 + property int duration: 200 property int type: Easing.BezierSpline property list bezierCurve: animationCurves.standardDecel } diff --git a/.config/quickshell/ii/modules/common/Config.qml b/.config/quickshell/ii/modules/common/Config.qml index d2b979c6a..ed10b805d 100644 --- a/.config/quickshell/ii/modules/common/Config.qml +++ b/.config/quickshell/ii/modules/common/Config.qml @@ -184,8 +184,8 @@ Singleton { 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 int mouseScrollFactor: 120 + property int touchpadScrollFactor: 450 } } diff --git a/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml b/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml index f3a1dae8f..3817afe50 100644 --- a/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml +++ b/.config/quickshell/ii/modules/sidebarLeft/AiChat.qml @@ -282,8 +282,8 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\) spacing: 10 popin: false - touchpadScrollFactor: 600 - mouseScrollFactor: 200 + touchpadScrollFactor: Config.options.interactions.scrolling.touchpadScrollFactor * 1.4 + mouseScrollFactor: Config.options.interactions.scrolling.mouseScrollFactor * 1.4 property int lastResponseLength: 0 diff --git a/.config/quickshell/ii/modules/sidebarLeft/Anime.qml b/.config/quickshell/ii/modules/sidebarLeft/Anime.qml index 68d4947b8..97dabd942 100644 --- a/.config/quickshell/ii/modules/sidebarLeft/Anime.qml +++ b/.config/quickshell/ii/modules/sidebarLeft/Anime.qml @@ -137,8 +137,8 @@ Item { anchors.fill: parent spacing: 10 - touchpadScrollFactor: 600 - mouseScrollFactor: 200 + touchpadScrollFactor: Config.options.interactions.scrolling.touchpadScrollFactor * 1.4 + mouseScrollFactor: Config.options.interactions.scrolling.mouseScrollFactor * 1.4 property int lastResponseLength: 0