From 0515a94429952f36fecdbb5390d30cfceef82cc9 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 16 Jul 2020 17:15:33 -0400 Subject: [PATCH] Show spinner for loading media event thumbnails --- src/gui/Base/HImage.qml | 14 +++++++++----- src/gui/Base/HMxcImage.qml | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gui/Base/HImage.qml b/src/gui/Base/HImage.qml index 48b43e4b..3baaaefd 100644 --- a/src/gui/Base/HImage.qml +++ b/src/gui/Base/HImage.qml @@ -15,7 +15,6 @@ Image { property alias radius: roundMask.radius property alias showProgressBar: progressBarLoader.active - property bool inderterminateProgressBar: false readonly property int circleRadius: Math.ceil(Math.max(image.width, image.height)) @@ -104,15 +103,20 @@ Image { HLoader { id: progressBarLoader + + readonly property alias progress: image.progress + readonly property Component determinate: HCircleProgressBar { + progress: image.progress + } + anchors.centerIn: parent width: Math.min(parent.width, parent.height) * 0.5 height: width active: image.status === Image.Loading + sourceComponent: HBusyIndicator {} - sourceComponent: HCircleProgressBar { - id: progressBar - progress: image.progress - } + onProgressChanged: + if (progress > 0 && progress < 1) sourceComponent = determinate } HIcon { diff --git a/src/gui/Base/HMxcImage.qml b/src/gui/Base/HMxcImage.qml index b28e516d..b1d9dee4 100644 --- a/src/gui/Base/HMxcImage.qml +++ b/src/gui/Base/HMxcImage.qml @@ -56,8 +56,9 @@ HImage { } - inderterminateProgressBar: isMxc source: sourceOverride || (show ? cachedPath : "") + showProgressBar: + (isMxc && status === Image.Null) || status === Image.Loading onWidthChanged: Qt.callLater(update) onHeightChanged: Qt.callLater(update)