From d033ea84e8ae23b9afb25f3fce4b486da1314ef4 Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 20 Jul 2019 15:06:38 -0400 Subject: [PATCH] Add scrollbars to flickable and listviews --- src/qml/Base/HFixedListView.qml | 28 +++++++++++++++++++++++ src/qml/Base/HFlickable.qml | 10 ++++++++ src/qml/Base/HListView.qml | 23 ++++--------------- src/qml/Base/HPage.qml | 3 +-- src/qml/SidePane/AccountDelegate.qml | 1 - src/qml/SidePane/RoomCategoriesList.qml | 2 +- src/qml/SidePane/RoomCategoryDelegate.qml | 1 - src/qml/SidePane/RoomList.qml | 2 +- 8 files changed, 45 insertions(+), 25 deletions(-) create mode 100644 src/qml/Base/HFixedListView.qml create mode 100644 src/qml/Base/HFlickable.qml diff --git a/src/qml/Base/HFixedListView.qml b/src/qml/Base/HFixedListView.qml new file mode 100644 index 00000000..4c9f74d0 --- /dev/null +++ b/src/qml/Base/HFixedListView.qml @@ -0,0 +1,28 @@ +// Copyright 2019 miruka +// This file is part of harmonyqml, licensed under LGPLv3. + +import QtQuick 2.12 +import QtQuick.Controls 2.12 + +ListView { + add: Transition { + HNumberAnimation { properties: "x,y"; from: 100 } + } + + move: Transition { + HNumberAnimation { properties: "x,y" } + } + + displaced: Transition { + HNumberAnimation { properties: "x,y" } + } + + remove: Transition { + ParallelAnimation { + HNumberAnimation { property: "opacity"; to: 0 } + HNumberAnimation { properties: "x,y"; to: 100 } + } + } + + interactive: false +} diff --git a/src/qml/Base/HFlickable.qml b/src/qml/Base/HFlickable.qml new file mode 100644 index 00000000..413bbbc9 --- /dev/null +++ b/src/qml/Base/HFlickable.qml @@ -0,0 +1,10 @@ +// Copyright 2019 miruka +// This file is part of harmonyqml, licensed under LGPLv3. + +import QtQuick 2.12 +import QtQuick.Controls 2.12 + +Flickable { + interactive: contentWidth > width || contentHeight > height + ScrollBar.vertical: ScrollBar {} +} diff --git a/src/qml/Base/HListView.qml b/src/qml/Base/HListView.qml index 10eecf75..16f09e4e 100644 --- a/src/qml/Base/HListView.qml +++ b/src/qml/Base/HListView.qml @@ -2,24 +2,9 @@ // This file is part of harmonyqml, licensed under LGPLv3. import QtQuick 2.12 +import QtQuick.Controls 2.12 -ListView { - add: Transition { - HNumberAnimation { properties: "x,y"; from: 100 } - } - - move: Transition { - HNumberAnimation { properties: "x,y" } - } - - displaced: Transition { - HNumberAnimation { properties: "x,y" } - } - - remove: Transition { - ParallelAnimation { - HNumberAnimation { property: "opacity"; to: 0 } - HNumberAnimation { properties: "x,y"; to: 100 } - } - } +HFixedListView { + interactive: true + ScrollBar.vertical: ScrollBar {} } diff --git a/src/qml/Base/HPage.qml b/src/qml/Base/HPage.qml index d3279bf3..e1c610f4 100644 --- a/src/qml/Base/HPage.qml +++ b/src/qml/Base/HPage.qml @@ -72,13 +72,12 @@ SwipeView { rightPadding: leftPadding Behavior on leftPadding { HNumberAnimation {} } - Flickable { + HFlickable { id: innerFlickable anchors.fill: parent clip: true contentWidth: parent.width contentHeight: contentColumn.childrenRect.height - interactive: contentWidth > width || contentHeight > height HColumnLayout { id: contentColumn diff --git a/src/qml/SidePane/AccountDelegate.qml b/src/qml/SidePane/AccountDelegate.qml index 03763aa5..99818452 100644 --- a/src/qml/SidePane/AccountDelegate.qml +++ b/src/qml/SidePane/AccountDelegate.qml @@ -81,7 +81,6 @@ Column { RoomCategoriesList { id: roomCategoriesList - interactive: false // no scrolling visible: height > 0 width: parent.width height: childrenRect.height * (accountDelegate.expanded ? 1 : 0) diff --git a/src/qml/SidePane/RoomCategoriesList.qml b/src/qml/SidePane/RoomCategoriesList.qml index 9ac7e498..3b9bb19e 100644 --- a/src/qml/SidePane/RoomCategoriesList.qml +++ b/src/qml/SidePane/RoomCategoriesList.qml @@ -6,7 +6,7 @@ import QtQuick.Layouts 1.12 import SortFilterProxyModel 0.2 import "../Base" -HListView { +HFixedListView { property string userId: "" id: roomCategoriesList diff --git a/src/qml/SidePane/RoomCategoryDelegate.qml b/src/qml/SidePane/RoomCategoryDelegate.qml index 15e003c6..f2bcfdfc 100644 --- a/src/qml/SidePane/RoomCategoryDelegate.qml +++ b/src/qml/SidePane/RoomCategoryDelegate.qml @@ -41,7 +41,6 @@ Column { RoomList { id: roomList - interactive: false // no scrolling visible: height > 0 width: roomCategoriesList.width - accountList.Layout.leftMargin opacity: roomCategoryDelegate.expanded ? 1 : 0 diff --git a/src/qml/SidePane/RoomList.qml b/src/qml/SidePane/RoomList.qml index 413df8a8..f471fafc 100644 --- a/src/qml/SidePane/RoomList.qml +++ b/src/qml/SidePane/RoomList.qml @@ -7,7 +7,7 @@ import SortFilterProxyModel 0.2 import "../Base" import "../utils.js" as Utils -HListView { +HFixedListView { id: roomList property string userId: ""