From 7c856be981dc37f5c380264e6dd48f91f80041d6 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 30 Jul 2020 16:46:25 -0400 Subject: [PATCH] fix: use Loader for animation to reduce cpu usage --- ui/app/AppLayouts/Wallet/CollectiblesTab.qml | 25 +++++++------------- ui/shared/LoadingImage.qml | 19 +++++++++++++++ 2 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 ui/shared/LoadingImage.qml diff --git a/ui/app/AppLayouts/Wallet/CollectiblesTab.qml b/ui/app/AppLayouts/Wallet/CollectiblesTab.qml index 31e79be12b..072c1f0bb8 100644 --- a/ui/app/AppLayouts/Wallet/CollectiblesTab.qml +++ b/ui/app/AppLayouts/Wallet/CollectiblesTab.qml @@ -9,33 +9,26 @@ Item { visible: walletModel.collectibles.rowCount() === 0 } - SVGImage { + Loader { id: loadingImg - visible: false + active: false + sourceComponent: loadingImageComponent anchors.right: parent.right anchors.rightMargin: Style.current.padding anchors.top: parent.top anchors.topMargin: Style.currentPadding anchors.verticalCenter: txtPassword.verticalCenter - // TODO replace by a real loading image - source: "../../img/settings.svg" - width: 30 - height: 30 - fillMode: Image.Stretch - RotationAnimator { - target: loadingImg; - from: 0; - to: 360; - duration: 1200 - running: true - loops: Animation.Infinite - } + } + + Component { + id: loadingImageComponent + LoadingImage {} } Connections { target: walletModel onLoadingCollectibles: { - loadingImg.visible = isLoading + loadingImg.active = isLoading } } diff --git a/ui/shared/LoadingImage.qml b/ui/shared/LoadingImage.qml new file mode 100644 index 0000000000..ed3b3b4329 --- /dev/null +++ b/ui/shared/LoadingImage.qml @@ -0,0 +1,19 @@ +import QtQuick 2.13 +import "." + +SVGImage { + id: loadingImg + // TODO replace by a real loading image + source: "../app/img/settings.svg" + width: 30 + height: 30 + fillMode: Image.Stretch + RotationAnimator { + target: loadingImg; + from: 0; + to: 360; + duration: 1200 + running: true + loops: Animation.Infinite + } +} \ No newline at end of file