From 2cfe76fd8e0669415659ab08eadb195912dedc2b Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 15 Dec 2019 13:02:40 -0400 Subject: [PATCH] Wrap image progress bars in loaders, fix cpu usage --- TODO.md | 1 - src/qml/Base/HAvatar.qml | 2 +- src/qml/Base/HImage.qml | 20 +++++++++++++------- src/qml/Base/HMxcImage.qml | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index 4758a2f5..34a0eb11 100644 --- a/TODO.md +++ b/TODO.md @@ -59,7 +59,6 @@ - Messed up message delegates position - Pausing uploads doesn't work well, servers end up dropping the connection - Quickly posting with another account leads to sync stop -- CPU usage - `code` not colored in room subtitle - In the "Leave me" room, "join > Hi > left" aren't combined - Event delegates changing height don't scroll the list diff --git a/src/qml/Base/HAvatar.qml b/src/qml/Base/HAvatar.qml index 20a2932e..9c36e501 100644 --- a/src/qml/Base/HAvatar.qml +++ b/src/qml/Base/HAvatar.qml @@ -45,7 +45,7 @@ Rectangle { HMxcImage { id: avatarImage anchors.fill: parent - progressBar.visible: false + showProgressBar: false visible: Boolean(sourceOverride || mxc) z: 2 sourceSize.width: parent.width diff --git a/src/qml/Base/HImage.qml b/src/qml/Base/HImage.qml index 9092a525..3bf01903 100644 --- a/src/qml/Base/HImage.qml +++ b/src/qml/Base/HImage.qml @@ -14,7 +14,9 @@ Image { property bool broken: false property bool animate: true property bool animated: Utils.urlExtension(image.source) === "gif" - property alias progressBar: progressBar + + property alias showProgressBar: progressBarLoader.active + property bool inderterminateProgressBar: false Component { @@ -64,16 +66,20 @@ Image { sourceComponent: animate && animated ? animatedImageComponent : null } - HCircleProgressBar { - id: progressBar + HLoader { + id: progressBarLoader anchors.centerIn: parent width: Math.min(parent.width, parent.height) * 0.5 height: width - visible: image.status === Image.Loading - value: image.progress - text: Math.round(value * 100) + "%" + active: image.status === Image.Loading - Behavior on value { HNumberAnimation { factor: 2 } } + sourceComponent: HCircleProgressBar { + id: progressBar + value: image.progress + text: Math.round(value * 100) + "%" + + Behavior on value { HNumberAnimation { factor: 2 } } + } } HIcon { diff --git a/src/qml/Base/HMxcImage.qml b/src/qml/Base/HMxcImage.qml index 5e7f8607..df308c16 100644 --- a/src/qml/Base/HMxcImage.qml +++ b/src/qml/Base/HMxcImage.qml @@ -2,7 +2,7 @@ import QtQuick 2.12 HImage { id: image - progressBar.indeterminate: isMxc + inderterminateProgressBar: isMxc source: sourceOverride || (show ? cachedPath : "") onWidthChanged: Qt.callLater(update) onHeightChanged: Qt.callLater(update)