diff options
Diffstat (limited to 'src/imports/controls/universal/qquickuniversalprogressring.cpp')
-rw-r--r-- | src/imports/controls/universal/qquickuniversalprogressring.cpp | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/src/imports/controls/universal/qquickuniversalprogressring.cpp b/src/imports/controls/universal/qquickuniversalprogressring.cpp index 2fe66047..ac087c78 100644 --- a/src/imports/controls/universal/qquickuniversalprogressring.cpp +++ b/src/imports/controls/universal/qquickuniversalprogressring.cpp @@ -1,9 +1,9 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2016 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** -** This file is part of the Qt Labs Controls module of the Qt Toolkit. +** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL3$ ** Commercial License Usage @@ -53,11 +53,11 @@ class QQuickUniversalProgressRingAnimatorJob : public QQuickAnimatorJob public: QQuickUniversalProgressRingAnimatorJob(); - void initialize(QQuickAnimatorController *controller) Q_DECL_OVERRIDE; - void updateCurrentTime(int time) Q_DECL_OVERRIDE; - void writeBack() Q_DECL_OVERRIDE; - void nodeWasDestroyed() Q_DECL_OVERRIDE; - void afterNodeSync() Q_DECL_OVERRIDE; + void initialize(QQuickAnimatorController *controller) override; + void updateCurrentTime(int time) override; + void writeBack() override; + void nodeWasDestroyed() override; + void afterNodeSync() override; private: struct Phase { @@ -73,7 +73,7 @@ private: Phase m_phases[PhaseCount]; }; -QQuickUniversalProgressRingAnimatorJob::QQuickUniversalProgressRingAnimatorJob() : m_node(Q_NULLPTR) +QQuickUniversalProgressRingAnimatorJob::QQuickUniversalProgressRingAnimatorJob() : m_node(nullptr) { m_phases[0] = Phase(433, -110, 10, QEasingCurve::BezierSpline); m_phases[1] = Phase(767, 10, 93, QEasingCurve::Linear ); @@ -121,7 +121,7 @@ void QQuickUniversalProgressRingAnimatorJob::updateCurrentTime(int time) if (visible) { int phaseIndex, remain = time, elapsed = 0; - for (phaseIndex = 0; phaseIndex < PhaseCount; ++phaseIndex) { + for (phaseIndex = 0; phaseIndex < PhaseCount - 1; ++phaseIndex) { if (remain <= m_phases[phaseIndex].duration + begin) break; remain -= m_phases[phaseIndex].duration; @@ -153,7 +153,7 @@ void QQuickUniversalProgressRingAnimatorJob::writeBack() void QQuickUniversalProgressRingAnimatorJob::nodeWasDestroyed() { - m_node = Q_NULLPTR; + m_node = nullptr; } void QQuickUniversalProgressRingAnimatorJob::afterNodeSync() @@ -191,11 +191,12 @@ int QQuickUniversalProgressRing::count() const void QQuickUniversalProgressRing::setCount(int count) { - if (m_count != count) { - m_count = count; - update(); - emit countChanged(); - } + if (m_count == count) + return; + + m_count = count; + update(); + emit countChanged(); } QColor QQuickUniversalProgressRing::color() const @@ -205,11 +206,12 @@ QColor QQuickUniversalProgressRing::color() const void QQuickUniversalProgressRing::setColor(const QColor &color) { - if (m_color != color) { - m_color = color; - update(); - emit colorChanged(); - } + if (m_color == color) + return; + + m_color = color; + update(); + emit colorChanged(); } QSGNode *QQuickUniversalProgressRing::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) @@ -228,6 +230,7 @@ QSGNode *QQuickUniversalProgressRing::updatePaintNode(QSGNode *oldNode, UpdatePa qreal diameter = size / 10.0; qreal radius = diameter / 2; qreal offset = (size - diameter * 2) / M_PI; + const QRectF rect(offset, offset, diameter, diameter); QSGNode *transformNode = oldNode->firstChild(); for (int i = 0; i < m_count; ++i) { @@ -249,7 +252,7 @@ QSGNode *QQuickUniversalProgressRing::updatePaintNode(QSGNode *oldNode, UpdatePa QSGRectangleNode *rectNode = static_cast<QSGRectangleNode *>(opacityNode->firstChild()); Q_ASSERT(rectNode->type() == QSGNode::GeometryNodeType); - rectNode->setRect(QRectF(offset, offset, diameter, diameter)); + rectNode->setRect(rect); rectNode->setColor(m_color); rectNode->setRadius(radius); rectNode->update(); |