diff options
Diffstat (limited to 'src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp')
-rw-r--r-- | src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp b/src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp index 4dbe04e4b1..1da27fa0aa 100644 --- a/src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp +++ b/src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp @@ -15,9 +15,9 @@ static const int BlockWidth = 16; static const int BlockRestingSpacing = 4; static const int BlockMovingSpacing = 48; static const int BlockSpan = Blocks * (BlockWidth + BlockRestingSpacing) - BlockRestingSpacing; -static const int TotalDuration = 4000; -static const int SecondPhaseStart = TotalDuration * 0.4; -static const int ThirdPhaseStart = TotalDuration * 0.6; +static const int QbpbTotalDuration = 4000; +static const int SecondPhaseStart = QbpbTotalDuration * 0.4; +static const int ThirdPhaseStart = QbpbTotalDuration * 0.6; static inline qreal blockStartX(int blockIndex) { @@ -53,7 +53,7 @@ QQuickBasicProgressBarNode::QQuickBasicProgressBarNode(QQuickBasicProgressBar *i m_pixelsPerSecond(item->width()) { setLoopCount(Infinite); - setDuration(TotalDuration); + setDuration(QbpbTotalDuration); } void QQuickBasicProgressBarNode::updateCurrentTime(int time) @@ -143,7 +143,6 @@ void QQuickBasicProgressBarNode::sync(QQuickItem *item) QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(transformNode->firstChild()); if (!rectNode) { rectNode = d->sceneGraphContext()->createInternalRectangleNode(); - rectNode->setColor(bar->color()); transformNode->appendChildNode(rectNode); } @@ -151,6 +150,9 @@ void QQuickBasicProgressBarNode::sync(QQuickItem *item) m.translate(blockStartX(i), 0); transformNode->setMatrix(m); + // Set the color here too in case it was set after component completion, + // as updateCurrentTime doesn't sync it. + rectNode->setColor(bar->color()); rectNode->setRect(QRectF(QPointF(0, 0), QSizeF(BlockWidth, item->implicitHeight()))); rectNode->update(); @@ -165,10 +167,12 @@ void QQuickBasicProgressBarNode::sync(QQuickItem *item) QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(firstChild()); if (!rectNode) { rectNode = d->sceneGraphContext()->createInternalRectangleNode(); - rectNode->setColor(bar->color()); appendChildNode(rectNode); } + // Always set the color, not just when creating the rectangle node, so that we respect + // changes that are made after component completion. + rectNode->setColor(bar->color()); rectNode->setRect(QRectF(QPointF(0, 0), QSizeF(bar->progress() * item->width(), item->implicitHeight()))); rectNode->update(); } |