[PC3 ProgressBar] Set binding for width

Otherwise the progress bar will never update its size when it was indeterminate
at one point..

BUG: 430544
This commit is contained in:
Kai Uwe Broulik 2020-12-18 18:49:02 +01:00
parent 4d2d834583
commit 85f136ff41
2 changed files with 41 additions and 2 deletions

View File

@ -35,8 +35,12 @@ T.ProgressBar {
alwaysRunToEnd: true
running: control.indeterminate && control.visible
onStarted: indicator.width = units.gridUnit * 2
onStopped: indicator.width = parent.width * control.position
onStarted: indicator.width = Qt.binding(function() {
return units.gridUnit * 2;
});
onStopped: indicator.width = Qt.binding(function() {
return indicator.parent.width * control.position;
});
PropertyAnimation {
target: indicator

View File

@ -160,5 +160,40 @@ ComponentBase {
}
}
ColumnLayout {
PlasmaComponents.Label {
text: "This should do one 'indefinite' animation cycle and then continuously animate to 100% in chunks of 10%."
wrapMode: Text.WordWrap
Layout.preferredWidth: progressBarWidth
}
PlasmaComponents.ProgressBar {
id: animatingProgressBar
from: 0
to: 100
// Bug 430544: A ProgressBar that was indeterminate once will
// not update its bar size according to its value anymore
// Set to false again in the Timer below
indeterminate: true
Timer {
interval: 500
triggeredOnStart: true
running: true
repeat: true
onTriggered: {
animatingProgressBar.indeterminate = false;
// ProgressBar clamps "value" by "to" (100), so we can't
// just blindly increase and then check >= 100
if (animatingProgressBar.value === 100) {
animatingProgressBar.value = 0;
} else {
animatingProgressBar.value += 10;
}
}
}
}
}
}
}