From 142cfea2ee8b50b5ef2e22b9de4fe4c461411ff2 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 14 Jul 2017 00:02:33 +0200 Subject: 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. --- framework/qml/ListView.qml | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'framework/qml/ListView.qml') 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 @@ import QtQuick 2.7 import QtQuick.Controls 2 +import org.kube.framework 1.0 as Kube ListView { id: root - property var focusProxy: root - /* - * The MouseArea + interactive: false + maximumFlickVelocity are required - * to fix scrolling for desktop systems where we don't want flicking behaviour. - * - * See also: - * ScrollView.qml in qtquickcontrols - * qquickwheelarea.cpp in qtquickcontrols - */ - MouseArea { + Kube.ScrollHelper { + flickable: root anchors.fill: root - propagateComposedEvents: true - - onWheel: { - //Some trackpads (mine) emit 0 events in between that we can safely ignore. - if (wheel.pixelDelta.y) { - //120 is apparently the factor used in windows(https://chromium.googlesource.com/chromium/src/+/70763eb93a32555910a3b4269aeec51252ab9ec6/ui/events/event.cc) - listView.flick(0, wheel.pixelDelta.y * 120) - } else if (wheel.angleDelta.y) { - //Arbitrary but this seems to work for me... - listView.flick(0, wheel.angleDelta.y * 10) - } - } } - interactive: false - maximumFlickVelocity: 100000 - - boundsBehavior: Flickable.StopAtBounds } -- cgit v1.2.3