mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-22 20:47:45 +00:00
Make news page loading more obvious, and show if there's no news
If there's no news available (e.g. the server is down, or no internet connection) make it look a little bit nicer.
This commit is contained in:
parent
8d4a081ad7
commit
18d416011a
3 changed files with 24 additions and 0 deletions
|
@ -45,6 +45,7 @@ class Headline : public QObject
|
||||||
Q_PROPERTY(QList<News> news MEMBER news CONSTANT)
|
Q_PROPERTY(QList<News> news MEMBER news CONSTANT)
|
||||||
Q_PROPERTY(QList<News> pinned MEMBER pinned CONSTANT)
|
Q_PROPERTY(QList<News> pinned MEMBER pinned CONSTANT)
|
||||||
Q_PROPERTY(QList<News> topics MEMBER topics CONSTANT)
|
Q_PROPERTY(QList<News> topics MEMBER topics CONSTANT)
|
||||||
|
Q_PROPERTY(bool failedToLoad MEMBER failedToLoad CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Headline(QObject *parent = nullptr)
|
explicit Headline(QObject *parent = nullptr)
|
||||||
|
@ -56,4 +57,7 @@ public:
|
||||||
QList<News> news;
|
QList<News> news;
|
||||||
QList<News> pinned;
|
QList<News> pinned;
|
||||||
QList<News> topics;
|
QList<News> topics;
|
||||||
|
|
||||||
|
// FIXME: wtf is this?
|
||||||
|
bool failedToLoad = false;
|
||||||
};
|
};
|
|
@ -540,6 +540,9 @@ void LauncherCore::refreshNews()
|
||||||
auto document = QJsonDocument::fromJson(reply->readAll());
|
auto document = QJsonDocument::fromJson(reply->readAll());
|
||||||
|
|
||||||
auto headline = new Headline(this);
|
auto headline = new Headline(this);
|
||||||
|
if (document.isEmpty()) {
|
||||||
|
headline->failedToLoad = true;
|
||||||
|
}
|
||||||
|
|
||||||
const auto parseNews = [](QJsonObject object) -> News {
|
const auto parseNews = [](QJsonObject object) -> News {
|
||||||
News news;
|
News news;
|
||||||
|
|
|
@ -86,6 +86,7 @@ Controls.Control {
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||||
|
|
||||||
maximumWidth: layout.maximumWidth
|
maximumWidth: layout.maximumWidth
|
||||||
|
visible: LauncherCore.headline !== null
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
@ -104,6 +105,11 @@ Controls.Control {
|
||||||
onClicked: applicationWindow().openUrl(modelData.url)
|
onClicked: applicationWindow().openUrl(modelData.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobileForm.FormTextDelegate {
|
||||||
|
description: i18n("No news.")
|
||||||
|
visible: LauncherCore.headline !== null ? LauncherCore.headline.failedToLoad : false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +119,7 @@ Controls.Control {
|
||||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||||
|
|
||||||
maximumWidth: layout.maximumWidth
|
maximumWidth: layout.maximumWidth
|
||||||
|
visible: LauncherCore.headline !== null
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
@ -131,6 +138,11 @@ Controls.Control {
|
||||||
onClicked: applicationWindow().openUrl(modelData.url)
|
onClicked: applicationWindow().openUrl(modelData.url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobileForm.FormTextDelegate {
|
||||||
|
description: i18n("No topics.")
|
||||||
|
visible: LauncherCore.headline !== null ? LauncherCore.headline.failedToLoad : false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,4 +150,9 @@ Controls.Control {
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Kirigami.LoadingPlaceholder {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: LauncherCore.headline === null
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue