mirror of
https://github.com/KDE/audiotube.git
synced 2025-12-24 00:18:04 -05:00
Add busy indicator
This commit is contained in:
@@ -37,6 +37,10 @@ Kirigami.ApplicationWindow {
|
||||
delegate: Kirigami.BasicListItem {
|
||||
text: model.display
|
||||
}
|
||||
Controls.BusyIndicator {
|
||||
anchors.centerIn: parent
|
||||
visible: searchModel.loading
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@ SearchModel::SearchModel(QObject *parent)
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
m_ytm.search(m_searchQuery);
|
||||
});
|
||||
connect(&m_ytm, &AsyncYTMusic::searchFinished, this, [=](const std::vector<search::SearchResultItem> &results) {
|
||||
beginResetModel();
|
||||
setLoading(false);
|
||||
m_searchResults = results;
|
||||
endResetModel();
|
||||
});
|
||||
@@ -73,3 +75,14 @@ void SearchModel::setSearchQuery(const QString &searchQuery)
|
||||
m_searchQuery = searchQuery;
|
||||
Q_EMIT searchQueryChanged();
|
||||
}
|
||||
|
||||
bool SearchModel::loading() const
|
||||
{
|
||||
return m_loading;
|
||||
}
|
||||
|
||||
void SearchModel::setLoading(bool loading)
|
||||
{
|
||||
m_loading = loading;
|
||||
Q_EMIT loadingChanged();
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ class SearchModel : public QAbstractListModel
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
|
||||
Q_PROPERTY(bool loading READ loading WRITE setLoading NOTIFY loadingChanged)
|
||||
|
||||
public:
|
||||
explicit SearchModel(QObject *parent = nullptr);
|
||||
@@ -19,14 +20,18 @@ public:
|
||||
int rowCount(const QModelIndex &parent) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
Q_SIGNAL void searchQueryChanged();
|
||||
|
||||
QString searchQuery() const;
|
||||
void setSearchQuery(const QString &searchQuery);
|
||||
Q_SIGNAL void searchQueryChanged();
|
||||
|
||||
bool loading() const;
|
||||
void setLoading(bool loading);
|
||||
Q_SIGNAL void loadingChanged();
|
||||
|
||||
private:
|
||||
QString m_searchQuery;
|
||||
std::vector<search::SearchResultItem> m_searchResults;
|
||||
bool m_loading = false;
|
||||
|
||||
AsyncYTMusic m_ytm;
|
||||
QThread *m_thread;
|
||||
|
||||
Reference in New Issue
Block a user