Use AutoListView.

Fixes #84.
This commit is contained in:
Black Hat 2018-10-15 09:56:30 +08:00
parent 3d104ddccc
commit 1c3fcef542
11 changed files with 18 additions and 23 deletions

View File

@ -0,0 +1,9 @@
import QtQuick 2.9
ListView {
ScrollHelper {
anchors.fill: parent
flickable: parent
}
}

View File

@ -13,7 +13,6 @@ MouseArea {
flickable.interactive = false flickable.interactive = false
flickable.maximumFlickVelocity = 100000 flickable.maximumFlickVelocity = 100000
flickable.boundsBehavior = Flickable.StopAtBounds flickable.boundsBehavior = Flickable.StopAtBounds
root.parent = flickable
} }
function scrollByPixelDelta(flickableItem, pixelDelta) { function scrollByPixelDelta(flickableItem, pixelDelta) {

View File

@ -6,3 +6,4 @@ AutoImage 2.0 AutoImage.qml
AutoLabel 2.0 AutoLabel.qml AutoLabel 2.0 AutoLabel.qml
AutoTextArea 2.0 AutoTextArea.qml AutoTextArea 2.0 AutoTextArea.qml
ScrollHelper 2.0 ScrollHelper.qml ScrollHelper 2.0 ScrollHelper.qml
AutoListView 2.0 AutoListView.qml

View File

@ -52,7 +52,7 @@ Column {
clip: true clip: true
ListView { AutoListView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 24 Layout.preferredHeight: 24

View File

@ -27,7 +27,7 @@ Page {
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
ListView { AutoListView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true

View File

@ -100,7 +100,7 @@ Drawer {
} }
} }
ListView { AutoListView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true

View File

@ -94,7 +94,7 @@ Rectangle {
] ]
} }
ListView { AutoListView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
@ -102,7 +102,6 @@ Rectangle {
spacing: 1 spacing: 1
clip: true clip: true
interactive: false
model: roomListProxyModel model: roomListProxyModel
@ -137,12 +136,6 @@ Rectangle {
} }
RoomContextMenu { id: roomContextMenu } RoomContextMenu { id: roomContextMenu }
ScrollHelper {
anchors.fill: parent
flickable: parent
}
} }
} }
} }

View File

@ -21,7 +21,6 @@ RoomPanelForm {
property int largestVisibleIndex: messageListView.count > 0 ? messageListView.indexAt(messageListView.contentX, messageListView.contentY + messageListView.height - 1) : -1 property int largestVisibleIndex: messageListView.count > 0 ? messageListView.indexAt(messageListView.contentX, messageListView.contentY + messageListView.height - 1) : -1
onContentYChanged: { onContentYChanged: {
console.log("Content Y changed.")
if(currentRoom && messageListView.contentY - 5000 < messageListView.originY) if(currentRoom && messageListView.contentY - 5000 < messageListView.originY)
currentRoom.getPreviousContent(50); currentRoom.getPreviousContent(50);
} }

View File

@ -65,7 +65,7 @@ Item {
id: roomHeader id: roomHeader
} }
ListView { AutoListView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
Layout.leftMargin: 16 Layout.leftMargin: 16
@ -77,7 +77,6 @@ Item {
displayMarginEnd: 40 displayMarginEnd: 40
verticalLayoutDirection: ListView.BottomToTop verticalLayoutDirection: ListView.BottomToTop
spacing: 8 spacing: 8
interactive: false
boundsBehavior: Flickable.DragOverBounds boundsBehavior: Flickable.DragOverBounds
@ -157,12 +156,6 @@ Item {
} }
} }
ScrollHelper {
anchors.fill: parent
flickable: parent
}
RoundButton { RoundButton {
width: 64 width: 64
height: 64 height: 64
@ -230,7 +223,7 @@ Item {
closePolicy: Dialog.CloseOnEscape | Dialog.CloseOnPressOutside closePolicy: Dialog.CloseOnEscape | Dialog.CloseOnPressOutside
contentItem: ListView { contentItem: AutoListView {
implicitHeight: Math.min(window.height - 64, implicitHeight: Math.min(window.height - 64,
readMarkerListView.contentHeight) readMarkerListView.contentHeight)

View File

@ -101,7 +101,7 @@ ApplicationWindow {
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0
ListView { AutoListView {
property var currentConnection: null property var currentConnection: null
Layout.fillWidth: true Layout.fillWidth: true

View File

@ -52,5 +52,6 @@
<file>imports/Spectral/Component/AutoLabel.qml</file> <file>imports/Spectral/Component/AutoLabel.qml</file>
<file>imports/Spectral/Component/AutoTextArea.qml</file> <file>imports/Spectral/Component/AutoTextArea.qml</file>
<file>imports/Spectral/Component/ScrollHelper.qml</file> <file>imports/Spectral/Component/ScrollHelper.qml</file>
<file>imports/Spectral/Component/AutoListView.qml</file>
</qresource> </qresource>
</RCC> </RCC>