From 0e34fce4a244ec2d023c3e6a2aa2a99a5c051b01 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Sun, 5 Aug 2018 00:15:58 +0800 Subject: [PATCH] Rearrange scroll bar. Fixes #3. --- qml/form/RoomForm.qml | 122 +++++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 54 deletions(-) diff --git a/qml/form/RoomForm.qml b/qml/form/RoomForm.qml index 4d4d2f0..3c672fc 100644 --- a/qml/form/RoomForm.qml +++ b/qml/form/RoomForm.qml @@ -74,75 +74,89 @@ Item { } } - ListView { - id: messageListView - - z: -10 + RowLayout { Layout.fillWidth: true Layout.fillHeight: true Layout.leftMargin: 16 - Layout.rightMargin: 16 - displayMarginBeginning: 40 - displayMarginEnd: 40 - verticalLayoutDirection: ListView.BottomToTop - spacing: 8 - boundsBehavior: Flickable.DragOverBounds + z: -10 - model: MessageEventModel{ - id: messageEventModel - room: currentRoom - } + spacing: 0 - delegate: MessageDelegate {} + ListView { + id: messageListView - section.property: "section" - section.criteria: ViewSection.FullString - section.delegate: RowLayout { - width: parent.width * 0.6 - anchors.right: parent.right + Layout.fillWidth: true + Layout.fillHeight: true + displayMarginBeginning: 40 + displayMarginEnd: 40 + verticalLayoutDirection: ListView.BottomToTop + spacing: 8 - Rectangle { - Layout.fillWidth: true - height:2 - color: Material.accent + boundsBehavior: Flickable.DragOverBounds + + model: MessageEventModel{ + id: messageEventModel + room: currentRoom } - Label { - padding: 4 - text: section - color: Material.accent - verticalAlignment: Text.AlignVCenter + delegate: MessageDelegate {} + + section.property: "section" + section.criteria: ViewSection.FullString + section.delegate: RowLayout { + width: parent.width * 0.6 + anchors.right: parent.right + + Rectangle { + Layout.fillWidth: true + height:2 + color: Material.accent + } + + Label { + padding: 4 + text: section + color: Material.accent + verticalAlignment: Text.AlignVCenter + } + } + + ScrollBar.vertical: messageListViewScrollBar + + onAtYBeginningChanged: atYBeginning && currentRoom ? currentRoom.getPreviousContent(50) : {} + onAtYEndChanged: atYEnd && currentRoom ? currentRoom.markAllMessagesAsRead() : {} + + RoundButton { + id: goTopFab + width: height + height: 64 + visible: !parent.atYEnd + + anchors.right: parent.right + anchors.bottom: parent.bottom + + contentItem: MaterialIcon { + anchors.fill: parent + icon: "\ue313" + color: "white" + } + + opacity: pressed ? 1 : hovered ? 0.7 : 0.4 + Material.background: Qt.lighter(Material.accent) + + onClicked: parent.positionViewAtBeginning() + + Behavior on opacity { NumberAnimation { duration: 200 } } } } - onAtYBeginningChanged: atYBeginning && currentRoom ? currentRoom.getPreviousContent(50) : {} - onAtYEndChanged: atYEnd && currentRoom ? currentRoom.markAllMessagesAsRead() : {} + ScrollBar { + id: messageListViewScrollBar - ScrollBar.vertical: ScrollBar {} - - RoundButton { - id: goTopFab - width: height - height: 64 - visible: !parent.atYEnd - - anchors.right: parent.right - anchors.bottom: parent.bottom - - contentItem: MaterialIcon { - anchors.fill: parent - icon: "\ue313" - color: "white" - } - - opacity: pressed ? 1 : hovered ? 0.7 : 0.4 - Material.background: Qt.lighter(Material.accent) - - onClicked: parent.positionViewAtBeginning() - - Behavior on opacity { NumberAnimation { duration: 200 } } + Layout.preferredWidth: 16 + Layout.fillHeight: true } }