From 1c3fcef5423db32c971782bc76586d759101c77f Mon Sep 17 00:00:00 2001 From: Black Hat Date: Mon, 15 Oct 2018 09:56:30 +0800 Subject: [PATCH] Use AutoListView. Fixes #84. --- imports/Spectral/Component/AutoListView.qml | 9 +++++++++ imports/Spectral/Component/ScrollHelper.qml | 1 - imports/Spectral/Component/qmldir | 1 + imports/Spectral/Page/SettingAccountDelegate.qml | 2 +- imports/Spectral/Page/SettingForm.ui.qml | 2 +- imports/Spectral/Panel/RoomDrawer.qml | 2 +- imports/Spectral/Panel/RoomListPanelForm.ui.qml | 9 +-------- imports/Spectral/Panel/RoomPanel.qml | 1 - imports/Spectral/Panel/RoomPanelForm.ui.qml | 11 ++--------- qml/main.qml | 2 +- res.qrc | 1 + 11 files changed, 18 insertions(+), 23 deletions(-) create mode 100644 imports/Spectral/Component/AutoListView.qml diff --git a/imports/Spectral/Component/AutoListView.qml b/imports/Spectral/Component/AutoListView.qml new file mode 100644 index 0000000..2b6bddb --- /dev/null +++ b/imports/Spectral/Component/AutoListView.qml @@ -0,0 +1,9 @@ +import QtQuick 2.9 + +ListView { + ScrollHelper { + anchors.fill: parent + + flickable: parent + } +} diff --git a/imports/Spectral/Component/ScrollHelper.qml b/imports/Spectral/Component/ScrollHelper.qml index a611527..923a141 100644 --- a/imports/Spectral/Component/ScrollHelper.qml +++ b/imports/Spectral/Component/ScrollHelper.qml @@ -13,7 +13,6 @@ MouseArea { flickable.interactive = false flickable.maximumFlickVelocity = 100000 flickable.boundsBehavior = Flickable.StopAtBounds - root.parent = flickable } function scrollByPixelDelta(flickableItem, pixelDelta) { diff --git a/imports/Spectral/Component/qmldir b/imports/Spectral/Component/qmldir index 90ce0ea..a9bbe45 100644 --- a/imports/Spectral/Component/qmldir +++ b/imports/Spectral/Component/qmldir @@ -6,3 +6,4 @@ AutoImage 2.0 AutoImage.qml AutoLabel 2.0 AutoLabel.qml AutoTextArea 2.0 AutoTextArea.qml ScrollHelper 2.0 ScrollHelper.qml +AutoListView 2.0 AutoListView.qml diff --git a/imports/Spectral/Page/SettingAccountDelegate.qml b/imports/Spectral/Page/SettingAccountDelegate.qml index 2c0a116..a59b1ee 100644 --- a/imports/Spectral/Page/SettingAccountDelegate.qml +++ b/imports/Spectral/Page/SettingAccountDelegate.qml @@ -52,7 +52,7 @@ Column { clip: true - ListView { + AutoListView { Layout.fillWidth: true Layout.preferredHeight: 24 diff --git a/imports/Spectral/Page/SettingForm.ui.qml b/imports/Spectral/Page/SettingForm.ui.qml index a5d1e12..2355730 100644 --- a/imports/Spectral/Page/SettingForm.ui.qml +++ b/imports/Spectral/Page/SettingForm.ui.qml @@ -27,7 +27,7 @@ Page { ColumnLayout { anchors.fill: parent - ListView { + AutoListView { Layout.fillWidth: true Layout.fillHeight: true diff --git a/imports/Spectral/Panel/RoomDrawer.qml b/imports/Spectral/Panel/RoomDrawer.qml index 17d8871..fd80940 100644 --- a/imports/Spectral/Panel/RoomDrawer.qml +++ b/imports/Spectral/Panel/RoomDrawer.qml @@ -100,7 +100,7 @@ Drawer { } } - ListView { + AutoListView { Layout.fillWidth: true Layout.fillHeight: true diff --git a/imports/Spectral/Panel/RoomListPanelForm.ui.qml b/imports/Spectral/Panel/RoomListPanelForm.ui.qml index 3b555de..60ef9b3 100644 --- a/imports/Spectral/Panel/RoomListPanelForm.ui.qml +++ b/imports/Spectral/Panel/RoomListPanelForm.ui.qml @@ -94,7 +94,7 @@ Rectangle { ] } - ListView { + AutoListView { Layout.fillWidth: true Layout.fillHeight: true @@ -102,7 +102,6 @@ Rectangle { spacing: 1 clip: true - interactive: false model: roomListProxyModel @@ -137,12 +136,6 @@ Rectangle { } RoomContextMenu { id: roomContextMenu } - - ScrollHelper { - anchors.fill: parent - - flickable: parent - } } } } diff --git a/imports/Spectral/Panel/RoomPanel.qml b/imports/Spectral/Panel/RoomPanel.qml index bcb58f4..a33ea1e 100644 --- a/imports/Spectral/Panel/RoomPanel.qml +++ b/imports/Spectral/Panel/RoomPanel.qml @@ -21,7 +21,6 @@ RoomPanelForm { property int largestVisibleIndex: messageListView.count > 0 ? messageListView.indexAt(messageListView.contentX, messageListView.contentY + messageListView.height - 1) : -1 onContentYChanged: { - console.log("Content Y changed.") if(currentRoom && messageListView.contentY - 5000 < messageListView.originY) currentRoom.getPreviousContent(50); } diff --git a/imports/Spectral/Panel/RoomPanelForm.ui.qml b/imports/Spectral/Panel/RoomPanelForm.ui.qml index 42a8506..2256ea0 100644 --- a/imports/Spectral/Panel/RoomPanelForm.ui.qml +++ b/imports/Spectral/Panel/RoomPanelForm.ui.qml @@ -65,7 +65,7 @@ Item { id: roomHeader } - ListView { + AutoListView { Layout.fillWidth: true Layout.fillHeight: true Layout.leftMargin: 16 @@ -77,7 +77,6 @@ Item { displayMarginEnd: 40 verticalLayoutDirection: ListView.BottomToTop spacing: 8 - interactive: false boundsBehavior: Flickable.DragOverBounds @@ -157,12 +156,6 @@ Item { } } - ScrollHelper { - anchors.fill: parent - - flickable: parent - } - RoundButton { width: 64 height: 64 @@ -230,7 +223,7 @@ Item { closePolicy: Dialog.CloseOnEscape | Dialog.CloseOnPressOutside - contentItem: ListView { + contentItem: AutoListView { implicitHeight: Math.min(window.height - 64, readMarkerListView.contentHeight) diff --git a/qml/main.qml b/qml/main.qml index 1d738d5..1251aa5 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -101,7 +101,7 @@ ApplicationWindow { anchors.fill: parent spacing: 0 - ListView { + AutoListView { property var currentConnection: null Layout.fillWidth: true diff --git a/res.qrc b/res.qrc index f0cd070..66b41dd 100644 --- a/res.qrc +++ b/res.qrc @@ -52,5 +52,6 @@ imports/Spectral/Component/AutoLabel.qml imports/Spectral/Component/AutoTextArea.qml imports/Spectral/Component/ScrollHelper.qml + imports/Spectral/Component/AutoListView.qml