Fix goal is disabling kinetic scrolling

This commit is contained in:
vslg 2020-05-20 23:03:36 -03:00
parent 1bad1e1106
commit 6f68f35810
5 changed files with 10 additions and 14 deletions

View File

@ -235,13 +235,13 @@ class UISettings(JSONDataFile):
"clearRoomFilterOnEscape": True, "clearRoomFilterOnEscape": True,
"clearMemberFilterOnEscape": True, "clearMemberFilterOnEscape": True,
"collapseSidePanesUnderWindowWidth": 400, "collapseSidePanesUnderWindowWidth": 400,
"enableKineticScrolling": True,
"hideProfileChangeEvents": True, "hideProfileChangeEvents": True,
"hideMembershipEvents": False, "hideMembershipEvents": False,
"hideUnknownEvents": False, "hideUnknownEvents": False,
"maxMessageCharactersPerLine": 65, "maxMessageCharactersPerLine": 65,
"ownMessagesOnLeftAboveWidth": 895, "ownMessagesOnLeftAboveWidth": 895,
"theme": "Midnight.qpl", "theme": "Midnight.qpl",
"useTrackpadFix": False,
"writeAliases": {}, "writeAliases": {},
"media": { "media": {
"autoLoad": True, "autoLoad": True,

View File

@ -27,7 +27,7 @@ HPage {
} }
} }
HTrackpadFix { HKineticScrollingDisabler {
flickable: flickable flickable: flickable
anchors.fill: flickable anchors.fill: flickable
} }

View File

@ -117,7 +117,7 @@ GridView {
} }
HTrackpadFix { HKineticScrollingDisabler {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
} }

View File

@ -2,10 +2,10 @@
import QtQuick 2.12 import QtQuick 2.12
// MouseArea component to fix scroll on trackpad // MouseArea component to disable kinetic scrolling
MouseArea { MouseArea {
id: mouseArea id: mouseArea
enabled: window.settings.useTrackpadFix enabled: ! window.settings.enableKineticScrolling
propagateComposedEvents: true propagateComposedEvents: true
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
@ -21,7 +21,6 @@ MouseArea {
property Flickable flickable: parent property Flickable flickable: parent
property int scrollFactor: 5
// Used to get default flickDeceleration value // Used to get default flickDeceleration value
readonly property Flickable dummy: Flickable {} readonly property Flickable dummy: Flickable {}
@ -33,11 +32,8 @@ MouseArea {
// low resolution trackpads. // low resolution trackpads.
// When higher pixelDelta, more scroll will be applied // When higher pixelDelta, more scroll will be applied
const pixelDelta = const pixelDelta =
wheel.pixelDelta.y * scrollFactor || wheel.pixelDelta.y ||
wheel.angleDelta.y / wheel.angleDelta.y / 8 * Qt.styleHints.wheelScrollLines
24 *
Qt.styleHints.wheelScrollLines *
scrollFactor
// Return current position if there was not any movement // Return current position if there was not any movement
if (flickable.contentHeight < flickable.height || !pixelDelta) if (flickable.contentHeight < flickable.height || !pixelDelta)
@ -61,12 +57,12 @@ MouseArea {
Binding { Binding {
target: flickable target: flickable
property: "maximumFlickVelocity" property: "maximumFlickVelocity"
value: mouseArea.enabled ? scrollFactor : 4000.0 value: mouseArea.enabled ? 0 : 4000.0
} }
Binding { Binding {
target: flickable target: flickable
property: "flickDeceleration" property: "flickDeceleration"
value: mouseArea.enabled ? scrollFactor * 3 : dummy.flickDeceleration value: mouseArea.enabled ? 0 : dummy.flickDeceleration
} }
} }

View File

@ -118,7 +118,7 @@ ListView {
} }
HTrackpadFix { HKineticScrollingDisabler {
id: mouseArea id: mouseArea
anchors.fill: parent anchors.fill: parent
} }