aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-10-18 15:36:26 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-10-19 11:33:02 +0000
commitdba57ed6f4c9fda4b6fd8b1aa1d61c31dcebd85e (patch)
tree0320a020af60d9d3f20a824df3700df0416f4cad /src
parentbea8a8d79fdbb6e84bfb5e667b3f312cebf7946a (diff)
Default: rewrite the indeterminate progress bar animation
Use a simple animated node instead of using the private animator API. Task-number: QTBUG-56601 Change-Id: Id8deb1e6ae48554bfa7b26b333247bf08c27aa09 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/ProgressBar.qml10
-rw-r--r--src/imports/controls/controls.pri4
-rw-r--r--src/imports/controls/qquickdefaultprogressbar.cpp277
-rw-r--r--src/imports/controls/qquickdefaultprogressbar_p.h (renamed from src/imports/controls/qquickprogressstrip_p.h)25
-rw-r--r--src/imports/controls/qquickprogressstrip.cpp315
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp5
6 files changed, 291 insertions, 345 deletions
diff --git a/src/imports/controls/ProgressBar.qml b/src/imports/controls/ProgressBar.qml
index a0d0912a..130adcec 100644
--- a/src/imports/controls/ProgressBar.qml
+++ b/src/imports/controls/ProgressBar.qml
@@ -48,18 +48,12 @@ T.ProgressBar {
contentItem.implicitHeight + topPadding + bottomPadding)
//! [contentItem]
- contentItem: ProgressStrip {
- id: strip
+ contentItem: ProgressBarImpl {
implicitHeight: 6
implicitWidth: 116
scale: control.mirrored ? -1 : 1
progress: control.position
- indeterminate: control.indeterminate
-
- ProgressStripAnimator {
- target: strip
- running: control.visible && control.indeterminate
- }
+ indeterminate: control.visible && control.indeterminate
}
//! [contentItem]
diff --git a/src/imports/controls/controls.pri b/src/imports/controls/controls.pri
index 0c1611e1..8a262694 100644
--- a/src/imports/controls/controls.pri
+++ b/src/imports/controls/controls.pri
@@ -1,13 +1,13 @@
HEADERS += \
- $$PWD/qquickprogressstrip_p.h \
$$PWD/qquickdialring_p.h \
$$PWD/qquickdefaultbusyindicator_p.h \
+ $$PWD/qquickdefaultprogressbar_p.h \
$$PWD/qquickdefaultstyle_p.h \
SOURCES += \
- $$PWD/qquickprogressstrip.cpp \
$$PWD/qquickdialring.cpp \
$$PWD/qquickdefaultbusyindicator.cpp \
+ $$PWD/qquickdefaultprogressbar.cpp \
$$PWD/qquickdefaultstyle.cpp
QML_CONTROLS = \
diff --git a/src/imports/controls/qquickdefaultprogressbar.cpp b/src/imports/controls/qquickdefaultprogressbar.cpp
new file mode 100644
index 00000000..a626bb32
--- /dev/null
+++ b/src/imports/controls/qquickdefaultprogressbar.cpp
@@ -0,0 +1,277 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qquickdefaultprogressbar_p.h"
+
+#include <QtCore/qeasingcurve.h>
+#include <QtCore/qelapsedtimer.h>
+#include <QtQuick/private/qquickitem_p.h>
+#include <QtQuick/private/qsgadaptationlayer_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static const int Blocks = 4;
+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 QRgb FillColor = 0x353637;
+
+static inline qreal blockStartX(int blockIndex)
+{
+ return ((blockIndex + 1) * -BlockWidth) - (blockIndex * BlockMovingSpacing);
+}
+
+static inline qreal blockRestX(int blockIndex, qreal availableWidth)
+{
+ const qreal spanRightEdgePos = availableWidth / 2 + BlockSpan / 2;
+ return spanRightEdgePos - (blockIndex + 1) * BlockWidth - (blockIndex * BlockRestingSpacing);
+}
+
+static inline qreal blockEndX(int blockIndex, qreal availableWidth)
+{
+ return availableWidth - blockStartX(Blocks - 1 - blockIndex) - BlockWidth;
+}
+
+class QQuickDefaultProgressBarNode : public QObject, public QSGTransformNode
+{
+public:
+ QQuickDefaultProgressBarNode(QQuickDefaultProgressBar *item);
+
+ void animate();
+ void sync(QQuickDefaultProgressBar *item);
+
+private:
+ bool m_indeterminate;
+ qreal m_pixelsPerSecond;
+ QElapsedTimer m_timer;
+};
+
+QQuickDefaultProgressBarNode::QQuickDefaultProgressBarNode(QQuickDefaultProgressBar *item)
+ : m_indeterminate(false), m_pixelsPerSecond(item->width())
+{
+ m_timer.start();
+}
+
+void QQuickDefaultProgressBarNode::animate()
+{
+ qint64 time = m_timer.elapsed();
+ if (time >= TotalDuration)
+ m_timer.restart();
+
+ QSGTransformNode *transformNode = static_cast<QSGTransformNode*>(firstChild());
+ for (int i = 0; i < Blocks; ++i) {
+ Q_ASSERT(transformNode->type() == QSGNode::TransformNodeType);
+
+ QMatrix4x4 m;
+ const qreal restX = blockRestX(i, m_pixelsPerSecond);
+ const qreal timeInSeconds = time / 1000.0;
+
+ if (time < SecondPhaseStart) {
+ // Move into the resting position for the first phase.
+ QEasingCurve easingCurve(QEasingCurve::InQuad);
+ const qreal easedCompletion = easingCurve.valueForProgress(time / qreal(SecondPhaseStart));
+ const qreal distance = m_pixelsPerSecond * (easedCompletion * (SecondPhaseStart / 1000.0));
+ const qreal position = blockStartX(i) + distance;
+ const qreal destination = restX;
+ m.translate(qMin(position, destination), 0);
+ } else if (time < ThirdPhaseStart) {
+ // Stay in the same position for the second phase.
+ m.translate(restX, 0);
+ } else {
+ // Move out of view for the third phase.
+ const int thirdPhaseSubKickoff = (BlockMovingSpacing / m_pixelsPerSecond) * 1000;
+ const int subphase = (time - ThirdPhaseStart) / thirdPhaseSubKickoff;
+ // If we're not at this subphase yet, don't try to animate movement,
+ // because it will be incorrect.
+ if (subphase < i)
+ return;
+
+ const qreal timeSinceSecondPhase = timeInSeconds - (ThirdPhaseStart / 1000.0);
+ // We only want to start keeping track of time once our subphase has started,
+ // otherwise we move too much because we account for time that has already elapsed.
+ // For example, if we were 60 milliseconds into the third subphase:
+ //
+ // 0 ..... 1 ..... 2 ...
+ // 100 100 60
+ //
+ // i == 0, timeSinceOurKickoff == 260
+ // i == 1, timeSinceOurKickoff == 160
+ // i == 2, timeSinceOurKickoff == 60
+ const qreal timeSinceOurKickoff = timeSinceSecondPhase - (thirdPhaseSubKickoff / 1000.0 * i);
+ const qreal position = restX + (m_pixelsPerSecond * (timeSinceOurKickoff));
+ const qreal destination = blockEndX(i, m_pixelsPerSecond);
+ m.translate(qMin(position, destination), 0);
+ }
+
+ transformNode->setMatrix(m);
+
+ transformNode = static_cast<QSGTransformNode*>(transformNode->nextSibling());
+ }
+}
+
+void QQuickDefaultProgressBarNode::sync(QQuickDefaultProgressBar *item)
+{
+ m_pixelsPerSecond = item->width();
+ if (m_indeterminate != item->isIndeterminate()) {
+ m_indeterminate = item->isIndeterminate();
+ QQuickWindow *window = item->window();
+ if (m_indeterminate) {
+ connect(window, &QQuickWindow::frameSwapped, window, &QQuickWindow::update);
+ connect(window, &QQuickWindow::beforeRendering, this, &QQuickDefaultProgressBarNode::animate);
+ } else {
+ disconnect(window, &QQuickWindow::frameSwapped, window, &QQuickWindow::update);
+ disconnect(window, &QQuickWindow::beforeRendering, this, &QQuickDefaultProgressBarNode::animate);
+ }
+ }
+
+ QQuickItemPrivate *d = QQuickItemPrivate::get(item);
+
+ QMatrix4x4 m;
+ m.translate(0, (item->height() - item->implicitHeight()) / 2);
+ setMatrix(m);
+
+ if (item->isIndeterminate()) {
+ if (childCount() != Blocks) {
+ // This was previously a regular progress bar; remove the old nodes.
+ removeAllChildNodes();
+ }
+
+ QSGTransformNode *transformNode = static_cast<QSGTransformNode*>(firstChild());
+ for (int i = 0; i < Blocks; ++i) {
+ if (!transformNode) {
+ transformNode = new QSGTransformNode;
+ appendChildNode(transformNode);
+ }
+
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(transformNode->firstChild());
+ if (!rectNode) {
+ rectNode = d->sceneGraphContext()->createInternalRectangleNode();
+ rectNode->setColor(FillColor);
+ transformNode->appendChildNode(rectNode);
+ }
+
+ QMatrix4x4 m;
+ m.translate(blockStartX(i), 0);
+ transformNode->setMatrix(m);
+
+ rectNode->setRect(QRectF(QPointF(0, 0), QSizeF(BlockWidth, item->implicitHeight())));
+ rectNode->update();
+
+ transformNode = static_cast<QSGTransformNode *>(transformNode->nextSibling());
+ }
+ } else {
+ if (childCount() > 1) {
+ // This was previously an indeterminate progress bar; remove the old nodes.
+ removeAllChildNodes();
+ }
+
+ QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(firstChild());
+ if (!rectNode) {
+ rectNode = d->sceneGraphContext()->createInternalRectangleNode();
+ rectNode->setColor(FillColor);
+ appendChildNode(rectNode);
+ }
+
+ rectNode->setRect(QRectF(QPointF(0, 0), QSizeF(item->progress() * item->width(), item->implicitHeight())));
+ rectNode->update();
+ }
+}
+
+QQuickDefaultProgressBar::QQuickDefaultProgressBar(QQuickItem *parent) :
+ QQuickItem(parent),
+ m_progress(0),
+ m_indeterminate(false)
+{
+ setFlag(ItemHasContents);
+}
+
+qreal QQuickDefaultProgressBar::progress() const
+{
+ return m_progress;
+}
+
+void QQuickDefaultProgressBar::setProgress(qreal progress)
+{
+ if (progress == m_progress)
+ return;
+
+ m_progress = progress;
+ update();
+ emit progressChanged();
+}
+
+bool QQuickDefaultProgressBar::isIndeterminate() const
+{
+ return m_indeterminate;
+}
+
+void QQuickDefaultProgressBar::setIndeterminate(bool indeterminate)
+{
+ if (indeterminate == m_indeterminate)
+ return;
+
+ m_indeterminate = indeterminate;
+ setClip(m_indeterminate);
+ update();
+ emit indeterminateChanged();
+}
+
+void QQuickDefaultProgressBar::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data)
+{
+ QQuickItem::itemChange(change, data);
+ if (change == ItemVisibleHasChanged)
+ update();
+}
+
+QSGNode *QQuickDefaultProgressBar::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *)
+{
+ QQuickDefaultProgressBarNode *node = static_cast<QQuickDefaultProgressBarNode *>(oldNode);
+ if (isVisible() && width() > 0 && height() > 0) {
+ if (!node)
+ node = new QQuickDefaultProgressBarNode(this);
+ node->sync(this);
+ } else {
+ delete node;
+ node = nullptr;
+ }
+ return node;
+}
+
+QT_END_NAMESPACE
diff --git a/src/imports/controls/qquickprogressstrip_p.h b/src/imports/controls/qquickdefaultprogressbar_p.h
index d2e297f5..ec228eee 100644
--- a/src/imports/controls/qquickprogressstrip_p.h
+++ b/src/imports/controls/qquickdefaultprogressbar_p.h
@@ -34,8 +34,8 @@
**
****************************************************************************/
-#ifndef QQUICKPROGRESSSTRIP_P_H
-#define QQUICKPROGRESSSTRIP_P_H
+#ifndef QQUICKDEFAULTPROGRESSBAR_P_H
+#define QQUICKDEFAULTPROGRESSBAR_P_H
//
// W A R N I N G
@@ -49,19 +49,17 @@
//
#include <QtQuick/qquickitem.h>
-#include <QtQuick/private/qquickanimatorjob_p.h>
QT_BEGIN_NAMESPACE
-class QQuickProgressStrip : public QQuickItem
+class QQuickDefaultProgressBar : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(bool indeterminate READ isIndeterminate WRITE setIndeterminate NOTIFY indeterminateChanged FINAL)
Q_PROPERTY(qreal progress READ progress WRITE setProgress NOTIFY progressChanged FINAL)
public:
- explicit QQuickProgressStrip(QQuickItem *parent = nullptr);
- ~QQuickProgressStrip();
+ explicit QQuickDefaultProgressBar(QQuickItem *parent = nullptr);
bool isIndeterminate() const;
void setIndeterminate(bool indeterminate);
@@ -74,6 +72,7 @@ Q_SIGNALS:
void indeterminateChanged();
protected:
+ void itemChange(ItemChange change, const ItemChangeData &data) override;
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override;
private:
@@ -81,16 +80,8 @@ private:
bool m_indeterminate;
};
-class QQuickProgressAnimator : public QQuickAnimator
-{
-public:
- QQuickProgressAnimator(QObject *parent = nullptr);
-
-protected:
- QString propertyName() const override;
- QQuickAnimatorJob *createJob() const override;
-};
-
QT_END_NAMESPACE
-#endif // QQUICKPROGRESSSTRIP_P_H
+QML_DECLARE_TYPE(QQuickDefaultProgressBar)
+
+#endif // QQUICKDEFAULTPROGRESSBAR_P_H
diff --git a/src/imports/controls/qquickprogressstrip.cpp b/src/imports/controls/qquickprogressstrip.cpp
deleted file mode 100644
index 33a21848..00000000
--- a/src/imports/controls/qquickprogressstrip.cpp
+++ /dev/null
@@ -1,315 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL3$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qquickprogressstrip_p.h"
-
-#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/qsgrectanglenode.h>
-
-QT_BEGIN_NAMESPACE
-
-class QQuickProgressAnimatorJob : public QQuickAnimatorJob
-{
-public:
- QQuickProgressAnimatorJob();
- ~QQuickProgressAnimatorJob();
-
- void initialize(QQuickAnimatorController *controller) override;
- void afterNodeSync() override;
- void updateCurrentTime(int time) override;
- void writeBack() override;
- void nodeWasDestroyed() override;
-
-private:
- QSGNode *m_node;
-};
-
-QQuickProgressStrip::QQuickProgressStrip(QQuickItem *parent) :
- QQuickItem(parent),
- m_progress(0),
- m_indeterminate(false)
-{
- setFlag(QQuickItem::ItemHasContents);
-}
-
-QQuickProgressStrip::~QQuickProgressStrip()
-{
-}
-
-qreal QQuickProgressStrip::progress() const
-{
- return m_progress;
-}
-
-void QQuickProgressStrip::setProgress(qreal progress)
-{
- if (progress == m_progress)
- return;
-
- m_progress = progress;
- update();
- emit progressChanged();
-}
-
-bool QQuickProgressStrip::isIndeterminate() const
-{
- return m_indeterminate;
-}
-
-void QQuickProgressStrip::setIndeterminate(bool indeterminate)
-{
- if (indeterminate == m_indeterminate)
- return;
-
- m_indeterminate = indeterminate;
- setClip(m_indeterminate);
- update();
- emit indeterminateChanged();
-}
-
-static const int blocks = 4;
-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 animationDuration = 4000;
-static const int secondPhaseStart = animationDuration * 0.4;
-static const int thirdPhaseStart = animationDuration * 0.6;
-
-static inline qreal blockStartX(int blockIndex)
-{
- return ((blockIndex + 1) * -blockWidth) - (blockIndex * blockMovingSpacing);
-}
-
-static inline qreal blockRestX(int blockIndex, qreal availableWidth)
-{
- const qreal spanRightEdgePos = availableWidth / 2 + blockSpan / 2;
- return spanRightEdgePos - (blockIndex + 1) * blockWidth - (blockIndex * blockRestingSpacing);
-}
-
-static inline qreal blockEndX(int blockIndex, qreal availableWidth)
-{
- return availableWidth - blockStartX(blocks - 1 - blockIndex) - blockWidth;
-}
-
-QSGNode *QQuickProgressStrip::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *)
-{
- QQuickItemPrivate *d = QQuickItemPrivate::get(this);
-
- if (!oldNode) {
- oldNode = window()->createRectangleNode();
- static_cast<QSGRectangleNode *>(oldNode)->setColor(Qt::transparent);
- }
- static_cast<QSGRectangleNode *>(oldNode)->setRect(boundingRect());
-
- QSGTransformNode *rootTransformNode = static_cast<QSGTransformNode *>(oldNode->firstChild());
- if (!rootTransformNode) {
- rootTransformNode = new QSGTransformNode;
- oldNode->appendChildNode(rootTransformNode);
- }
- Q_ASSERT(rootTransformNode->type() == QSGNode::TransformNodeType);
-
- const qreal y = (height() - implicitHeight()) / 2;
- const QColor color(0x35, 0x36, 0x37);
- if (m_indeterminate) {
- if (rootTransformNode->childCount() != blocks) {
- // This was previously a regular progress bar; remove the old nodes.
- rootTransformNode->removeAllChildNodes();
- }
-
- QSGTransformNode *transformNode = static_cast<QSGTransformNode*>(rootTransformNode->firstChild());
- for (int i = 0; i < blocks; ++i) {
- if (!transformNode) {
- transformNode = new QSGTransformNode;
- rootTransformNode->appendChildNode(transformNode);
- }
-
- QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(transformNode->firstChild());
- if (!rectNode) {
- rectNode = d->sceneGraphContext()->createInternalRectangleNode();
- rectNode->setColor(color);
- transformNode->appendChildNode(rectNode);
- }
-
- QMatrix4x4 m;
- m.translate(blockStartX(i), 0);
- transformNode->setMatrix(m);
-
- rectNode->setRect(QRectF(QPointF(0, y), QSizeF(blockWidth, implicitHeight())));
- rectNode->update();
-
- transformNode = static_cast<QSGTransformNode *>(transformNode->nextSibling());
- }
- } else {
- if (rootTransformNode->childCount() > 1) {
- // This was previously an indeterminate progress bar; remove the old nodes.
- rootTransformNode->removeAllChildNodes();
- }
-
- QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(rootTransformNode->firstChild());
- if (!rectNode) {
- rectNode = d->sceneGraphContext()->createInternalRectangleNode();
- rectNode->setColor(color);
- rootTransformNode->appendChildNode(rectNode);
- }
-
- rectNode->setRect(QRectF(QPointF(0, y), QSizeF(m_progress * width(), implicitHeight())));
- rectNode->update();
- }
-
- return oldNode;
-}
-
-QQuickProgressAnimator::QQuickProgressAnimator(QObject *parent) :
- QQuickAnimator(parent)
-{
- setDuration(animationDuration);
- setLoops(QQuickAnimator::Infinite);
-}
-
-QString QQuickProgressAnimator::propertyName() const
-{
- return QString();
-}
-
-QQuickAnimatorJob *QQuickProgressAnimator::createJob() const
-{
- return new QQuickProgressAnimatorJob;
-}
-
-QQuickProgressAnimatorJob::QQuickProgressAnimatorJob() :
- m_node(nullptr)
-{
-}
-
-QQuickProgressAnimatorJob::~QQuickProgressAnimatorJob()
-{
-}
-
-void QQuickProgressAnimatorJob::initialize(QQuickAnimatorController *controller)
-{
- QQuickAnimatorJob::initialize(controller);
- m_node = QQuickItemPrivate::get(m_target)->childContainerNode();
-}
-
-void QQuickProgressAnimatorJob::afterNodeSync()
-{
- m_node = QQuickItemPrivate::get(m_target)->childContainerNode();
-}
-
-void QQuickProgressAnimatorJob::updateCurrentTime(int time)
-{
- if (!m_node)
- return;
-
- QSGRectangleNode *rootRectNode = static_cast<QSGRectangleNode *>(m_node->firstChild());
- if (!rootRectNode)
- return;
- Q_ASSERT(rootRectNode->type() == QSGNode::GeometryNodeType);
-
- QSGTransformNode *rootTransformNode = static_cast<QSGTransformNode*>(rootRectNode->firstChild());
- Q_ASSERT(rootTransformNode->type() == QSGNode::TransformNodeType);
-
- QSGTransformNode *transformNode = static_cast<QSGTransformNode*>(rootTransformNode->firstChild());
- // This function can be called without the relevant nodes having been created yet,
- // which can happen if you set indeterminate to true at runtime.
- if (!transformNode || transformNode->type() != QSGNode::TransformNodeType)
- return;
-
- const qreal pixelsPerSecond = rootRectNode->rect().width();
-
- for (int i = 0; i < blocks; ++i) {
- QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(transformNode->firstChild());
- Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType);
-
- QMatrix4x4 m;
- const qreal restX = blockRestX(i, rootRectNode->rect().width());
- const qreal timeInSeconds = time / 1000.0;
-
- if (time < secondPhaseStart) {
- // Move into the resting position for the first phase.
- QEasingCurve easingCurve(QEasingCurve::InQuad);
- const qreal easedCompletion = easingCurve.valueForProgress(time / qreal(secondPhaseStart));
- const qreal distance = pixelsPerSecond * (easedCompletion * (secondPhaseStart / 1000.0));
- const qreal position = blockStartX(i) + distance;
- const qreal destination = restX;
- m.translate(qMin(position, destination), 0);
- } else if (time < thirdPhaseStart) {
- // Stay in the same position for the second phase.
- m.translate(restX, 0);
- } else {
- // Move out of view for the third phase.
- const int thirdPhaseSubKickoff = (blockMovingSpacing / pixelsPerSecond) * 1000;
- const int subphase = (time - thirdPhaseStart) / thirdPhaseSubKickoff;
- // If we're not at this subphase yet, don't try to animate movement,
- // because it will be incorrect.
- if (subphase < i)
- return;
-
- const qreal timeSinceSecondPhase = timeInSeconds - (thirdPhaseStart / 1000.0);
- // We only want to start keeping track of time once our subphase has started,
- // otherwise we move too much because we account for time that has already elapsed.
- // For example, if we were 60 milliseconds into the third subphase:
- //
- // 0 ..... 1 ..... 2 ...
- // 100 100 60
- //
- // i == 0, timeSinceOurKickoff == 260
- // i == 1, timeSinceOurKickoff == 160
- // i == 2, timeSinceOurKickoff == 60
- const qreal timeSinceOurKickoff = timeSinceSecondPhase - (thirdPhaseSubKickoff / 1000.0 * i);
- const qreal position = restX + (pixelsPerSecond * (timeSinceOurKickoff));
- const qreal destination = blockEndX(i, rootRectNode->rect().width());
- m.translate(qMin(position, destination), 0);
- }
-
- transformNode->setMatrix(m);
- rectNode->update();
-
- transformNode = static_cast<QSGTransformNode*>(transformNode->nextSibling());
- }
-}
-
-void QQuickProgressAnimatorJob::writeBack()
-{
-}
-
-void QQuickProgressAnimatorJob::nodeWasDestroyed()
-{
- m_node = nullptr;
-}
-
-QT_END_NAMESPACE
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index db853f56..6802171f 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -48,9 +48,9 @@
#include <QtQuickControls2/private/qquicktumblerview_p.h>
#include "qquickdefaultbusyindicator_p.h"
+#include "qquickdefaultprogressbar_p.h"
#include "qquickdefaultstyle_p.h"
#include "qquickdialring_p.h"
-#include "qquickprogressstrip_p.h"
static inline void initResources()
{
@@ -164,8 +164,7 @@ void QtQuickControls2Plugin::initializeEngine(QQmlEngine *engine, const char *ur
const QByteArray import = QByteArray(uri) + ".impl";
qmlRegisterType<QQuickDefaultBusyIndicator>(import, 2, 0, "BusyIndicatorImpl");
- qmlRegisterType<QQuickProgressStrip>(import, 2, 0, "ProgressStrip");
- qmlRegisterType<QQuickProgressAnimator>(import, 2, 0, "ProgressStripAnimator");
+ qmlRegisterType<QQuickDefaultProgressBar>(import, 2, 0, "ProgressBarImpl");
qmlRegisterType<QQuickDialRing>(import, 2, 0, "DialRing");
qmlRegisterType<QQuickTumblerView>(import, 2, 1, "TumblerView");
qmlRegisterSingletonType<QQuickDefaultStyle>(import, 2, 1, "Default", styleSingleton);