Fix constant CPU usage due to HButtonContent

Unload the animated HBusyIndicator when not needed
This commit is contained in:
miruka 2020-03-23 14:04:00 -04:00
parent 919edb52ad
commit b11bd8331b
2 changed files with 7 additions and 5 deletions

View File

@ -1,7 +1,6 @@
# TODO # TODO
- mention color in local echo - mention color in local echo
- cpu usage
## Main goals for next version ## Main goals for next version

View File

@ -25,7 +25,7 @@ HRowLayout {
visible: button.icon.name || button.loading visible: button.icon.name || button.loading
Layout.preferredWidth: Layout.preferredWidth:
button.loading ? busyIndicator.width : icon.width button.loading ? busyIndicatorLoader.width : icon.width
Layout.fillHeight: true Layout.fillHeight: true
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
@ -45,15 +45,18 @@ HRowLayout {
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }
} }
HBusyIndicator { HLoader {
id: busyIndicator id: busyIndicatorLoader
anchors.centerIn: parent anchors.centerIn: parent
width: height width: height
height: parent.height height: parent.height
opacity: button.loading ? 1 : 0 opacity: button.loading ? 1 : 0
visible: opacity > 0 active: opacity > 0
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }
sourceComponent: HBusyIndicator {
}
} }
} }