From a7bac204ad99a5893a9ad2ae14467974648f81f5 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Sat, 8 May 2021 18:54:29 +0200 Subject: [PATCH] Implement InlineMessage displaying download/update errors --- src/errorlogmodel.cpp | 3 +++ src/errorlogmodel.h | 3 +++ src/qml/ErrorListPage.qml | 2 +- src/qml/main.qml | 26 +++++++++++++++++++++++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/errorlogmodel.cpp b/src/errorlogmodel.cpp index 228eb519..10a8fde8 100644 --- a/src/errorlogmodel.cpp +++ b/src/errorlogmodel.cpp @@ -73,6 +73,9 @@ void ErrorLogModel::monitorErrorMessages(const QString &url, const QString &id, query.bindValue(QStringLiteral(":message"), error->message); query.bindValue(QStringLiteral(":date"), error->date.toSecsSinceEpoch()); Database::instance().execute(query); + + // Send signal to display inline error message + Q_EMIT newErrorLogged(error); } void ErrorLogModel::clearAll() diff --git a/src/errorlogmodel.h b/src/errorlogmodel.h index 56787c9e..7b774921 100644 --- a/src/errorlogmodel.h +++ b/src/errorlogmodel.h @@ -34,6 +34,9 @@ public: public: void monitorErrorMessages(const QString &url, const QString &id, const int errorCode, const QString &errorString); +Q_SIGNALS: + void newErrorLogged(Error *error); + private: explicit ErrorLogModel(); diff --git a/src/qml/ErrorListPage.qml b/src/qml/ErrorListPage.qml index 1eb9239a..c3e0a4a1 100644 --- a/src/qml/ErrorListPage.qml +++ b/src/qml/ErrorListPage.qml @@ -41,7 +41,7 @@ Kirigami.ScrollablePage { Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter Controls.Label { - text: ( (error.id) ? i18n("Media download") : i18n("Feed update error") ) + " · " + error.date.toLocaleDateString(Qt.locale(), Locale.NarrowFormat) + " · " + error.date.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat) + text: ( (error.id) ? i18n("Media download error") : i18n("Feed update error") ) + " · " + error.date.toLocaleDateString(Qt.locale(), Locale.NarrowFormat) + " · " + error.date.toLocaleTimeString(Qt.locale(), Locale.NarrowFormat) Layout.fillWidth: true elide: Text.ElideRight font: Kirigami.Theme.smallFont diff --git a/src/qml/main.qml b/src/qml/main.qml index aecb1907..71ddcb8f 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -21,6 +21,7 @@ Kirigami.ApplicationWindow { property var miniplayerSize: Kirigami.Units.gridUnit * 3 + Kirigami.Units.gridUnit / 6 property int tabBarHeight: Kirigami.Units.gridUnit * 2 + property int bottomMessageSpacing: Kirigami.Units.largeSpacing * 9 + ( audio.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 ) + tabBarActive * tabBarHeight property int tabBarActive: 0 Kirigami.PagePool { @@ -153,6 +154,7 @@ Kirigami.ApplicationWindow { } } + UpdateNotification { z: 2 id: updateNotification @@ -160,7 +162,29 @@ Kirigami.ApplicationWindow { anchors { horizontalCenter: parent.horizontalCenter bottom: parent.bottom - bottomMargin: Kirigami.Units.largeSpacing * 9 + ( audio.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 ) + tabBarActive * tabBarHeight + bottomMargin: bottomMessageSpacing + } + } + + Kirigami.InlineMessage { + id: inlineMessage + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + right: parent.right + left: parent.left + margins: Kirigami.Units.gridUnit + bottomMargin: bottomMessageSpacing + ( updateNotification.visible ? updateNotification.height + Kirigami.Units.largeSpacing : 0 ) + } + type: Kirigami.MessageType.Error + showCloseButton: true + + Connections { + target: ErrorLogModel + function onNewErrorLogged(error) { + inlineMessage.text = error.id ? i18n("Media download error") : i18n("Feed update error") + "\n" + i18n("Check Error Log tab (under Downloads) for more details."); + inlineMessage.visible = true; + } } } }