feat(StatusRoundedImage): add loading indicator option

Closes #56
This commit is contained in:
B.Melnik 2021-05-27 14:44:51 +03:00 committed by Pascal Precht
parent 82e34d64a6
commit 44b275f23d
No known key found for this signature in database
GPG Key ID: 0EE28D8D6FD85D7D
2 changed files with 18 additions and 11 deletions

View File

@ -5,6 +5,9 @@ import StatusQ.Core.Theme 0.1
Rectangle { Rectangle {
id: statusRoundImage id: statusRoundImage
property bool showLoadingIndicator: false
property alias image: image property alias image: image
implicitWidth: 40 implicitWidth: 40
@ -28,4 +31,15 @@ Rectangle {
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
cache: true 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
}
}
} }

View File

@ -45,24 +45,17 @@ TabButton {
height: 28 height: 28
StatusRoundedImage { StatusRoundedImage {
id: statusRoundImage id: statusRoundImage
showLoadingIndicator: true
width: parent.width width: parent.width
height: parent.height height: parent.height
image.source: icon.source image.source: icon.source
} }
Loader { Loader {
sourceComponent: { sourceComponent:letterIdenticon
switch (statusRoundImage.image.status) {
case Image.Loading:
return statusLoadingIndicator
break;
case Image.Error:
return letterIdenticon
break;
}
}
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
active: statusRoundImage.image.status === Image.Loading || statusRoundImage.image.status === Image.Error active: statusRoundImage.image.status === Image.Error
} }
Component { Component {