aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/controls/material/qquickmaterialprogressring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/controls/material/qquickmaterialprogressring.cpp')
-rw-r--r--src/imports/controls/material/qquickmaterialprogressring.cpp57
1 files changed, 29 insertions, 28 deletions
diff --git a/src/imports/controls/material/qquickmaterialprogressring.cpp b/src/imports/controls/material/qquickmaterialprogressring.cpp
index c11a347f..8407c7c2 100644
--- a/src/imports/controls/material/qquickmaterialprogressring.cpp
+++ b/src/imports/controls/material/qquickmaterialprogressring.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 Quick 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
@@ -67,13 +67,15 @@ public:
QQuickMaterialRingAnimatorJob();
~QQuickMaterialRingAnimatorJob();
- 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:
+ int m_lastStartAngle;
+ int m_lastEndAngle;
qreal m_devicePixelRatio;
QSGNode *m_containerNode;
QQuickWindow *m_window;
@@ -134,11 +136,12 @@ QColor QQuickMaterialProgressRing::color() const
void QQuickMaterialProgressRing::setColor(QColor color)
{
- if (m_color != color) {
- m_color = color;
- update();
- emit colorChanged();
- }
+ if (m_color == color)
+ return;
+
+ m_color = color;
+ update();
+ emit colorChanged();
}
static const int spanAnimationDuration = 700;
@@ -166,9 +169,11 @@ QQuickAnimatorJob *QQuickMaterialRingAnimator::createJob() const
}
QQuickMaterialRingAnimatorJob::QQuickMaterialRingAnimatorJob() :
+ m_lastStartAngle(0),
+ m_lastEndAngle(0),
m_devicePixelRatio(1.0),
- m_containerNode(Q_NULLPTR),
- m_window(Q_NULLPTR)
+ m_containerNode(nullptr),
+ m_window(nullptr)
{
}
@@ -214,29 +219,25 @@ void QQuickMaterialRingAnimatorJob::updateCurrentTime(int time)
const int iteration = time / spanAnimationDuration;
int startAngle = 0;
int endAngle = 0;
- static int lastStartAngle = 0;
- static int lastEndAngle = 0;
if (iteration % 2 == 0) {
- if (lastStartAngle > 360 * oneDegree) {
- lastStartAngle -= 360 * oneDegree;
+ if (m_lastStartAngle > 360 * oneDegree) {
+ m_lastStartAngle -= 360 * oneDegree;
}
// The start angle is only affected by the rotation animation for the "grow" phase.
- startAngle = lastStartAngle;
- // TODO: use the correct curve here. QEasingCurve's bezier API doesn't support SVG path data.
+ startAngle = m_lastStartAngle;
QEasingCurve angleCurve(QEasingCurve::OutQuad);
const qreal percentage = angleCurve.valueForProgress(spanPercentageComplete);
- endAngle = lastStartAngle + minSweepSpan + percentage * (maxSweepSpan - minSweepSpan);
- lastEndAngle = endAngle;
+ endAngle = m_lastStartAngle + minSweepSpan + percentage * (maxSweepSpan - minSweepSpan);
+ m_lastEndAngle = endAngle;
} else {
// Both the start angle *and* the span are affected by the "shrink" phase.
- // TODO: use the correct curve here. QEasingCurve's bezier API doesn't support SVG path data.
QEasingCurve angleCurve(QEasingCurve::InQuad);
const qreal percentage = angleCurve.valueForProgress(spanPercentageComplete);
- startAngle = lastEndAngle - maxSweepSpan + percentage * (maxSweepSpan - minSweepSpan);
- endAngle = lastEndAngle;
- lastStartAngle = startAngle;
+ startAngle = m_lastEndAngle - maxSweepSpan + percentage * (maxSweepSpan - minSweepSpan);
+ endAngle = m_lastEndAngle;
+ m_lastStartAngle = startAngle;
}
const int halfPen = pen.width() / 2;
@@ -258,8 +259,8 @@ void QQuickMaterialRingAnimatorJob::writeBack()
void QQuickMaterialRingAnimatorJob::nodeWasDestroyed()
{
- m_containerNode = Q_NULLPTR;
- m_window = Q_NULLPTR;
+ m_containerNode = nullptr;
+ m_window = nullptr;
}
void QQuickMaterialRingAnimatorJob::afterNodeSync()