diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-14 00:02:33 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-07-15 20:12:04 +0200 |
commit | 142cfea2ee8b50b5ef2e22b9de4fe4c461411ff2 (patch) | |
tree | e0bd0bcb6d3325a2ee5d9c2984f3cd5ff78cb425 /framework/qml/ListView.qml | |
parent | 89d62446608feb3296edb692b218d9eecdb24fe4 (diff) | |
download | kube-142cfea2ee8b50b5ef2e22b9de4fe4c461411ff2.tar.gz kube-142cfea2ee8b50b5ef2e22b9de4fe4c461411ff2.zip |
Use a ScrollHelper to fix scrolling on listviews
Because the standard scrolling is so unusable depending on the input
device we replace it by something custom that is fairly similar to what
QQC1 ScrollView did. Using a ScrollView sucks in many ways, including
that you have to wrap all sorts of things which is just code wise not
great at all. The ScrollHelper can instead be attached to any existing
flickable to override it's scrolling behaviour, so we can also silently
drop it once the default flickable behaviour starts to make sense.
Diffstat (limited to 'framework/qml/ListView.qml')
-rw-r--r-- | framework/qml/ListView.qml | 29 |
1 files changed, 3 insertions, 26 deletions
diff --git a/framework/qml/ListView.qml b/framework/qml/ListView.qml index f137d03e..161fe48e 100644 --- a/framework/qml/ListView.qml +++ b/framework/qml/ListView.qml | |||
@@ -19,37 +19,14 @@ | |||
19 | 19 | ||
20 | import QtQuick 2.7 | 20 | import QtQuick 2.7 |
21 | import QtQuick.Controls 2 | 21 | import QtQuick.Controls 2 |
22 | import org.kube.framework 1.0 as Kube | ||
22 | 23 | ||
23 | ListView { | 24 | ListView { |
24 | id: root | 25 | id: root |
25 | property var focusProxy: root | ||
26 | 26 | ||
27 | /* | 27 | Kube.ScrollHelper { |
28 | * The MouseArea + interactive: false + maximumFlickVelocity are required | 28 | flickable: root |
29 | * to fix scrolling for desktop systems where we don't want flicking behaviour. | ||
30 | * | ||
31 | * See also: | ||
32 | * ScrollView.qml in qtquickcontrols | ||
33 | * qquickwheelarea.cpp in qtquickcontrols | ||
34 | */ | ||
35 | MouseArea { | ||
36 | anchors.fill: root | 29 | anchors.fill: root |
37 | propagateComposedEvents: true | ||
38 | |||
39 | onWheel: { | ||
40 | //Some trackpads (mine) emit 0 events in between that we can safely ignore. | ||
41 | if (wheel.pixelDelta.y) { | ||
42 | //120 is apparently the factor used in windows(https://chromium.googlesource.com/chromium/src/+/70763eb93a32555910a3b4269aeec51252ab9ec6/ui/events/event.cc) | ||
43 | listView.flick(0, wheel.pixelDelta.y * 120) | ||
44 | } else if (wheel.angleDelta.y) { | ||
45 | //Arbitrary but this seems to work for me... | ||
46 | listView.flick(0, wheel.angleDelta.y * 10) | ||
47 | } | ||
48 | } | ||
49 | } | 30 | } |
50 | interactive: false | ||
51 | maximumFlickVelocity: 100000 | ||
52 | |||
53 | boundsBehavior: Flickable.StopAtBounds | ||
54 | } | 31 | } |
55 | 32 | ||