From 1556e569b8dcbfb3fd446749c0c4002fec51cb25 Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 7 Mar 2020 11:11:32 -0400 Subject: [PATCH] Replace room loading bar with an eventList header --- src/gui/Base/HButton.qml | 3 +- src/gui/Pages/Chat/Chat.qml | 1 - src/gui/Pages/Chat/ChatPage.qml | 4 --- src/gui/Pages/Chat/LoadingRoomProgressBar.qml | 13 --------- src/gui/Pages/Chat/Timeline/EventList.qml | 29 +++++++++++++++++-- 5 files changed, 28 insertions(+), 22 deletions(-) delete mode 100644 src/gui/Pages/Chat/LoadingRoomProgressBar.qml diff --git a/src/gui/Base/HButton.qml b/src/gui/Base/HButton.qml index 1ca0fabc..55a5e067 100644 --- a/src/gui/Base/HButton.qml +++ b/src/gui/Base/HButton.qml @@ -32,7 +32,7 @@ Button { background: HButtonBackground { button: button buttonTheme: theme.controls.button - radius: circle ? height : 0 + radius: circle ? height : enableRadius ? theme.radius : 0 color: backgroundColor } @@ -51,6 +51,7 @@ Button { property bool loading: false property bool circle: false property bool padded: true + property bool enableRadius: false property HToolTip toolTip: HToolTip { id: toolTip diff --git a/src/gui/Pages/Chat/Chat.qml b/src/gui/Pages/Chat/Chat.qml index 328e8627..794e9068 100644 --- a/src/gui/Pages/Chat/Chat.qml +++ b/src/gui/Pages/Chat/Chat.qml @@ -17,7 +17,6 @@ Item { property QtObject userInfo: ModelStore.get("accounts").find(userId) property QtObject roomInfo: ModelStore.get(userId, "rooms").find(roomId) - property bool loadingMessages: false property bool ready: Boolean(userInfo && roomInfo) readonly property alias loader: loader diff --git a/src/gui/Pages/Chat/ChatPage.qml b/src/gui/Pages/Chat/ChatPage.qml index 8c525077..f9f01014 100644 --- a/src/gui/Pages/Chat/ChatPage.qml +++ b/src/gui/Pages/Chat/ChatPage.qml @@ -23,10 +23,6 @@ HPage { Layout.fillWidth: true } - LoadingRoomProgressBar { - Layout.fillWidth: true - } - EventList { id: eventList diff --git a/src/gui/Pages/Chat/LoadingRoomProgressBar.qml b/src/gui/Pages/Chat/LoadingRoomProgressBar.qml deleted file mode 100644 index fc78b91d..00000000 --- a/src/gui/Pages/Chat/LoadingRoomProgressBar.qml +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-License-Identifier: LGPL-3.0-or-later - -import QtQuick 2.12 -import QtQuick.Layouts 1.12 -import "../../Base" - -HProgressBar { - indeterminate: true - height: chat.loadingMessages ? implicitHeight : 0 - visible: height > 0 - - Behavior on height { HNumberAnimation {} } -} diff --git a/src/gui/Pages/Chat/Timeline/EventList.qml b/src/gui/Pages/Chat/Timeline/EventList.qml index 08c7add1..4e87fd2a 100644 --- a/src/gui/Pages/Chat/Timeline/EventList.qml +++ b/src/gui/Pages/Chat/Timeline/EventList.qml @@ -1,6 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-later import QtQuick 2.12 +import QtQuick.Layouts 1.12 import "../../.." import "../../../Base" @@ -84,12 +85,34 @@ Rectangle { // fetch past events. onInviterChanged: canLoad = true + // Since the list is BottomToTop, this is actually a header + footer: Item { + width: eventList.width + height: (button.height + theme.spacing * 2) * opacity + opacity: eventList.loading ? 1 : 0 + visible: opacity > 0 + + Behavior on opacity { HNumberAnimation {} } + + HButton { + id: button + width: Math.min(parent.width, implicitWidth) + anchors.centerIn: parent + + loading: true + text: qsTr("Loading previous messages...") + enableRadius: true + iconItem.small: true + } + } + Component.onCompleted: shortcuts.flickTarget = eventList property string inviter: chat.roomInfo.inviter || "" property real yPos: visibleArea.yPosition property bool canLoad: true + property bool loading: false property bool ownEventsOnRight: width < theme.chat.eventList.ownEventsOnRightUnderWidth @@ -130,8 +153,8 @@ Rectangle { // component is destroyed but func is still running try { - eventList.canLoad = false - chat.loadingMessages = true + eventList.canLoad = false + eventList.loading = true py.callClientCoro( chat.userId, @@ -146,7 +169,7 @@ Rectangle { // the screen. if (moreToLoad) yPosChanged() - chat.loadingMessages = false + eventList.loading = false } catch (err) { return }