summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-12 03:56:53 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-07-12 03:58:25 +0200
commitc7d0845fb34d7ccea3b754c6bc9cbbc391bfa12d (patch)
treee1f8e2394de59e8f4350ff4fde5f9c40d4363cd7
parent03d607e379ac9fe48315ce121ada76338ed6686d (diff)
downloadkube-c7d0845fb34d7ccea3b754c6bc9cbbc391bfa12d.tar.gz
kube-c7d0845fb34d7ccea3b754c6bc9cbbc391bfa12d.zip
A listview with sane scrolling
-rw-r--r--framework/qml/ConversationView.qml8
-rw-r--r--framework/qml/ListView.qml51
-rw-r--r--framework/qmldir1
3 files changed, 54 insertions, 6 deletions
diff --git a/framework/qml/ConversationView.qml b/framework/qml/ConversationView.qml
index 2f499752..9c21b470 100644
--- a/framework/qml/ConversationView.qml
+++ b/framework/qml/ConversationView.qml
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> 2 * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsystems.com>
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -59,7 +60,7 @@ Rectangle {
59 60
60 color: Kube.Colors.backgroundColor 61 color: Kube.Colors.backgroundColor
61 62
62 ListView { 63 Kube.ListView {
63 id: listView 64 id: listView
64 65
65 anchors.fill: parent 66 anchors.fill: parent
@@ -110,11 +111,6 @@ Rectangle {
110 //Setting the currentIndex results in further lags. So we don't do that either. 111 //Setting the currentIndex results in further lags. So we don't do that either.
111 // currentIndex: root.currentIndex 112 // currentIndex: root.currentIndex
112 113
113 boundsBehavior: Flickable.StopAtBounds
114
115 //default is 1500, which is not usable with a mouse
116 flickDeceleration: 1500
117
118 //Optimize for view quality 114 //Optimize for view quality
119 pixelAligned: true 115 pixelAligned: true
120 116
diff --git a/framework/qml/ListView.qml b/framework/qml/ListView.qml
new file mode 100644
index 00000000..7fbb5721
--- /dev/null
+++ b/framework/qml/ListView.qml
@@ -0,0 +1,51 @@
1/*
2 * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsystems.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20import QtQuick 2.7
21import QtQuick.Controls 2
22
23ListView {
24 id: root
25 property var focusProxy: root
26
27 /*
28 * The MouseArea + interactive: false + maximumFlickVelocity are required
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
37 propagateComposedEvents: true
38
39 onWheel: {
40 //Some trackpads (mine) emit 0 events in between that we can safely ignore.
41 if (wheel.angleDelta.y) {
42 listView.flick(0, wheel.angleDelta.y * 40)
43 }
44 }
45 }
46 interactive: false
47 maximumFlickVelocity: 100000
48
49 boundsBehavior: Flickable.StopAtBounds
50}
51
diff --git a/framework/qmldir b/framework/qmldir
index 0e7768c4..b8e7345f 100644
--- a/framework/qmldir
+++ b/framework/qmldir
@@ -29,6 +29,7 @@ Heading 1.0 Heading.qml
29View 1.0 View.qml 29View 1.0 View.qml
30AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml 30AutocompleteLineEdit 1.0 AutocompleteLineEdit.qml
31AttachmentDelegate 1.0 AttachmentDelegate.qml 31AttachmentDelegate 1.0 AttachmentDelegate.qml
32ListView 1.0 ListView.qml
32singleton Messages 1.0 Messages.qml 33singleton Messages 1.0 Messages.qml
33singleton Colors 1.0 Colors.qml 34singleton Colors 1.0 Colors.qml
34singleton Icons 1.0 Icons.qml 35singleton Icons 1.0 Icons.qml