Wrap image progress bars in loaders, fix cpu usage

This commit is contained in:
miruka 2019-12-15 13:02:40 -04:00
parent 2d501dca5a
commit 2cfe76fd8e
4 changed files with 15 additions and 10 deletions

View File

@ -59,7 +59,6 @@
- Messed up message delegates position - Messed up message delegates position
- Pausing uploads doesn't work well, servers end up dropping the connection - Pausing uploads doesn't work well, servers end up dropping the connection
- Quickly posting with another account leads to sync stop - Quickly posting with another account leads to sync stop
- CPU usage
- `code` not colored in room subtitle - `code` not colored in room subtitle
- In the "Leave me" room, "join > Hi > left" aren't combined - In the "Leave me" room, "join > Hi > left" aren't combined
- Event delegates changing height don't scroll the list - Event delegates changing height don't scroll the list

View File

@ -45,7 +45,7 @@ Rectangle {
HMxcImage { HMxcImage {
id: avatarImage id: avatarImage
anchors.fill: parent anchors.fill: parent
progressBar.visible: false showProgressBar: false
visible: Boolean(sourceOverride || mxc) visible: Boolean(sourceOverride || mxc)
z: 2 z: 2
sourceSize.width: parent.width sourceSize.width: parent.width

View File

@ -14,7 +14,9 @@ Image {
property bool broken: false property bool broken: false
property bool animate: true property bool animate: true
property bool animated: Utils.urlExtension(image.source) === "gif" property bool animated: Utils.urlExtension(image.source) === "gif"
property alias progressBar: progressBar
property alias showProgressBar: progressBarLoader.active
property bool inderterminateProgressBar: false
Component { Component {
@ -64,16 +66,20 @@ Image {
sourceComponent: animate && animated ? animatedImageComponent : null sourceComponent: animate && animated ? animatedImageComponent : null
} }
HCircleProgressBar { HLoader {
id: progressBar id: progressBarLoader
anchors.centerIn: parent anchors.centerIn: parent
width: Math.min(parent.width, parent.height) * 0.5 width: Math.min(parent.width, parent.height) * 0.5
height: width height: width
visible: image.status === Image.Loading active: image.status === Image.Loading
value: image.progress
text: Math.round(value * 100) + "%"
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 { HIcon {

View File

@ -2,7 +2,7 @@ import QtQuick 2.12
HImage { HImage {
id: image id: image
progressBar.indeterminate: isMxc inderterminateProgressBar: isMxc
source: sourceOverride || (show ? cachedPath : "") source: sourceOverride || (show ? cachedPath : "")
onWidthChanged: Qt.callLater(update) onWidthChanged: Qt.callLater(update)
onHeightChanged: Qt.callLater(update) onHeightChanged: Qt.callLater(update)