Implement update status progress indicator

This commit is contained in:
Bart De Vries 2021-04-20 20:36:29 +02:00
parent 53e2560796
commit 28e8051500
4 changed files with 128 additions and 3 deletions

View File

@ -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);
}
}

View File

@ -0,0 +1,114 @@
/**
* SPDX-FileCopyrightText: 2017 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>
* SPDX-FileCopyrightText: 2021 Bart De Vries <bart@mogwai.be>
*
* 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()
}
}
}
}

View File

@ -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 )
}
}
}

View File

@ -18,6 +18,7 @@
<file alias="DownloadSwipePage.qml">qml/DownloadSwipePage.qml</file>
<file alias="GenericListHeader.qml">qml/GenericListHeader.qml</file>
<file alias="GenericEntryDelegate.qml">qml/GenericEntryDelegate.qml</file>
<file alias="UpdateNotification.qml">qml/UpdateNotification.qml</file>
<file alias="logo.png">../logo.png</file>
<file>qtquickcontrols2.conf</file>
</qresource>