From a69943e0420acb2c632465b67bfe81dcdefc454e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Wed, 7 Apr 2021 11:09:03 -0400
Subject: [PATCH] listviews: fixed max scroll speed

Change-Id: I29633415aa15379743c0a2a8f2274e33b75e3f39
GitLab: #288
---
 src/commoncomponents/ListViewJami.qml               |  1 +
 .../components/ConversationSmartListView.qml        |  1 +
 src/settingsview/SettingsView.qml                   | 13 +++++--------
 .../components/CurrentAccountSettings.qml           |  2 +-
 .../components/PluginListPreferencesView.qml        |  2 ++
 .../components/PluginListSettingsView.qml           |  1 +
 6 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/commoncomponents/ListViewJami.qml b/src/commoncomponents/ListViewJami.qml
index 926555ad3..2ad1f62f1 100644
--- a/src/commoncomponents/ListViewJami.qml
+++ b/src/commoncomponents/ListViewJami.qml
@@ -44,6 +44,7 @@ Rectangle {
         visible: listViewBackground.visible
         layer.mipmap: false
         clip: true
+        maximumFlickVelocity: 1024
 
         ScrollIndicator.vertical: ScrollIndicator {}
     }
diff --git a/src/mainview/components/ConversationSmartListView.qml b/src/mainview/components/ConversationSmartListView.qml
index 7fc6dad12..a4f4dda5a 100644
--- a/src/mainview/components/ConversationSmartListView.qml
+++ b/src/mainview/components/ConversationSmartListView.qml
@@ -89,6 +89,7 @@ ListView {
     }
 
     clip: true
+    maximumFlickVelocity: 1024
 
     delegate: ConversationSmartListViewItemDelegate {
         id: smartListItemDelegate
diff --git a/src/settingsview/SettingsView.qml b/src/settingsview/SettingsView.qml
index 4ac5b063a..775f581f7 100644
--- a/src/settingsview/SettingsView.qml
+++ b/src/settingsview/SettingsView.qml
@@ -162,19 +162,17 @@ Rectangle {
             onBackArrowClicked: root.settingsBackArrowClicked()
         }
 
-        ScrollView {
+        Flickable {
             id: settingsViewScrollView
 
-            property ScrollBar vScrollBar: ScrollBar.vertical
-
             anchors.top: settingsHeader.bottom
             anchors.horizontalCenter: settingsViewRect.horizontalCenter
 
             height: settingsViewRect.height - settingsHeader.height
             width: settingsViewRect.width
 
-            ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
-            ScrollBar.vertical.policy: ScrollBar.AsNeeded
+            maximumFlickVelocity: 1024
+            ScrollIndicator.vertical: ScrollIndicator {}
 
             clip: true
             contentHeight: rightSettingsStackLayout.height
@@ -231,10 +229,9 @@ Rectangle {
 
                     onAdvancedSettingsToggled: {
                         if (settingsVisible)
-                            settingsViewScrollView.vScrollBar.position =
-                                    getAdvancedSettingsScrollPosition()
+                            settingsViewScrollView.contentY = getAdvancedSettingsScrollPosition()
                         else
-                            settingsViewScrollView.vScrollBar.position = 0
+                            settingsViewScrollView.contentY = 0
                     }
                 }
 
diff --git a/src/settingsview/components/CurrentAccountSettings.qml b/src/settingsview/components/CurrentAccountSettings.qml
index cb8bc7853..457814ad3 100644
--- a/src/settingsview/components/CurrentAccountSettings.qml
+++ b/src/settingsview/components/CurrentAccountSettings.qml
@@ -85,7 +85,7 @@ Rectangle {
     }
 
     function getAdvancedSettingsScrollPosition() {
-        return advancedSettings.y / root.height
+        return advancedSettings.y
     }
 
     function setPasswordButtonText() {
diff --git a/src/settingsview/components/PluginListPreferencesView.qml b/src/settingsview/components/PluginListPreferencesView.qml
index e22596ca3..3fffe8750 100644
--- a/src/settingsview/components/PluginListPreferencesView.qml
+++ b/src/settingsview/components/PluginListPreferencesView.qml
@@ -276,6 +276,7 @@ Rectangle {
 
                     model: PluginAdapter.getPluginPreferencesModel(root.pluginId, root.category)
                     interactive: false
+                    maximumFlickVelocity: 1024
 
                     delegate: PreferenceItemDelegate {
                         id: preferenceItemDelegateCategory
@@ -325,6 +326,7 @@ Rectangle {
 
             model: PluginAdapter.getPluginPreferencesModel(root.pluginId)
             interactive: false
+            maximumFlickVelocity: 1024
 
             delegate: PreferenceItemDelegate {
                 id: preferenceItemDelegate
diff --git a/src/settingsview/components/PluginListSettingsView.qml b/src/settingsview/components/PluginListSettingsView.qml
index 95e303401..07b31c633 100644
--- a/src/settingsview/components/PluginListSettingsView.qml
+++ b/src/settingsview/components/PluginListSettingsView.qml
@@ -124,6 +124,7 @@ Rectangle {
             Layout.bottomMargin: 10
 
             model: PluginAdapter.getPluginSelectableModel()
+            maximumFlickVelocity: 1024
 
             delegate: PluginItemDelegate {
                 id: pluginItemDelegate
-- 
GitLab