From 28e805150010d5479063f1b220b97a136c5f127c Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Tue, 20 Apr 2021 20:36:29 +0200 Subject: [PATCH] Implement update status progress indicator --- src/fetcher.cpp | 6 +- src/qml/UpdateNotification.qml | 114 +++++++++++++++++++++++++++++++++ src/qml/main.qml | 10 +++ src/resources.qrc | 1 + 4 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 src/qml/UpdateNotification.qml diff --git a/src/fetcher.cpp b/src/fetcher.cpp index 87a7c801..306c4f73 100644 --- a/src/fetcher.cpp +++ b/src/fetcher.cpp @@ -90,7 +90,7 @@ void Fetcher::fetchAll() void Fetcher::updateMonitor(int progress) { - qDebug() << "Update monitor" << progress << "/" << m_updateTotal; + //qDebug() << "Update monitor" << progress << "/" << m_updateTotal; // this method will watch for the end of the update process if (progress > -1 && m_updateTotal > -1 && progress == m_updateTotal) { m_updating = false; @@ -98,8 +98,8 @@ void Fetcher::updateMonitor(int progress) m_updateTotal = -1; disconnect(this, &Fetcher::updateProgressChanged, this, &Fetcher::updateMonitor); Q_EMIT updatingChanged(m_updating); - Q_EMIT updateProgressChanged(m_updateProgress); - Q_EMIT updateTotalChanged(m_updateTotal); + //Q_EMIT updateProgressChanged(m_updateProgress); + //Q_EMIT updateTotalChanged(m_updateTotal); } } diff --git a/src/qml/UpdateNotification.qml b/src/qml/UpdateNotification.qml new file mode 100644 index 00000000..a903b843 --- /dev/null +++ b/src/qml/UpdateNotification.qml @@ -0,0 +1,114 @@ +/** + * SPDX-FileCopyrightText: 2017 (c) Matthieu Gallien + * SPDX-FileCopyrightText: 2021 Bart De Vries + * + * SPDX-License-Identifier: LGPL-3.0-or-later + */ + +import QtQuick 2.14 +import QtQuick.Layouts 1.14 +import QtQuick.Controls 2.14 as Controls +import org.kde.kirigami 2.15 as Kirigami +import org.kde.alligator 1.0 + +/* + * This visually mimics the Kirigami.InlineMessage due to the + * BusyIndicator, which is not supported by the InlineMessage. + * Consider implementing support for the BusyIndicator within + * the InlineMessage in the future. + */ +Rectangle { + id: rootComponent + + color: Kirigami.Theme.activeTextColor + + width: (labelWidth.boundingRect.width - labelWidth.boundingRect.x) + 3 * Kirigami.Units.largeSpacing + + indicator.width + height: indicator.height + + visible: opacity > 0 + opacity: 0 + + radius: Kirigami.Units.smallSpacing / 2 + + Rectangle { + id: bgFillRect + + anchors.fill: parent + anchors.margins: Kirigami.Units.devicePixelRatio + + color: Kirigami.Theme.backgroundColor + + radius: rootComponent.radius * 0.60 + } + + Rectangle { + anchors.fill: bgFillRect + color: rootComponent.color + opacity: 0.20 + radius: bgFillRect.radius + } + + RowLayout { + anchors.fill: parent + spacing: Kirigami.Units.largeSpacing + + Controls.BusyIndicator{ + id: indicator + Layout.alignment: Qt.AlignVCenter + } + + Controls.Label { + id: feedUpdateCountLabel + text: i18ncp("number of updated feeds", + "Updated %2 of %1 feed", + "Updated %2 of %1 feeds", + Fetcher.updateTotal, Fetcher.updateProgress) + color: Kirigami.Theme.textColor + + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignVCenter + } + } + + TextMetrics { + id: labelWidth + + text: i18ncp("number of updated feeds", + "Updated %2 of %1 feed", + "Updated %2 of %1 feeds", + 999, 999) + } + + Timer { + id: hideTimer + + interval: 2000 + repeat: false + + onTriggered: + { + rootComponent.opacity = 0 + } + } + + Behavior on opacity { + NumberAnimation { + easing.type: Easing.InOutQuad + duration: Kirigami.Units.longDuration + } + } + + Connections { + target: Fetcher + function onUpdatingChanged() { + if (Fetcher.updating) { + hideTimer.stop() + opacity = 1 + } else { + hideTimer.start() + } + } + } +} diff --git a/src/qml/main.qml b/src/qml/main.qml index bf6b4f8c..7c6c5b59 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -146,4 +146,14 @@ Kirigami.ApplicationWindow { } } + UpdateNotification { + z: 2 + id: updateNotification + + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom + bottomMargin: Kirigami.Units.largeSpacing * 9 + ( audio.entry ? ( footerLoader.item.contentY == 0 ? miniplayerSize : 0 ) : 0 ) + } + } } diff --git a/src/resources.qrc b/src/resources.qrc index 21500ee5..0e4f0ecb 100755 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -18,6 +18,7 @@ qml/DownloadSwipePage.qml qml/GenericListHeader.qml qml/GenericEntryDelegate.qml + qml/UpdateNotification.qml ../logo.png qtquickcontrols2.conf