From 44b275f23d2025437914866aa75594965b66d80f Mon Sep 17 00:00:00 2001 From: "B.Melnik" Date: Thu, 27 May 2021 14:44:51 +0300 Subject: [PATCH] feat(StatusRoundedImage): add loading indicator option Closes #56 --- src/StatusQ/Components/StatusRoundedImage.qml | 14 ++++++++++++++ src/StatusQ/Controls/StatusIconTabButton.qml | 15 ++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/StatusQ/Components/StatusRoundedImage.qml b/src/StatusQ/Components/StatusRoundedImage.qml index 5f4d880c..b6055b99 100644 --- a/src/StatusQ/Components/StatusRoundedImage.qml +++ b/src/StatusQ/Components/StatusRoundedImage.qml @@ -5,6 +5,9 @@ import StatusQ.Core.Theme 0.1 Rectangle { id: statusRoundImage + + property bool showLoadingIndicator: false + property alias image: image implicitWidth: 40 @@ -28,4 +31,15 @@ Rectangle { fillMode: Image.PreserveAspectFit cache: true } + + Loader { + id: itemSelector + anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + active: showLoadingIndicator && image.status === Image.Loading + sourceComponent: StatusLoadingIndicator { + color: Theme.palette.directColor6 + + } + } } diff --git a/src/StatusQ/Controls/StatusIconTabButton.qml b/src/StatusQ/Controls/StatusIconTabButton.qml index bac5462c..36b62527 100644 --- a/src/StatusQ/Controls/StatusIconTabButton.qml +++ b/src/StatusQ/Controls/StatusIconTabButton.qml @@ -45,24 +45,17 @@ TabButton { height: 28 StatusRoundedImage { id: statusRoundImage + showLoadingIndicator: true width: parent.width height: parent.height image.source: icon.source } Loader { - sourceComponent: { - switch (statusRoundImage.image.status) { - case Image.Loading: - return statusLoadingIndicator - break; - case Image.Error: - return letterIdenticon - break; - } - } + sourceComponent:letterIdenticon + anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter - active: statusRoundImage.image.status === Image.Loading || statusRoundImage.image.status === Image.Error + active: statusRoundImage.image.status === Image.Error } Component {