Make the explore page search loading process more obvious
Adds progress bars, lots of them! Now it's easier to tell if NeoChat is trying it's best to load the public room list.
This commit is contained in:
@@ -41,6 +41,7 @@ void PublicRoomListModel::setConnection(Connection *conn)
|
|||||||
if (job) {
|
if (job) {
|
||||||
job->abandon();
|
job->abandon();
|
||||||
job = nullptr;
|
job = nullptr;
|
||||||
|
Q_EMIT loadingChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_connection) {
|
if (m_connection) {
|
||||||
@@ -70,12 +71,14 @@ void PublicRoomListModel::setServer(const QString &value)
|
|||||||
nextBatch = "";
|
nextBatch = "";
|
||||||
attempted = false;
|
attempted = false;
|
||||||
rooms.clear();
|
rooms.clear();
|
||||||
|
Q_EMIT loadingChanged();
|
||||||
|
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
||||||
if (job) {
|
if (job) {
|
||||||
job->abandon();
|
job->abandon();
|
||||||
job = nullptr;
|
job = nullptr;
|
||||||
|
Q_EMIT loadingChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_connection) {
|
if (m_connection) {
|
||||||
@@ -110,6 +113,7 @@ void PublicRoomListModel::setKeyword(const QString &value)
|
|||||||
if (job) {
|
if (job) {
|
||||||
job->abandon();
|
job->abandon();
|
||||||
job = nullptr;
|
job = nullptr;
|
||||||
|
Q_EMIT loadingChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_connection) {
|
if (m_connection) {
|
||||||
@@ -133,6 +137,7 @@ void PublicRoomListModel::next(int count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
job = m_connection->callApi<QueryPublicRoomsJob>(m_server, count, nextBatch, QueryPublicRoomsJob::Filter{m_keyword, {}});
|
job = m_connection->callApi<QueryPublicRoomsJob>(m_server, count, nextBatch, QueryPublicRoomsJob::Filter{m_keyword, {}});
|
||||||
|
Q_EMIT loadingChanged();
|
||||||
|
|
||||||
connect(job, &BaseJob::finished, this, [this] {
|
connect(job, &BaseJob::finished, this, [this] {
|
||||||
attempted = true;
|
attempted = true;
|
||||||
@@ -150,6 +155,7 @@ void PublicRoomListModel::next(int count)
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->job = nullptr;
|
this->job = nullptr;
|
||||||
|
Q_EMIT loadingChanged();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,4 +259,9 @@ bool PublicRoomListModel::hasMore() const
|
|||||||
return !(attempted && nextBatch.isEmpty());
|
return !(attempted && nextBatch.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PublicRoomListModel::loading() const
|
||||||
|
{
|
||||||
|
return (job != nullptr) || isJobPending(job);
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_publicroomlistmodel.cpp"
|
#include "moc_publicroomlistmodel.cpp"
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ class PublicRoomListModel : public QAbstractListModel
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(bool hasMore READ hasMore NOTIFY hasMoreChanged)
|
Q_PROPERTY(bool hasMore READ hasMore NOTIFY hasMoreChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @biref Whether the model is still loading.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(bool loading READ loading NOTIFY loadingChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Defines the model roles.
|
* @brief Defines the model roles.
|
||||||
@@ -98,6 +103,8 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] bool hasMore() const;
|
[[nodiscard]] bool hasMore() const;
|
||||||
|
|
||||||
|
[[nodiscard]] bool loading() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Load the next set of rooms.
|
* @brief Load the next set of rooms.
|
||||||
*
|
*
|
||||||
@@ -111,6 +118,7 @@ private:
|
|||||||
QString m_keyword;
|
QString m_keyword;
|
||||||
|
|
||||||
bool attempted = false;
|
bool attempted = false;
|
||||||
|
bool m_loading = false;
|
||||||
QString nextBatch;
|
QString nextBatch;
|
||||||
|
|
||||||
QVector<Quotient::PublicRoomsChunk> rooms;
|
QVector<Quotient::PublicRoomsChunk> rooms;
|
||||||
@@ -122,4 +130,5 @@ Q_SIGNALS:
|
|||||||
void serverChanged();
|
void serverChanged();
|
||||||
void keywordChanged();
|
void keywordChanged();
|
||||||
void hasMoreChanged();
|
void hasMoreChanged();
|
||||||
|
void loadingChanged();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import QtQuick.Controls 2.15 as QQC2
|
|||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
import Qt.labs.qmlmodels 1.0
|
import Qt.labs.qmlmodels 1.0
|
||||||
|
|
||||||
import org.kde.kirigami 2.15 as Kirigami
|
import org.kde.kirigami 2.19 as Kirigami
|
||||||
import org.kde.kirigamiaddons.labs.components 1.0 as KirigamiComponents
|
import org.kde.kirigamiaddons.labs.components 1.0 as KirigamiComponents
|
||||||
|
|
||||||
import org.kde.neochat 1.0
|
import org.kde.neochat 1.0
|
||||||
@@ -255,5 +255,25 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footer: RowLayout {
|
||||||
|
width: parent.width
|
||||||
|
|
||||||
|
QQC2.ProgressBar {
|
||||||
|
visible: publicRoomsListView.model.loading && publicRoomsListView.count !== 0
|
||||||
|
indeterminate: true
|
||||||
|
padding: Kirigami.Units.largeSpacing * 2
|
||||||
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||||
|
Layout.topMargin: Kirigami.Units.largeSpacing
|
||||||
|
Layout.bottomMargin: Kirigami.Units.largeSpacing
|
||||||
|
Layout.leftMargin: Kirigami.Units.largeSpacing
|
||||||
|
Layout.rightMargin: Kirigami.Units.largeSpacing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Kirigami.LoadingPlaceholder {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: publicRoomsListView.model.loading && publicRoomsListView.count === 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user