diff --git a/launcher/include/headline.h b/launcher/include/headline.h index 7464ef1..9af7ff1 100644 --- a/launcher/include/headline.h +++ b/launcher/include/headline.h @@ -45,6 +45,7 @@ class Headline : public QObject Q_PROPERTY(QList news MEMBER news CONSTANT) Q_PROPERTY(QList pinned MEMBER pinned CONSTANT) Q_PROPERTY(QList topics MEMBER topics CONSTANT) + Q_PROPERTY(bool failedToLoad MEMBER failedToLoad CONSTANT) public: explicit Headline(QObject *parent = nullptr) @@ -56,4 +57,7 @@ public: QList news; QList pinned; QList topics; + + // FIXME: wtf is this? + bool failedToLoad = false; }; \ No newline at end of file diff --git a/launcher/src/launchercore.cpp b/launcher/src/launchercore.cpp index a95dc28..b2fa9fd 100755 --- a/launcher/src/launchercore.cpp +++ b/launcher/src/launchercore.cpp @@ -540,6 +540,9 @@ void LauncherCore::refreshNews() auto document = QJsonDocument::fromJson(reply->readAll()); auto headline = new Headline(this); + if (document.isEmpty()) { + headline->failedToLoad = true; + } const auto parseNews = [](QJsonObject object) -> News { News news; diff --git a/launcher/ui/Pages/NewsPage.qml b/launcher/ui/Pages/NewsPage.qml index ffb8bab..b57b6b9 100644 --- a/launcher/ui/Pages/NewsPage.qml +++ b/launcher/ui/Pages/NewsPage.qml @@ -86,6 +86,7 @@ Controls.Control { Layout.alignment: Qt.AlignHCenter | Qt.AlignTop maximumWidth: layout.maximumWidth + visible: LauncherCore.headline !== null contentItem: ColumnLayout { spacing: 0 @@ -104,6 +105,11 @@ Controls.Control { 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 maximumWidth: layout.maximumWidth + visible: LauncherCore.headline !== null contentItem: ColumnLayout { spacing: 0 @@ -131,6 +138,11 @@ Controls.Control { 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 } } + + Kirigami.LoadingPlaceholder { + anchors.centerIn: parent + visible: LauncherCore.headline === null + } } \ No newline at end of file