fix(StatusProgressBar): Hide text in bar if it does not fit (#672)

This commit is contained in:
Mikhail Rogachev 2022-05-13 21:05:37 +03:00 committed by GitHub
parent 1b25ddd2b5
commit 9498be05ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -34,10 +34,24 @@ ProgressBar {
radius: 5
StatusBaseText {
id: textItem
anchors.centerIn: parent
property bool _fittedInBar: width < bar.width ? true : false
text: control.text
font.pixelSize: 12
color: Theme.palette.indirectColor1
Component.onCompleted: opacity = width < bar.width ? 1 : 0
on_FittedInBarChanged: {
if (_fittedInBar && opacity == 0) {
fadeIn.start();
}
else if (!_fittedInBar) {
fadeIn.stop();
opacity = 0;
}
}
OpacityAnimator { id: fadeIn; target: textItem; from: 0; to: 1; duration: 250 }
}
}
}