diff --git a/src/qml/Base/HAvatar.qml b/src/qml/Base/HAvatar.qml index bb062014..916b9f53 100644 --- a/src/qml/Base/HAvatar.qml +++ b/src/qml/Base/HAvatar.qml @@ -46,6 +46,7 @@ Rectangle { HMxcImage { id: avatarImage anchors.fill: parent + progressBar.visible: false visible: Boolean(sourceOverride || mxc) z: 2 sourceSize.width: parent.width @@ -53,7 +54,6 @@ Rectangle { fillMode: Image.PreserveAspectCrop animate: false clientUserId: avatar.clientUserId - loadingLabel.font.pixelSize: theme.fontSize.small HoverHandler { id: hoverHandler } diff --git a/src/qml/Base/HCircleProgressBar.qml b/src/qml/Base/HCircleProgressBar.qml index 35e3a6ec..192c4632 100644 --- a/src/qml/Base/HCircleProgressBar.qml +++ b/src/qml/Base/HCircleProgressBar.qml @@ -12,7 +12,7 @@ RadialBar { spanAngle: 360 from: 0 - to: 100 + to: 1 value: 0 showText: true diff --git a/src/qml/Base/HImage.qml b/src/qml/Base/HImage.qml index bc89b79b..93b24f7c 100644 --- a/src/qml/Base/HImage.qml +++ b/src/qml/Base/HImage.qml @@ -12,9 +12,8 @@ Image { property bool animate: true - property bool animated: Utils.urlExtension(image.source) === "gif" - readonly property alias loadingLabel: loadingLabel + property alias progressBar: progressBar Component { @@ -65,15 +64,15 @@ Image { sourceComponent: animate && animated ? animatedImageComponent : null } - - HLabel { - id: loadingLabel + HCircleProgressBar { + id: progressBar anchors.centerIn: parent + width: Math.min(parent.width, parent.height) * 0.5 + height: width visible: image.status === Image.Loading - text: qsTr("%1%").arg(progress) + value: image.progress + text: Math.round(value * 100) + "%" - property int progress: Math.round(image.progress * 100) - - Behavior on progress { HNumberAnimation { factor: 2 } } + Behavior on value { HNumberAnimation { factor: 2 } } } } diff --git a/src/qml/Base/HMxcImage.qml b/src/qml/Base/HMxcImage.qml index 837c2e28..dd039fa0 100644 --- a/src/qml/Base/HMxcImage.qml +++ b/src/qml/Base/HMxcImage.qml @@ -2,6 +2,7 @@ import QtQuick 2.12 HImage { id: image + progressBar.indeterminate: isMxc source: sourceOverride || (show ? cachedPath : "") onWidthChanged: Qt.callLater(update) onHeightChanged: Qt.callLater(update) @@ -9,7 +10,7 @@ HImage { onMxcChanged: { Qt.callLater(update) - if (mxc.startsWith("mxc://")) { + if (isMxc) { py.callCoro("mxc_to_http", [mxc], http => { image.httpUrl = http || "" }) @@ -28,6 +29,7 @@ HImage { property bool show: false property string cachedPath: "" property string httpUrl: "" + readonly property bool isMxc: mxc.startsWith("mxc://") function update() { @@ -41,7 +43,7 @@ HImage { if (! image) return // if it was destroyed - if (! image.mxc.startsWith("mxc://")) { + if (! isMxc) { if (source != mxc) source = mxc show = image.visible return