aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/util')
-rw-r--r--src/quick/util/qquickanimation.cpp68
-rw-r--r--src/quick/util/qquickanimation_p.h79
-rw-r--r--src/quick/util/qquickanimation_p_p.h18
-rw-r--r--src/quick/util/qquickanimationcontroller.cpp8
-rw-r--r--src/quick/util/qquickanimationcontroller_p.h2
-rw-r--r--src/quick/util/qquickanimator.cpp10
-rw-r--r--src/quick/util/qquickanimator_p.h16
-rw-r--r--src/quick/util/qquickanimatorcontroller.cpp4
-rw-r--r--src/quick/util/qquickanimatorjob.cpp16
-rw-r--r--src/quick/util/qquickanimatorjob_p.h2
-rw-r--r--src/quick/util/qquickapplication_p.h2
-rw-r--r--src/quick/util/qquickbehavior.cpp28
-rw-r--r--src/quick/util/qquickbehavior_p.h6
-rw-r--r--src/quick/util/qquickfontloader.cpp21
-rw-r--r--src/quick/util/qquickfontloader_p.h2
-rw-r--r--src/quick/util/qquickfontmetrics.cpp4
-rw-r--r--src/quick/util/qquickfontmetrics_p.h2
-rw-r--r--src/quick/util/qquickglobal.cpp45
-rw-r--r--src/quick/util/qquickimageprovider.cpp62
-rw-r--r--src/quick/util/qquickimageprovider.h15
-rw-r--r--src/quick/util/qquickimageprovider_p.h72
-rw-r--r--src/quick/util/qquickpath.cpp269
-rw-r--r--src/quick/util/qquickpath_p.h135
-rw-r--r--src/quick/util/qquickpath_p_p.h9
-rw-r--r--src/quick/util/qquickpathinterpolator.cpp4
-rw-r--r--src/quick/util/qquickpathinterpolator_p.h2
-rw-r--r--src/quick/util/qquickpixmapcache.cpp237
-rw-r--r--src/quick/util/qquickprofiler.cpp9
-rw-r--r--src/quick/util/qquickprofiler_p.h13
-rw-r--r--src/quick/util/qquickpropertychanges.cpp101
-rw-r--r--src/quick/util/qquickpropertychanges_p.h6
-rw-r--r--src/quick/util/qquickshortcut.cpp8
-rw-r--r--src/quick/util/qquickshortcut_p.h8
-rw-r--r--src/quick/util/qquicksmoothedanimation.cpp2
-rw-r--r--src/quick/util/qquicksmoothedanimation_p.h4
-rw-r--r--src/quick/util/qquicksmoothedanimation_p_p.h6
-rw-r--r--src/quick/util/qquickspringanimation.cpp6
-rw-r--r--src/quick/util/qquickspringanimation_p.h4
-rw-r--r--src/quick/util/qquickstate.cpp29
-rw-r--r--src/quick/util/qquickstate_p.h14
-rw-r--r--src/quick/util/qquickstate_p_p.h12
-rw-r--r--src/quick/util/qquickstatechangescript.cpp2
-rw-r--r--src/quick/util/qquickstatechangescript_p.h2
-rw-r--r--src/quick/util/qquickstategroup.cpp29
-rw-r--r--src/quick/util/qquickstategroup_p.h2
-rw-r--r--src/quick/util/qquickstyledtext.cpp26
-rw-r--r--src/quick/util/qquickstyledtext_p.h12
-rw-r--r--src/quick/util/qquicksvgparser.cpp13
-rw-r--r--src/quick/util/qquicksystempalette.cpp2
-rw-r--r--src/quick/util/qquicksystempalette_p.h2
-rw-r--r--src/quick/util/qquicktextmetrics.cpp4
-rw-r--r--src/quick/util/qquicktimeline.cpp32
-rw-r--r--src/quick/util/qquicktimeline_p_p.h6
-rw-r--r--src/quick/util/qquicktransition.cpp33
-rw-r--r--src/quick/util/qquicktransition_p.h17
-rw-r--r--src/quick/util/qquicktransitionmanager.cpp63
-rw-r--r--src/quick/util/qquicktransitionmanager_p_p.h2
-rw-r--r--src/quick/util/qquickutilmodule.cpp5
-rw-r--r--src/quick/util/qquickvalidator.cpp25
-rw-r--r--src/quick/util/qquickvalidator_p.h4
-rw-r--r--src/quick/util/qquickvaluetypes.cpp23
-rw-r--r--src/quick/util/qquickvaluetypes_p.h8
-rw-r--r--src/quick/util/util.pri3
63 files changed, 1152 insertions, 523 deletions
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index bfac46adb9..02be9daac0 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickAbstractAnimation
\inqmlmodule QtQuick
\ingroup qtquick-transitions-animations
- \brief Is the base of all QML animations
+ \brief Is the base of all QML animations.
The Animation type cannot be used directly in a QML file. It exists
to provide a set of common properties and methods, available across all the
@@ -91,7 +91,7 @@ QQuickAbstractAnimation::~QQuickAbstractAnimation()
{
Q_D(QQuickAbstractAnimation);
if (d->group)
- setGroup(0); //remove from group
+ setGroup(nullptr); //remove from group
delete d->animationInstance;
}
@@ -234,6 +234,27 @@ QQmlProperty QQuickAbstractAnimationPrivate::createProperty(QObject *obj, const
The corresponding handler is \c onStopped.
*/
+/*!
+ \qmlsignal QtQuick::Animation::finished()
+ \since 5.12
+
+ This signal is emitted when the animation has finished naturally.
+
+ It is not emitted when \l running is set to \c false, nor for animations whose
+ \l loops property is set to \c Animation.Infinite.
+
+ In addition, it is only emitted for top-level, standalone animations. It
+ will not be emitted for animations in a Behavior or Transition, or
+ animations that are part of an animation group.
+
+ If \l alwaysRunToEnd is true, this signal will not be emitted until the
+ animation has completed its current iteration.
+
+ The corresponding handler is \c onFinished.
+
+ \sa stopped(), started(), running
+*/
+
void QQuickAbstractAnimation::setRunning(bool r)
{
Q_D(QQuickAbstractAnimation);
@@ -643,7 +664,7 @@ QAbstractAnimationJob* QQuickAbstractAnimation::transition(QQuickStateActions &a
Q_UNUSED(modified);
Q_UNUSED(direction);
Q_UNUSED(defaultTarget);
- return 0;
+ return nullptr;
}
void QQuickAbstractAnimationPrivate::animationFinished(QAbstractAnimationJob*)
@@ -656,6 +677,7 @@ void QQuickAbstractAnimationPrivate::animationFinished(QAbstractAnimationJob*)
if (loopCount != 1)
animationInstance->setLoopCount(loopCount);
}
+ emit q->finished();
}
QQuickAbstractAnimation::ThreadingModel QQuickAbstractAnimation::threadingModel() const
@@ -669,7 +691,7 @@ QQuickAbstractAnimation::ThreadingModel QQuickAbstractAnimation::threadingModel(
\inqmlmodule QtQuick
\ingroup qtquick-transitions-animations
\inherits Animation
- \brief Provides a pause for an animation
+ \brief Provides a pause for an animation.
When used in a SequentialAnimation, PauseAnimation is a step when
nothing happens, for a specified duration.
@@ -740,7 +762,7 @@ QAbstractAnimationJob* QQuickPauseAnimation::transition(QQuickStateActions &acti
\inqmlmodule QtQuick
\ingroup qtquick-animation-properties
\inherits PropertyAnimation
- \brief Animates changes in color values
+ \brief Animates changes in color values.
ColorAnimation is a specialized PropertyAnimation that defines an
animation to be applied when a color value changes.
@@ -838,7 +860,7 @@ void QQuickColorAnimation::setTo(const QColor &t)
}
QActionAnimation::QActionAnimation()
- : QAbstractAnimationJob(), animAction(0)
+ : QAbstractAnimationJob(), animAction(nullptr)
{
}
@@ -898,7 +920,7 @@ void QActionAnimation::debugAnimation(QDebug d) const
\inqmlmodule QtQuick
\ingroup qtquick-transitions-animations
\inherits Animation
- \brief Defines scripts to be run during an animation
+ \brief Defines scripts to be run during an animation.
ScriptAction can be used to run a script at a specific point in an animation.
@@ -1041,7 +1063,7 @@ QAbstractAnimationJob* QQuickScriptAction::transition(QQuickStateActions &action
\inqmlmodule QtQuick
\ingroup qtquick-transitions-animations
\inherits Animation
- \brief Specifies immediate property changes during animation
+ \brief Specifies immediate property changes during animation.
PropertyAction is used to specify an immediate property change during an
animation. The property change is not animated.
@@ -1302,7 +1324,7 @@ QAbstractAnimationJob* QQuickPropertyAction::transition(QQuickStateActions &acti
\inqmlmodule QtQuick
\ingroup qtquick-animation-properties
\inherits PropertyAnimation
- \brief Animates changes in qreal-type values
+ \brief Animates changes in qreal-type values.
NumberAnimation is a specialized PropertyAnimation that defines an
animation to be applied when a numerical value changes.
@@ -1415,7 +1437,7 @@ void QQuickNumberAnimation::setTo(qreal t)
\inqmlmodule QtQuick
\ingroup qtquick-animation-properties
\inherits PropertyAnimation
- \brief Animates changes in QVector3d values
+ \brief Animates changes in QVector3d values.
Vector3dAnimation is a specialized PropertyAnimation that defines an
animation to be applied when a Vector3d value changes.
@@ -1492,7 +1514,7 @@ void QQuickVector3dAnimation::setTo(QVector3D t)
\inqmlmodule QtQuick
\ingroup qtquick-animation-properties
\inherits PropertyAnimation
- \brief Animates changes in rotation values
+ \brief Animates changes in rotation values.
RotationAnimation is a specialized PropertyAnimation that gives control
over the direction of rotation during an animation.
@@ -1666,13 +1688,13 @@ void QQuickRotationAnimation::setDirection(QQuickRotationAnimation::RotationDire
d->direction = direction;
switch(d->direction) {
case Clockwise:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateClockwiseRotation);
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&_q_interpolateClockwiseRotation));
break;
case Counterclockwise:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateCounterclockwiseRotation);
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&_q_interpolateCounterclockwiseRotation));
break;
case Shortest:
- d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(&_q_interpolateShortestRotation);
+ d->interpolator = reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void *>(&_q_interpolateShortestRotation));
break;
default:
d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType);
@@ -1706,7 +1728,7 @@ void QQuickAnimationGroupPrivate::clear_animation(QQmlListProperty<QQuickAbstrac
if (q) {
while (q->d_func()->animations.count()) {
QQuickAbstractAnimation *firstAnim = q->d_func()->animations.at(0);
- firstAnim->setGroup(0);
+ firstAnim->setGroup(nullptr);
}
}
}
@@ -1715,7 +1737,7 @@ QQuickAnimationGroup::~QQuickAnimationGroup()
{
Q_D(QQuickAnimationGroup);
for (int i = 0; i < d->animations.count(); ++i)
- d->animations.at(i)->d_func()->group = 0;
+ d->animations.at(i)->d_func()->group = nullptr;
d->animations.clear();
}
@@ -1734,7 +1756,7 @@ QQmlListProperty<QQuickAbstractAnimation> QQuickAnimationGroup::animations()
\inqmlmodule QtQuick
\ingroup qtquick-transitions-animations
\inherits Animation
- \brief Allows animations to be run sequentially
+ \brief Allows animations to be run sequentially.
The SequentialAnimation and ParallelAnimation types allow multiple
animations to be run together. Animations defined in a SequentialAnimation
@@ -1828,7 +1850,7 @@ QAbstractAnimationJob* QQuickSequentialAnimation::transition(QQuickStateActions
\inqmlmodule QtQuick
\ingroup qtquick-transitions-animations
\inherits Animation
- \brief Enables animations to be run in parallel
+ \brief Enables animations to be run in parallel.
The SequentialAnimation and ParallelAnimation types allow multiple
animations to be run together. Animations defined in a SequentialAnimation
@@ -1937,7 +1959,7 @@ void QQuickPropertyAnimationPrivate::convertVariant(QVariant &variant, int type)
}
QQuickBulkValueAnimator::QQuickBulkValueAnimator()
- : QAbstractAnimationJob(), animValue(0), fromSourced(0), m_duration(250)
+ : QAbstractAnimationJob(), animValue(nullptr), fromSourced(nullptr), m_duration(250)
{
}
@@ -1991,7 +2013,7 @@ void QQuickBulkValueAnimator::debugAnimation(QDebug d) const
\inqmlmodule QtQuick
\ingroup qtquick-animation-properties
\inherits Animation
- \brief Animates changes in property values
+ \brief Animates changes in property values.
PropertyAnimation provides a way to animate changes to a property's value.
@@ -2112,7 +2134,7 @@ void QQuickPropertyAnimation::setFrom(const QVariant &f)
return;
d->from = f;
d->fromIsDefined = f.isValid();
- emit fromChanged(f);
+ emit fromChanged();
}
/*!
@@ -2139,7 +2161,7 @@ void QQuickPropertyAnimation::setTo(const QVariant &t)
return;
d->to = t;
d->toIsDefined = t.isValid();
- emit toChanged(t);
+ emit toChanged();
}
/*!
@@ -2556,7 +2578,7 @@ void QQuickAnimationPropertyUpdater::setValue(qreal v)
if (deleted)
return;
}
- wasDeleted = 0;
+ wasDeleted = nullptr;
fromSourced = true;
}
diff --git a/src/quick/util/qquickanimation_p.h b/src/quick/util/qquickanimation_p.h
index e27871dcaa..746cb938bd 100644
--- a/src/quick/util/qquickanimation_p.h
+++ b/src/quick/util/qquickanimation_p.h
@@ -87,8 +87,8 @@ public:
AnyThread
};
- QQuickAbstractAnimation(QObject *parent=0);
- virtual ~QQuickAbstractAnimation();
+ QQuickAbstractAnimation(QObject *parent=nullptr);
+ ~QQuickAbstractAnimation() override;
enum Loops { Infinite = -2 };
Q_ENUM(Loops)
@@ -126,6 +126,7 @@ Q_SIGNALS:
void pausedChanged(bool);
void alwaysRunToEndChanged(bool);
void loopCountChanged(int);
+ Q_REVISION(12) void finished();
public Q_SLOTS:
void restart();
@@ -144,7 +145,7 @@ public:
virtual QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = nullptr);
QAbstractAnimationJob* qtAnimation();
private Q_SLOTS:
@@ -166,8 +167,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPauseAnimation : public QQuickAbstractAnimati
Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged)
public:
- QQuickPauseAnimation(QObject *parent=0);
- virtual ~QQuickPauseAnimation();
+ QQuickPauseAnimation(QObject *parent=nullptr);
+ ~QQuickPauseAnimation() override;
int duration() const;
void setDuration(int);
@@ -179,7 +180,7 @@ protected:
QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0) override;
+ QObject *defaultTarget = nullptr) override;
};
class QQuickScriptActionPrivate;
@@ -192,8 +193,8 @@ class QQuickScriptAction : public QQuickAbstractAnimation
Q_PROPERTY(QString scriptName READ stateChangeScriptName WRITE setStateChangeScriptName)
public:
- QQuickScriptAction(QObject *parent=0);
- virtual ~QQuickScriptAction();
+ QQuickScriptAction(QObject *parent=nullptr);
+ ~QQuickScriptAction() override;
QQmlScriptString script() const;
void setScript(const QQmlScriptString &);
@@ -205,7 +206,7 @@ protected:
QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0) override;
+ QObject *defaultTarget = nullptr) override;
};
class QQuickPropertyActionPrivate;
@@ -222,8 +223,8 @@ class QQuickPropertyAction : public QQuickAbstractAnimation
Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged)
public:
- QQuickPropertyAction(QObject *parent=0);
- virtual ~QQuickPropertyAction();
+ QQuickPropertyAction(QObject *parent=nullptr);
+ ~QQuickPropertyAction() override;
QObject *target() const;
void setTargetObject(QObject *);
@@ -250,7 +251,7 @@ protected:
QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0) override;
+ QObject *defaultTarget = nullptr) override;
};
class QQuickPropertyAnimationPrivate;
@@ -270,8 +271,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPropertyAnimation : public QQuickAbstractAnim
Q_PROPERTY(QQmlListProperty<QObject> exclude READ exclude)
public:
- QQuickPropertyAnimation(QObject *parent=0);
- virtual ~QQuickPropertyAnimation();
+ QQuickPropertyAnimation(QObject *parent=nullptr);
+ ~QQuickPropertyAnimation() override;
virtual int duration() const;
virtual void setDuration(int);
@@ -300,17 +301,17 @@ public:
protected:
QQuickStateActions createTransitionActions(QQuickStateActions &actions,
QQmlProperties &modified,
- QObject *defaultTarget = 0);
+ QObject *defaultTarget = nullptr);
QQuickPropertyAnimation(QQuickPropertyAnimationPrivate &dd, QObject *parent);
QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0) override;
+ QObject *defaultTarget = nullptr) override;
Q_SIGNALS:
void durationChanged(int);
- void fromChanged(const QVariant &);
- void toChanged(const QVariant &);
+ void fromChanged();
+ void toChanged();
void easingChanged(const QEasingCurve &);
void propertiesChanged(const QString &);
void targetChanged();
@@ -325,8 +326,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickColorAnimation : public QQuickPropertyAnimati
Q_PROPERTY(QColor to READ to WRITE setTo)
public:
- QQuickColorAnimation(QObject *parent=0);
- virtual ~QQuickColorAnimation();
+ QQuickColorAnimation(QObject *parent=nullptr);
+ ~QQuickColorAnimation() override;
QColor from() const;
void setFrom(const QColor &);
@@ -340,12 +341,12 @@ class Q_QUICK_PRIVATE_EXPORT QQuickNumberAnimation : public QQuickPropertyAnimat
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
- Q_PROPERTY(qreal from READ from WRITE setFrom)
- Q_PROPERTY(qreal to READ to WRITE setTo)
+ Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
public:
- QQuickNumberAnimation(QObject *parent=0);
- virtual ~QQuickNumberAnimation();
+ QQuickNumberAnimation(QObject *parent=nullptr);
+ ~QQuickNumberAnimation() override;
qreal from() const;
void setFrom(qreal);
@@ -365,12 +366,12 @@ class Q_QUICK_PRIVATE_EXPORT QQuickVector3dAnimation : public QQuickPropertyAnim
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickPropertyAnimation)
- Q_PROPERTY(QVector3D from READ from WRITE setFrom)
- Q_PROPERTY(QVector3D to READ to WRITE setTo)
+ Q_PROPERTY(QVector3D from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(QVector3D to READ to WRITE setTo NOTIFY toChanged)
public:
- QQuickVector3dAnimation(QObject *parent=0);
- virtual ~QQuickVector3dAnimation();
+ QQuickVector3dAnimation(QObject *parent=nullptr);
+ ~QQuickVector3dAnimation() override;
QVector3D from() const;
void setFrom(QVector3D);
@@ -385,13 +386,13 @@ class Q_QUICK_PRIVATE_EXPORT QQuickRotationAnimation : public QQuickPropertyAnim
Q_OBJECT
Q_DECLARE_PRIVATE(QQuickRotationAnimation)
- Q_PROPERTY(qreal from READ from WRITE setFrom)
- Q_PROPERTY(qreal to READ to WRITE setTo)
+ Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged)
+ Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged)
Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged)
public:
- QQuickRotationAnimation(QObject *parent=0);
- virtual ~QQuickRotationAnimation();
+ QQuickRotationAnimation(QObject *parent=nullptr);
+ ~QQuickRotationAnimation() override;
qreal from() const;
void setFrom(qreal);
@@ -419,7 +420,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickAnimationGroup : public QQuickAbstractAnimati
public:
QQuickAnimationGroup(QObject *parent);
- virtual ~QQuickAnimationGroup();
+ ~QQuickAnimationGroup() override;
QQmlListProperty<QQuickAbstractAnimation> animations();
friend class QQuickAbstractAnimation;
@@ -434,15 +435,15 @@ class QQuickSequentialAnimation : public QQuickAnimationGroup
Q_DECLARE_PRIVATE(QQuickAnimationGroup)
public:
- QQuickSequentialAnimation(QObject *parent=0);
- virtual ~QQuickSequentialAnimation();
+ QQuickSequentialAnimation(QObject *parent=nullptr);
+ ~QQuickSequentialAnimation() override;
protected:
ThreadingModel threadingModel() const override;
QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0) override;
+ QObject *defaultTarget = nullptr) override;
};
class Q_QUICK_PRIVATE_EXPORT QQuickParallelAnimation : public QQuickAnimationGroup
@@ -451,15 +452,15 @@ class Q_QUICK_PRIVATE_EXPORT QQuickParallelAnimation : public QQuickAnimationGro
Q_DECLARE_PRIVATE(QQuickAnimationGroup)
public:
- QQuickParallelAnimation(QObject *parent=0);
- virtual ~QQuickParallelAnimation();
+ QQuickParallelAnimation(QObject *parent=nullptr);
+ ~QQuickParallelAnimation() override;
protected:
ThreadingModel threadingModel() const override;
QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0) override;
+ QObject *defaultTarget = nullptr) override;
};
diff --git a/src/quick/util/qquickanimation_p_p.h b/src/quick/util/qquickanimation_p_p.h
index a7abc5a004..c20ec65c24 100644
--- a/src/quick/util/qquickanimation_p_p.h
+++ b/src/quick/util/qquickanimation_p_p.h
@@ -102,7 +102,7 @@ public:
QActionAnimation();
QActionAnimation(QAbstractAnimationAction *action);
- ~QActionAnimation();
+ ~QActionAnimation() override;
int duration() const override;
void setAnimAction(QAbstractAnimationAction *action);
@@ -130,7 +130,7 @@ class Q_AUTOTEST_EXPORT QQuickBulkValueAnimator : public QAbstractAnimationJob
Q_DISABLE_COPY(QQuickBulkValueAnimator)
public:
QQuickBulkValueAnimator();
- ~QQuickBulkValueAnimator();
+ ~QQuickBulkValueAnimator() override;
void setAnimValue(QQuickBulkValueUpdater *value);
QQuickBulkValueUpdater *getAnimValue() const { return animValue; }
@@ -178,7 +178,7 @@ public:
: running(false), paused(false), alwaysRunToEnd(false),
/*connectedTimeLine(false), */componentComplete(true),
avoidPropertyValueSourceStart(false), disableUserControl(false),
- registered(false), loopCount(1), group(0), animationInstance(0) {}
+ registered(false), loopCount(1), group(nullptr), animationInstance(nullptr) {}
bool running:1;
bool paused:1;
@@ -199,7 +199,7 @@ public:
QQuickAnimationGroup *group;
QAbstractAnimationJob* animationInstance;
- static QQmlProperty createProperty(QObject *obj, const QString &str, QObject *infoObj, QString *errorMessage = Q_NULLPTR);
+ static QQmlProperty createProperty(QObject *obj, const QString &str, QObject *infoObj, QString *errorMessage = nullptr);
};
class QQuickPauseAnimationPrivate : public QQuickAbstractAnimationPrivate
@@ -237,7 +237,7 @@ class QQuickPropertyActionPrivate : public QQuickAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QQuickPropertyAction)
public:
QQuickPropertyActionPrivate()
- : QQuickAbstractAnimationPrivate(), target(0) {}
+ : QQuickAbstractAnimationPrivate(), target(nullptr) {}
QObject *target;
QString propertyName;
@@ -265,8 +265,8 @@ class QQuickPropertyAnimationPrivate : public QQuickAbstractAnimationPrivate
Q_DECLARE_PUBLIC(QQuickPropertyAnimation)
public:
QQuickPropertyAnimationPrivate()
- : QQuickAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false),
- defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), duration(250), actions(0) {}
+ : QQuickAbstractAnimationPrivate(), target(nullptr), fromSourced(false), fromIsDefined(false), toIsDefined(false),
+ defaultToInterpolatorType(0), interpolatorType(0), interpolator(nullptr), duration(250), actions(nullptr) {}
QVariant from;
QVariant to;
@@ -306,8 +306,8 @@ public:
class Q_AUTOTEST_EXPORT QQuickAnimationPropertyUpdater : public QQuickBulkValueUpdater
{
public:
- QQuickAnimationPropertyUpdater() : interpolatorType(0), interpolator(0), prevInterpolatorType(0), reverse(false), fromSourced(false), fromDefined(false), wasDeleted(0) {}
- ~QQuickAnimationPropertyUpdater();
+ QQuickAnimationPropertyUpdater() : interpolatorType(0), interpolator(nullptr), prevInterpolatorType(0), reverse(false), fromSourced(false), fromDefined(false), wasDeleted(nullptr) {}
+ ~QQuickAnimationPropertyUpdater() override;
void setValue(qreal v) override;
diff --git a/src/quick/util/qquickanimationcontroller.cpp b/src/quick/util/qquickanimationcontroller.cpp
index cebb0391ae..bfe96755c5 100644
--- a/src/quick/util/qquickanimationcontroller.cpp
+++ b/src/quick/util/qquickanimationcontroller.cpp
@@ -49,7 +49,7 @@ class QQuickAnimationControllerPrivate : public QObjectPrivate, QAnimationJobCha
Q_DECLARE_PUBLIC(QQuickAnimationController)
public:
QQuickAnimationControllerPrivate()
- : progress(0.0), animation(0), animationInstance(0), finalized(false) {}
+ : progress(0.0), animation(nullptr), animationInstance(nullptr), finalized(false) {}
void animationFinished(QAbstractAnimationJob *job) override;
void animationCurrentTimeChanged(QAbstractAnimationJob *job, int currentTime) override;
@@ -96,7 +96,7 @@ void QQuickAnimationControllerPrivate::animationCurrentTimeChanged(QAbstractAnim
\instantiates QQuickAnimationController
\inqmlmodule QtQuick
\ingroup qtquick-animation-control
- \brief Enables manual control of animations
+ \brief Enables manual control of animations.
Normally animations are driven by an internal timer, but the AnimationController
allows the given \a animation to be driven by a \a progress value explicitly.
@@ -197,7 +197,7 @@ void QQuickAnimationController::reload()
return;
if (!d->animation) {
- d->animationInstance = 0;
+ d->animationInstance = nullptr;
} else {
QQuickStateActions actions;
QQmlProperties properties;
@@ -223,7 +223,7 @@ void QQuickAnimationController::updateProgress()
d->animationInstance->setDisableUserControl();
d->animationInstance->start();
- QQmlAnimationTimer::unregisterAnimation(d->animationInstance);
+ QQmlAnimationTimer::instance()->unregisterAnimation(d->animationInstance);
d->animationInstance->setCurrentTime(d->progress * d->animationInstance->duration());
}
diff --git a/src/quick/util/qquickanimationcontroller_p.h b/src/quick/util/qquickanimationcontroller_p.h
index 43555ac1c1..d9ce377060 100644
--- a/src/quick/util/qquickanimationcontroller_p.h
+++ b/src/quick/util/qquickanimationcontroller_p.h
@@ -69,7 +69,7 @@ class Q_AUTOTEST_EXPORT QQuickAnimationController : public QObject, public QQmlP
Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation NOTIFY animationChanged)
public:
- QQuickAnimationController(QObject *parent=0);
+ QQuickAnimationController(QObject *parent=nullptr);
~QQuickAnimationController();
qreal progress() const;
diff --git a/src/quick/util/qquickanimator.cpp b/src/quick/util/qquickanimator.cpp
index 5608326f8a..d1ff78f8bc 100644
--- a/src/quick/util/qquickanimator.cpp
+++ b/src/quick/util/qquickanimator.cpp
@@ -280,22 +280,22 @@ QAbstractAnimationJob *QQuickAnimator::transition(QQuickStateActions &actions,
if (d->defaultProperty.isValid() && propertyName() != d->defaultProperty.name()) {
qDebug() << Q_FUNC_INFO << "property name conflict...";
- return 0;
+ return nullptr;
}
// The animation system cannot handle backwards uncontrolled animations.
if (direction == Backward)
- return 0;
+ return nullptr;
QQuickAnimatorJob *job = createJob();
if (!job)
- return 0;
+ return nullptr;
d->apply(job, propertyName(), actions, modified, defaultTarget);
if (!job->target()) {
delete job;
- return 0;
+ return nullptr;
}
return job;
@@ -576,7 +576,7 @@ QQuickAnimatorJob *QQuickUniformAnimator::createJob() const
{
QString u = propertyName();
if (u.isEmpty())
- return 0;
+ return nullptr;
QQuickUniformAnimatorJob *job = new QQuickUniformAnimatorJob();
job->setUniform(u.toLatin1());
diff --git a/src/quick/util/qquickanimator_p.h b/src/quick/util/qquickanimator_p.h
index 92c66299dc..511cecda7f 100644
--- a/src/quick/util/qquickanimator_p.h
+++ b/src/quick/util/qquickanimator_p.h
@@ -94,8 +94,8 @@ protected:
TransitionDirection,
QObject *) override;
- QQuickAnimator(QQuickAnimatorPrivate &dd, QObject *parent = 0);
- QQuickAnimator(QObject *parent = 0);
+ QQuickAnimator(QQuickAnimatorPrivate &dd, QObject *parent = nullptr);
+ QQuickAnimator(QObject *parent = nullptr);
Q_SIGNALS:
void targetItemChanged(QQuickItem *);
@@ -110,7 +110,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickScaleAnimator : public QQuickAnimator
{
Q_OBJECT
public:
- QQuickScaleAnimator(QObject *parent = 0);
+ QQuickScaleAnimator(QObject *parent = nullptr);
protected:
QQuickAnimatorJob *createJob() const override;
QString propertyName() const override { return QStringLiteral("scale"); }
@@ -120,7 +120,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickXAnimator : public QQuickAnimator
{
Q_OBJECT
public:
- QQuickXAnimator(QObject *parent = 0);
+ QQuickXAnimator(QObject *parent = nullptr);
protected:
QQuickAnimatorJob *createJob() const override;
QString propertyName() const override { return QStringLiteral("x"); }
@@ -130,7 +130,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickYAnimator : public QQuickAnimator
{
Q_OBJECT
public:
- QQuickYAnimator(QObject *parent = 0);
+ QQuickYAnimator(QObject *parent = nullptr);
protected:
QQuickAnimatorJob *createJob() const override;
QString propertyName() const override { return QStringLiteral("y"); }
@@ -140,7 +140,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickOpacityAnimator : public QQuickAnimator
{
Q_OBJECT
public:
- QQuickOpacityAnimator(QObject *parent = 0);
+ QQuickOpacityAnimator(QObject *parent = nullptr);
protected:
QQuickAnimatorJob *createJob() const override;
QString propertyName() const override { return QStringLiteral("opacity"); }
@@ -157,7 +157,7 @@ public:
enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise };
Q_ENUM(RotationDirection)
- QQuickRotationAnimator(QObject *parent = 0);
+ QQuickRotationAnimator(QObject *parent = nullptr);
void setDirection(RotationDirection dir);
RotationDirection direction() const;
@@ -179,7 +179,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickUniformAnimator : public QQuickAnimator
Q_PROPERTY(QString uniform READ uniform WRITE setUniform NOTIFY uniformChanged)
public:
- QQuickUniformAnimator(QObject *parent = 0);
+ QQuickUniformAnimator(QObject *parent = nullptr);
QString uniform() const;
void setUniform(const QString &);
diff --git a/src/quick/util/qquickanimatorcontroller.cpp b/src/quick/util/qquickanimatorcontroller.cpp
index 3f7347c01d..5cf8051922 100644
--- a/src/quick/util/qquickanimatorcontroller.cpp
+++ b/src/quick/util/qquickanimatorcontroller.cpp
@@ -123,8 +123,10 @@ static void qquickanimator_sync_before_start(QAbstractAnimationJob *job)
void QQuickAnimatorController::beforeNodeSync()
{
- for (const QSharedPointer<QAbstractAnimationJob> &toStop : qAsConst(m_rootsPendingStop))
+ for (const QSharedPointer<QAbstractAnimationJob> &toStop : qAsConst(m_rootsPendingStop)) {
toStop->stop();
+ m_animationRoots.remove(toStop.data());
+ }
m_rootsPendingStop.clear();
diff --git a/src/quick/util/qquickanimatorjob.cpp b/src/quick/util/qquickanimatorjob.cpp
index a7950e2b33..03be78ab15 100644
--- a/src/quick/util/qquickanimatorjob.cpp
+++ b/src/quick/util/qquickanimatorjob.cpp
@@ -197,8 +197,12 @@ void QQuickAnimatorProxyJob::windowChanged(QQuickWindow *window)
void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window)
{
if (!window) {
- if (m_job && m_controller)
+ if (m_job && m_controller) {
+ disconnect(m_controller->window(), &QQuickWindow::sceneGraphInitialized,
+ this, &QQuickAnimatorProxyJob::sceneGraphInitialized);
m_controller->cancel(m_job);
+ }
+
m_controller = nullptr;
stop();
@@ -213,8 +217,10 @@ void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window)
void QQuickAnimatorProxyJob::sceneGraphInitialized()
{
- disconnect(m_controller->window(), &QQuickWindow::sceneGraphInitialized, this, &QQuickAnimatorProxyJob::sceneGraphInitialized);
- readyToAnimate();
+ if (m_controller) {
+ disconnect(m_controller->window(), &QQuickWindow::sceneGraphInitialized, this, &QQuickAnimatorProxyJob::sceneGraphInitialized);
+ readyToAnimate();
+ }
}
void QQuickAnimatorProxyJob::readyToAnimate()
@@ -246,8 +252,8 @@ void QQuickAnimatorProxyJob::syncBackCurrentValues()
}
QQuickAnimatorJob::QQuickAnimatorJob()
- : m_target(0)
- , m_controller(0)
+ : m_target(nullptr)
+ , m_controller(nullptr)
, m_from(0)
, m_to(0)
, m_value(0)
diff --git a/src/quick/util/qquickanimatorjob_p.h b/src/quick/util/qquickanimatorjob_p.h
index 777da2ee6c..74085526c0 100644
--- a/src/quick/util/qquickanimatorjob_p.h
+++ b/src/quick/util/qquickanimatorjob_p.h
@@ -194,7 +194,7 @@ public:
{
Helper()
: ref(1)
- , node(0)
+ , node(nullptr)
, ox(0)
, oy(0)
, dx(0)
diff --git a/src/quick/util/qquickapplication_p.h b/src/quick/util/qquickapplication_p.h
index 8ee203f0da..66a33489e4 100644
--- a/src/quick/util/qquickapplication_p.h
+++ b/src/quick/util/qquickapplication_p.h
@@ -72,7 +72,7 @@ class Q_AUTOTEST_EXPORT QQuickApplication : public QQmlApplication
Q_PROPERTY(QQmlListProperty<QQuickScreenInfo> screens READ screens NOTIFY screensChanged)
public:
- explicit QQuickApplication(QObject *parent = 0);
+ explicit QQuickApplication(QObject *parent = nullptr);
virtual ~QQuickApplication();
bool active() const;
Qt::LayoutDirection layoutDirection() const;
diff --git a/src/quick/util/qquickbehavior.cpp b/src/quick/util/qquickbehavior.cpp
index a562ebd937..76d464e7f8 100644
--- a/src/quick/util/qquickbehavior.cpp
+++ b/src/quick/util/qquickbehavior.cpp
@@ -57,7 +57,7 @@ class QQuickBehaviorPrivate : public QObjectPrivate, public QAnimationJobChangeL
{
Q_DECLARE_PUBLIC(QQuickBehavior)
public:
- QQuickBehaviorPrivate() : animation(0), animationInstance(0), enabled(true), finalized(false)
+ QQuickBehaviorPrivate() : animation(nullptr), animationInstance(nullptr), enabled(true), finalized(false)
, blockRunningChanged(false) {}
void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
@@ -77,7 +77,7 @@ public:
\inqmlmodule QtQuick
\ingroup qtquick-transitions-animations
\ingroup qtquick-interceptors
- \brief Defines a default animation for a property change
+ \brief Defines a default animation for a property change.
A Behavior defines the default animation to be applied whenever a
particular property value changes.
@@ -171,9 +171,28 @@ void QQuickBehavior::setEnabled(bool enabled)
emit enabledChanged();
}
+/*!
+ \qmlproperty Variant QtQuick::Behavior::targetValue
+
+ This property holds the target value of the property being controlled by the Behavior.
+ This value is set by the Behavior before the animation is started.
+
+ \since QtQuick 2.13
+*/
+QVariant QQuickBehavior::targetValue() const
+{
+ Q_D(const QQuickBehavior);
+ return d->targetValue;
+}
+
void QQuickBehavior::write(const QVariant &value)
{
Q_D(QQuickBehavior);
+ const bool targetValueHasChanged = d->targetValue != value;
+ if (targetValueHasChanged) {
+ d->targetValue = value;
+ emit targetValueChanged(); // emitting the signal here should allow
+ } // d->enabled to change if scripted by the user.
bool bypass = !d->enabled || !d->finalized || QQmlEnginePrivate::designerMode();
if (!bypass)
qmlExecuteDeferred(this);
@@ -181,16 +200,13 @@ void QQuickBehavior::write(const QVariant &value)
if (d->animationInstance)
d->animationInstance->stop();
QQmlPropertyPrivate::write(d->property, value, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
- d->targetValue = value;
return;
}
bool behaviorActive = d->animation->isRunning();
- if (behaviorActive && value == d->targetValue)
+ if (behaviorActive && !targetValueHasChanged)
return;
- d->targetValue = value;
-
if (d->animationInstance
&& (d->animationInstance->duration() != -1
|| d->animationInstance->isRenderThreadProxy())
diff --git a/src/quick/util/qquickbehavior_p.h b/src/quick/util/qquickbehavior_p.h
index b3fd2af400..80a51d77af 100644
--- a/src/quick/util/qquickbehavior_p.h
+++ b/src/quick/util/qquickbehavior_p.h
@@ -69,10 +69,11 @@ class Q_QUICK_PRIVATE_EXPORT QQuickBehavior : public QObject, public QQmlPropert
Q_CLASSINFO("DefaultProperty", "animation")
Q_PROPERTY(QQuickAbstractAnimation *animation READ animation WRITE setAnimation)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
+ Q_PROPERTY(QVariant targetValue READ targetValue NOTIFY targetValueChanged REVISION 13)
Q_CLASSINFO("DeferredPropertyNames", "animation")
public:
- QQuickBehavior(QObject *parent=0);
+ QQuickBehavior(QObject *parent=nullptr);
~QQuickBehavior();
void setTarget(const QQmlProperty &) override;
@@ -84,8 +85,11 @@ public:
bool enabled() const;
void setEnabled(bool enabled);
+ QVariant targetValue() const;
+
Q_SIGNALS:
void enabledChanged();
+ void targetValueChanged();
private Q_SLOTS:
void componentFinalized();
diff --git a/src/quick/util/qquickfontloader.cpp b/src/quick/util/qquickfontloader.cpp
index 68e27c25fd..2de9768243 100644
--- a/src/quick/util/qquickfontloader.cpp
+++ b/src/quick/util/qquickfontloader.cpp
@@ -77,8 +77,8 @@ Q_SIGNALS:
void fontDownloaded(const QString&, QQuickFontLoader::Status);
private:
- int redirectCount;
- QNetworkReply *reply;
+ int redirectCount = 0;
+ QNetworkReply *reply = nullptr;
private Q_SLOTS:
void replyFinished();
@@ -91,13 +91,8 @@ public:
};
QQuickFontObject::QQuickFontObject(int _id)
- : QObject(0)
-#if QT_CONFIG(qml_network)
- ,redirectCount(0), reply(0)
-#endif
- ,id(_id)
+ : QObject(nullptr), id(_id)
{
-
}
#if QT_CONFIG(qml_network)
@@ -119,7 +114,7 @@ void QQuickFontObject::replyFinished()
QUrl url = reply->url().resolved(redirect.toUrl());
QNetworkAccessManager *manager = reply->manager();
reply->deleteLater();
- reply = 0;
+ reply = nullptr;
download(url, manager);
return;
}
@@ -138,7 +133,7 @@ void QQuickFontObject::replyFinished()
emit fontDownloaded(QString(), QQuickFontLoader::Error);
}
reply->deleteLater();
- reply = 0;
+ reply = nullptr;
}
}
#endif // qml_network
@@ -148,11 +143,11 @@ class QQuickFontLoaderPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QQuickFontLoader)
public:
- QQuickFontLoaderPrivate() : status(QQuickFontLoader::Null) {}
+ QQuickFontLoaderPrivate() {}
QUrl url;
QString name;
- QQuickFontLoader::Status status;
+ QQuickFontLoader::Status status = QQuickFontLoader::Null;
};
static void q_QFontLoaderFontsStaticReset();
@@ -203,7 +198,7 @@ static void q_QFontLoaderFontsStaticReset()
\instantiates QQuickFontLoader
\inqmlmodule QtQuick
\ingroup qtquick-text-utility
- \brief Allows fonts to be loaded by name or URL
+ \brief Allows fonts to be loaded by name or URL.
The FontLoader type is used to load fonts by name or URL.
diff --git a/src/quick/util/qquickfontloader_p.h b/src/quick/util/qquickfontloader_p.h
index 29feecde4f..8d277f7cf7 100644
--- a/src/quick/util/qquickfontloader_p.h
+++ b/src/quick/util/qquickfontloader_p.h
@@ -72,7 +72,7 @@ public:
enum Status { Null = 0, Ready, Loading, Error };
Q_ENUM(Status)
- QQuickFontLoader(QObject *parent = 0);
+ QQuickFontLoader(QObject *parent = nullptr);
~QQuickFontLoader();
QUrl source() const;
diff --git a/src/quick/util/qquickfontmetrics.cpp b/src/quick/util/qquickfontmetrics.cpp
index 8c44150486..42b3038c48 100644
--- a/src/quick/util/qquickfontmetrics.cpp
+++ b/src/quick/util/qquickfontmetrics.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick
\since 5.4
\ingroup qtquick-text-utility
- \brief Provides metrics for a given font
+ \brief Provides metrics for a given font.
FontMetrics calculates the size of characters and strings for a given font.
@@ -287,7 +287,7 @@ qreal QQuickFontMetrics::lineWidth() const
*/
qreal QQuickFontMetrics::advanceWidth(const QString &text) const
{
- return m_metrics.width(text);
+ return m_metrics.horizontalAdvance(text);
}
/*!
diff --git a/src/quick/util/qquickfontmetrics_p.h b/src/quick/util/qquickfontmetrics_p.h
index ebabe51712..db2b7b6796 100644
--- a/src/quick/util/qquickfontmetrics_p.h
+++ b/src/quick/util/qquickfontmetrics_p.h
@@ -80,7 +80,7 @@ class Q_AUTOTEST_EXPORT QQuickFontMetrics : public QObject
Q_PROPERTY(qreal strikeOutPosition READ strikeOutPosition NOTIFY fontChanged)
Q_PROPERTY(qreal lineWidth READ lineWidth NOTIFY fontChanged)
public:
- explicit QQuickFontMetrics(QObject *parent = 0);
+ explicit QQuickFontMetrics(QObject *parent = nullptr);
~QQuickFontMetrics();
QFont font() const;
diff --git a/src/quick/util/qquickglobal.cpp b/src/quick/util/qquickglobal.cpp
index 1d2f3de1df..5337bfd640 100644
--- a/src/quick/util/qquickglobal.cpp
+++ b/src/quick/util/qquickglobal.cpp
@@ -302,6 +302,8 @@ public:
QV4::ScopedValue vweight(scope, obj->get((s = v4->newString(QStringLiteral("weight")))));
QV4::ScopedValue vwspac(scope, obj->get((s = v4->newString(QStringLiteral("wordSpacing")))));
QV4::ScopedValue vhint(scope, obj->get((s = v4->newString(QStringLiteral("hintingPreference")))));
+ QV4::ScopedValue vkerning(scope, obj->get((s = v4->newString(QStringLiteral("kerning")))));
+ QV4::ScopedValue vshaping(scope, obj->get((s = v4->newString(QStringLiteral("preferShaping")))));
// pull out the values, set ok to true if at least one valid field is given.
if (vbold->isBoolean()) {
@@ -356,6 +358,17 @@ public:
retn.setHintingPreference(static_cast<QFont::HintingPreference>(vhint->integerValue()));
if (ok) *ok = true;
}
+ if (vkerning->isBoolean()) {
+ retn.setKerning(vkerning->booleanValue());
+ if (ok) *ok = true;
+ }
+ if (vshaping->isBoolean()) {
+ bool enable = vshaping->booleanValue();
+ if (enable)
+ retn.setStyleStrategy(static_cast<QFont::StyleStrategy>(retn.styleStrategy() & ~QFont::PreferNoShaping));
+ else
+ retn.setStyleStrategy(static_cast<QFont::StyleStrategy>(retn.styleStrategy() | QFont::PreferNoShaping));
+ }
return retn;
}
@@ -375,7 +388,7 @@ public:
float matVals[16];
QV4::ScopedValue v(scope);
for (quint32 i = 0; i < 16; ++i) {
- v = array->getIndexed(i);
+ v = array->get(i);
if (!v->isNumber())
return QMatrix4x4();
matVals[i] = v->asDouble();
@@ -385,7 +398,7 @@ public:
return QMatrix4x4(matVals);
}
- const QMetaObject *getMetaObjectForMetaType(int type) Q_DECL_OVERRIDE
+ const QMetaObject *getMetaObjectForMetaType(int type) override
{
switch (type) {
case QMetaType::QColor:
@@ -406,10 +419,10 @@ public:
break;
}
- return 0;
+ return nullptr;
}
- bool init(int type, QVariant& dst) Q_DECL_OVERRIDE
+ bool init(int type, QVariant& dst) override
{
switch (type) {
case QMetaType::QColor:
@@ -439,7 +452,7 @@ public:
return false;
}
- bool create(int type, int argc, const void *argv[], QVariant *v) Q_DECL_OVERRIDE
+ bool create(int type, int argc, const void *argv[], QVariant *v) override
{
switch (type) {
case QMetaType::QFont: // must specify via js-object.
@@ -506,7 +519,7 @@ public:
return true;
}
- bool createFromString(int type, const QString &s, void *data, size_t dataSize) Q_DECL_OVERRIDE
+ bool createFromString(int type, const QString &s, void *data, size_t dataSize) override
{
bool ok = false;
@@ -529,7 +542,7 @@ public:
return false;
}
- bool createStringFrom(int type, const void *data, QString *s) Q_DECL_OVERRIDE
+ bool createStringFrom(int type, const void *data, QString *s) override
{
if (type == QMetaType::QColor) {
const QColor *color = reinterpret_cast<const QColor *>(data);
@@ -540,7 +553,7 @@ public:
return false;
}
- bool variantFromString(const QString &s, QVariant *v) Q_DECL_OVERRIDE
+ bool variantFromString(const QString &s, QVariant *v) override
{
QColor c(s);
if (c.isValid()) {
@@ -583,7 +596,7 @@ public:
return false;
}
- bool variantFromString(int type, const QString &s, QVariant *v) Q_DECL_OVERRIDE
+ bool variantFromString(int type, const QString &s, QVariant *v) override
{
bool ok = false;
@@ -626,7 +639,7 @@ public:
return false;
}
- bool variantFromJsObject(int type, QQmlV4Handle object, QV4::ExecutionEngine *v4, QVariant *v) Q_DECL_OVERRIDE
+ bool variantFromJsObject(int type, QQmlV4Handle object, QV4::ExecutionEngine *v4, QVariant *v) override
{
QV4::Scope scope(v4);
#ifndef QT_NO_DEBUG
@@ -652,7 +665,7 @@ public:
return (*(reinterpret_cast<const T *>(lhs)) == rhs.value<T>());
}
- bool equal(int type, const void *lhs, const QVariant &rhs) Q_DECL_OVERRIDE
+ bool equal(int type, const void *lhs, const QVariant &rhs) override
{
switch (type) {
case QMetaType::QColor:
@@ -685,7 +698,7 @@ public:
return true;
}
- bool store(int type, const void *src, void *dst, size_t dstSize) Q_DECL_OVERRIDE
+ bool store(int type, const void *src, void *dst, size_t dstSize) override
{
Q_UNUSED(dstSize);
switch (type) {
@@ -715,7 +728,7 @@ public:
return true;
}
- bool read(const QVariant &src, void *dst, int dstType) Q_DECL_OVERRIDE
+ bool read(const QVariant &src, void *dst, int dstType) override
{
switch (dstType) {
case QMetaType::QColor:
@@ -749,7 +762,7 @@ public:
return false;
}
- bool write(int type, const void *src, QVariant& dst) Q_DECL_OVERRIDE
+ bool write(int type, const void *src, QVariant& dst) override
{
switch (type) {
case QMetaType::QColor:
@@ -850,8 +863,8 @@ void QQuick_initializeProviders()
void QQuick_deinitializeProviders()
{
QQml_removeValueTypeProvider(getValueTypeProvider());
- QQml_setColorProvider(0); // technically, another plugin may have overridden our providers
- QQml_setGuiProvider(0); // but we cannot handle that case in a sane way.
+ QQml_setColorProvider(nullptr); // technically, another plugin may have overridden our providers
+ QQml_setGuiProvider(nullptr); // but we cannot handle that case in a sane way.
}
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp
index b4a6b9e1f6..ebcca77f17 100644
--- a/src/quick/util/qquickimageprovider.cpp
+++ b/src/quick/util/qquickimageprovider.cpp
@@ -39,8 +39,10 @@
#include "qquickimageprovider.h"
+#include "qquickimageprovider_p.h"
#include "qquickpixmapcache_p.h"
#include <QtQuick/private/qsgcontext_p.h>
+#include <private/qqmlglobal_p.h>
QT_BEGIN_NAMESPACE
@@ -108,7 +110,7 @@ QImage QQuickTextureFactory::image() const
QQuickTextureFactory *QQuickTextureFactory::textureFactoryForImage(const QImage &image)
{
if (image.isNull())
- return 0;
+ return nullptr;
QQuickTextureFactory *texture = QSGContext::createTextureFactoryFromImage(image);
if (texture)
return texture;
@@ -160,7 +162,10 @@ QQuickTextureFactory *QQuickTextureFactory::textureFactoryForImage(const QImage
Constructs the image response
*/
QQuickImageResponse::QQuickImageResponse()
+ : QObject(*(new QQuickImageResponsePrivate))
{
+ qmlobject_connect(this, QQuickImageResponse, SIGNAL(finished()),
+ this, QQuickImageResponse, SLOT(_q_finished()));
}
/*!
@@ -255,13 +260,13 @@ void QQuickImageResponse::cancel()
If you want the rest of the URL to be case insensitive, you will have to take care
of that yourself inside your image provider.
- \section2 An example
+ \section2 An Example
Here are two images. Their \c source values indicate they should be loaded by
an image provider named "colors", and the images to be loaded are "yellow"
and "red", respectively:
- \snippet imageprovider/imageprovider-example.qml 0
+ \snippet imgprovider/imageprovider-example.qml 0
When these images are loaded by QML, it looks for a matching image provider
and calls its requestImage() or requestPixmap() method (depending on its
@@ -272,25 +277,14 @@ void QQuickImageResponse::cancel()
requested by the above QML. This implementation dynamically
generates QPixmap images that are filled with the requested color:
- \snippet imageprovider/imageprovider.cpp 0
- \codeline
- \snippet imageprovider/imageprovider.cpp 1
+ \snippet imgprovider/imageprovider.cpp 0
To make this provider accessible to QML, it is registered with the QML engine
with a "colors" identifier:
- \code
- int main(int argc, char *argv[])
- {
- ...
-
- QQuickView view;
- QQmlEngine *engine = view.engine();
- engine->addImageProvider(QLatin1String("colors"), new ColorPixmapProvider);
-
- ...
- }
- \endcode
+ \snippet imgprovider/imageprovider.cpp 1
+ \codeline
+ \snippet imgprovider/imageprovider.cpp 2
Now the images can be successfully loaded in QML:
@@ -301,7 +295,7 @@ void QQuickImageResponse::cancel()
instead of registering it in the application \c main() function as shown above.
- \section2 Asynchronous image loading
+ \section2 Asynchronous Image Loading
Image providers that support QImage or Texture loading automatically include support
for asychronous loading of images. To enable asynchronous loading for an
@@ -330,7 +324,7 @@ void QQuickImageResponse::cancel()
See the \l {imageresponseprovider}{Image Response Provider Example} for a complete implementation.
- \section2 Image caching
+ \section2 Image Caching
Images returned by a QQuickImageProvider are automatically cached,
similar to any image loaded by the QML engine. When an image with a
@@ -340,8 +334,6 @@ void QQuickImageResponse::cancel()
\c cache property to \c false for the relevant \l Image, \l BorderImage or
\l AnimatedImage object.
- The \l {Qt Quick 1} version of this class is named QDeclarativeImageProvider.
-
\sa QQmlEngine::addImageProvider()
*/
@@ -444,7 +436,7 @@ QPixmap QQuickImageProvider::requestPixmap(const QString &id, QSize *size, const
/*!
Implement this method to return the texture with \a id. The default
- implementation returns 0.
+ implementation returns \nullptr.
The \a id is the requested image source, with the "image:" scheme and
provider identifier removed. For example, if the image \l{Image::}{source}
@@ -469,7 +461,7 @@ QQuickTextureFactory *QQuickImageProvider::requestTexture(const QString &id, QSi
Q_UNUSED(requestedSize);
if (d->type == Texture)
qWarning("ImageProvider supports Texture type but has not implemented requestTexture()");
- return 0;
+ return nullptr;
}
/*!
@@ -484,7 +476,7 @@ QQuickTextureFactory *QQuickImageProvider::requestTexture(const QString &id, QSi
*/
QQuickAsyncImageProvider::QQuickAsyncImageProvider()
: QQuickImageProvider(ImageResponse, ForceAsynchronousImageLoading)
- , d(0) // just as a placeholder in case we need it for the future
+ , d(nullptr) // just as a placeholder in case we need it for the future
{
Q_UNUSED(d);
}
@@ -515,15 +507,12 @@ class QQuickImageProviderOptionsPrivate : public QSharedData
{
public:
QQuickImageProviderOptionsPrivate()
- : autoTransform(QQuickImageProviderOptions::UsePluginDefaultTransform)
- , preserveAspectRatioCrop(false)
- , preserveAspectRatioFit(false)
{
}
- QQuickImageProviderOptions::AutoTransform autoTransform;
- bool preserveAspectRatioCrop;
- bool preserveAspectRatioFit;
+ QQuickImageProviderOptions::AutoTransform autoTransform = QQuickImageProviderOptions::UsePluginDefaultTransform;
+ bool preserveAspectRatioCrop = false;
+ bool preserveAspectRatioFit = false;
};
/*!
@@ -683,13 +672,18 @@ QSize QQuickImageProviderWithOptions::loadSize(const QSize &originalSize, const
return res;
const bool preserveAspectCropOrFit = options.preserveAspectRatioCrop() || options.preserveAspectRatioFit();
- const bool force_scale = (format == "svg" || format == "svgz");
+ const bool formatIsSvg = (format == "svg" || format == "svgz");
+
+ if (!preserveAspectCropOrFit && formatIsSvg && !requestedSize.isEmpty())
+ return requestedSize;
qreal ratio = 0.0;
- if (requestedSize.width() && (preserveAspectCropOrFit || force_scale || requestedSize.width() < originalSize.width())) {
+ if (requestedSize.width() && (preserveAspectCropOrFit || formatIsSvg ||
+ requestedSize.width() < originalSize.width())) {
ratio = qreal(requestedSize.width()) / originalSize.width();
}
- if (requestedSize.height() && (preserveAspectCropOrFit || force_scale || requestedSize.height() < originalSize.height())) {
+ if (requestedSize.height() && (preserveAspectCropOrFit || formatIsSvg ||
+ requestedSize.height() < originalSize.height())) {
qreal hr = qreal(requestedSize.height()) / originalSize.height();
if (ratio == 0.0)
ratio = hr;
diff --git a/src/quick/util/qquickimageprovider.h b/src/quick/util/qquickimageprovider.h
index 681de4b6c2..82d0501697 100644
--- a/src/quick/util/qquickimageprovider.h
+++ b/src/quick/util/qquickimageprovider.h
@@ -56,9 +56,10 @@ class QQuickWindow;
class Q_QUICK_EXPORT QQuickTextureFactory : public QObject
{
+ Q_OBJECT
public:
QQuickTextureFactory();
- virtual ~QQuickTextureFactory();
+ ~QQuickTextureFactory() override;
virtual QSGTexture *createTexture(QQuickWindow *window) const = 0;
virtual QSize textureSize() const = 0;
@@ -68,12 +69,14 @@ public:
static QQuickTextureFactory *textureFactoryForImage(const QImage &image);
};
+class QQuickImageResponsePrivate;
+
class Q_QUICK_EXPORT QQuickImageResponse : public QObject
{
Q_OBJECT
public:
QQuickImageResponse();
- virtual ~QQuickImageResponse();
+ ~QQuickImageResponse() override;
virtual QQuickTextureFactory *textureFactory() const = 0;
virtual QString errorString() const;
@@ -83,6 +86,10 @@ public Q_SLOTS:
Q_SIGNALS:
void finished();
+
+private:
+ Q_DECLARE_PRIVATE(QQuickImageResponse)
+ Q_PRIVATE_SLOT(d_func(), void _q_finished())
};
class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase
@@ -90,7 +97,7 @@ class Q_QUICK_EXPORT QQuickImageProvider : public QQmlImageProviderBase
friend class QQuickImageProviderWithOptions; // ### Qt 6 Remove
public:
QQuickImageProvider(ImageType type, Flags flags = Flags());
- virtual ~QQuickImageProvider();
+ ~QQuickImageProvider() override;
ImageType imageType() const override;
Flags flags() const override;
@@ -113,7 +120,7 @@ class Q_QUICK_EXPORT QQuickAsyncImageProvider : public QQuickImageProvider
{
public:
QQuickAsyncImageProvider();
- virtual ~QQuickAsyncImageProvider();
+ ~QQuickAsyncImageProvider() override;
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
virtual QQuickImageResponse *requestImageResponse(const QString &id, const QSize &requestedSize, const QQuickImageProviderOptions &options) = 0;
diff --git a/src/quick/util/qquickimageprovider_p.h b/src/quick/util/qquickimageprovider_p.h
new file mode 100644
index 0000000000..b5baf79319
--- /dev/null
+++ b/src/quick/util/qquickimageprovider_p.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQuick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKQQUICKIMAGEPROVIDER_P_H
+#define QQUICKQQUICKIMAGEPROVIDER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qtquickglobal_p.h>
+#include <private/qobject_p.h>
+#include <qquickimageprovider.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickImageResponsePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickImageResponse)
+public:
+ bool finished = false;
+
+ void _q_finished() { finished = true; }
+};
+
+
+QT_END_NAMESPACE
+
+#endif // QQUICKQQUICKIMAGEPROVIDER_P_H
diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp
index 15defdc01b..60d725d650 100644
--- a/src/quick/util/qquickpath.cpp
+++ b/src/quick/util/qquickpath.cpp
@@ -55,12 +55,13 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickPathElement
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief PathElement is the base path type
+ \brief PathElement is the base path type.
This type is the base for all path types. It cannot
be instantiated.
- \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic, PathArc, PathCurve, PathSvg
+ \sa Path, PathAttribute, PathPercent, PathLine, PathQuad, PathCubic, PathArc,
+ PathAngleArc, PathCurve, PathSvg
*/
/*!
@@ -68,10 +69,10 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickPath
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Defines a path for use by \l PathView and \l Shape
+ \brief Defines a path for use by \l PathView and \l Shape.
A Path is composed of one or more path segments - PathLine, PathQuad,
- PathCubic, PathArc, PathCurve, PathSvg.
+ PathCubic, PathArc, PathAngleArc, PathCurve, PathSvg.
The spacing of the items along the Path can be adjusted via a
PathPercent object.
@@ -121,6 +122,12 @@ QT_BEGIN_NAMESPACE
\li Yes
\li Yes
\row
+ \li PathAngleArc
+ \li Yes
+ \li Yes
+ \li Yes
+ \li Yes
+ \row
\li PathSvg
\li Yes
\li Yes
@@ -146,7 +153,10 @@ QT_BEGIN_NAMESPACE
\li No
\endtable
- \sa PathView, Shape, PathAttribute, PathPercent, PathLine, PathMove, PathQuad, PathCubic, PathArc, PathCurve, PathSvg
+ \note Path is a non-visual type; it does not display anything on its own.
+ To draw a path, use \l Shape.
+
+ \sa PathView, Shape, PathAttribute, PathPercent, PathLine, PathMove, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve, PathSvg
*/
QQuickPath::QQuickPath(QObject *parent)
: QObject(*(new QQuickPathPrivate), parent)
@@ -233,6 +243,7 @@ bool QQuickPath::isClosed() const
\li \l PathQuad - a quadratic Bezier curve to a given position with a control point.
\li \l PathCubic - a cubic Bezier curve to a given position with two control points.
\li \l PathArc - an arc to a given position with a radius.
+ \li \l PathAngleArc - an arc specified by center point, radii, and angles.
\li \l PathSvg - a path specified as an SVG path data string.
\li \l PathCurve - a point on a Catmull-Rom curve.
\li \l PathAttribute - an attribute at a given position in the path.
@@ -245,7 +256,7 @@ bool QQuickPath::isClosed() const
QQmlListProperty<QQuickPathElement> QQuickPath::pathElements()
{
return QQmlListProperty<QQuickPathElement>(this,
- 0,
+ nullptr,
pathElements_append,
pathElements_count,
pathElements_at,
@@ -386,7 +397,12 @@ void QQuickPath::processPath()
d->_pointCache.clear();
d->prevBez.isValid = false;
- d->_path = createPath(QPointF(), QPointF(), d->_attributes, d->pathLength, d->_attributePoints, &d->closed);
+ if (d->isShapePath) {
+ // This path is a ShapePath, so avoid extra overhead
+ d->_path = createShapePath(QPointF(), QPointF(), d->pathLength, &d->closed);
+ } else {
+ d->_path = createPath(QPointF(), QPointF(), d->_attributes, d->pathLength, d->_attributePoints, &d->closed);
+ }
emit changed();
}
@@ -482,6 +498,42 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en
return path;
}
+QPainterPath QQuickPath::createShapePath(const QPointF &startPoint, const QPointF &endPoint, qreal &pathLength, bool *closed)
+{
+ Q_D(QQuickPath);
+
+ if (!d->componentComplete)
+ return QPainterPath();
+
+ QPainterPath path;
+
+ qreal startX = d->startX.isValid() ? d->startX.value : startPoint.x();
+ qreal startY = d->startY.isValid() ? d->startY.value : startPoint.y();
+ path.moveTo(startX, startY);
+
+ int index = 0;
+ for (QQuickCurve *curve : qAsConst(d->_pathCurves)) {
+ QQuickPathData data;
+ data.index = index;
+ data.endPoint = endPoint;
+ data.curves = d->_pathCurves;
+ curve->addToPath(path, data);
+ ++index;
+ }
+
+ if (closed) {
+ QPointF end = path.currentPosition();
+ *closed = startX == end.x() && startY == end.y();
+ }
+
+ // Note: Length of paths inside ShapePath is not used, so currently
+ // length is always 0. This avoids potentially heavy path.length()
+ //pathLength = path.length();
+ pathLength = 0;
+
+ return path;
+}
+
void QQuickPath::classBegin()
{
Q_D(QQuickPath);
@@ -946,7 +998,7 @@ bool QQuickCurve::hasRelativeY()
\instantiates QQuickPathAttribute
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Specifies how to set an attribute at a given position in a Path
+ \brief Specifies how to set an attribute at a given position in a Path.
The PathAttribute object allows attributes consisting of a name and
a value to be specified for various points along a path. The
@@ -1063,7 +1115,7 @@ void QQuickPathAttribute::setValue(qreal value)
\instantiates QQuickPathLine
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Defines a straight line
+ \brief Defines a straight line.
The example below creates a path consisting of a straight line from
0,100 to 200,100:
@@ -1075,7 +1127,7 @@ void QQuickPathAttribute::setValue(qreal value)
}
\endqml
- \sa Path, PathQuad, PathCubic, PathArc, PathCurve, PathSvg, PathMove
+ \sa Path, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve, PathSvg, PathMove
*/
/*!
@@ -1122,7 +1174,7 @@ void QQuickPathLine::addToPath(QPainterPath &path, const QQuickPathData &data)
\instantiates QQuickPathMove
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Moves the Path's position
+ \brief Moves the Path's position.
The example below creates a path consisting of two horizontal lines with
some empty space between them. All three segments have a width of 100:
@@ -1141,7 +1193,7 @@ void QQuickPathLine::addToPath(QPainterPath &path, const QQuickPathData &data)
between the operations of drawing a straight line and moving the path
position without drawing anything.
- \sa Path, PathQuad, PathCubic, PathArc, PathCurve, PathSvg, PathLine
+ \sa Path, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve, PathSvg, PathLine
*/
/*!
@@ -1180,7 +1232,7 @@ void QQuickPathMove::addToPath(QPainterPath &path, const QQuickPathData &data)
\instantiates QQuickPathQuad
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Defines a quadratic Bezier curve with a control point
+ \brief Defines a quadratic Bezier curve with a control point.
The following QML produces the path shown below:
\table
@@ -1195,7 +1247,7 @@ void QQuickPathMove::addToPath(QPainterPath &path, const QQuickPathData &data)
\endqml
\endtable
- \sa Path, PathCubic, PathLine, PathArc, PathCurve, PathSvg
+ \sa Path, PathCubic, PathLine, PathArc, PathAngleArc, PathCurve, PathSvg
*/
/*!
@@ -1332,7 +1384,7 @@ void QQuickPathQuad::addToPath(QPainterPath &path, const QQuickPathData &data)
\instantiates QQuickPathCubic
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Defines a cubic Bezier curve with two control points
+ \brief Defines a cubic Bezier curve with two control points.
The following QML produces the path shown below:
\table
@@ -1351,7 +1403,7 @@ void QQuickPathQuad::addToPath(QPainterPath &path, const QQuickPathData &data)
\endqml
\endtable
- \sa Path, PathQuad, PathLine, PathArc, PathCurve, PathSvg
+ \sa Path, PathQuad, PathLine, PathArc, PathAngleArc, PathCurve, PathSvg
*/
/*!
@@ -1556,7 +1608,7 @@ void QQuickPathCubic::addToPath(QPainterPath &path, const QQuickPathData &data)
\instantiates QQuickPathCatmullRomCurve
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Defines a point on a Catmull-Rom curve
+ \brief Defines a point on a Catmull-Rom curve.
PathCurve provides an easy way to specify a curve passing directly through a set of points.
Typically multiple PathCurves are used in a series, as the following example demonstrates:
@@ -1702,7 +1754,7 @@ void QQuickPathCatmullRomCurve::addToPath(QPainterPath &path, const QQuickPathDa
\instantiates QQuickPathArc
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Defines an arc with the given radius
+ \brief Defines an arc with the given radius.
PathArc provides a simple way of specifying an arc that ends at a given position
and uses the specified radius. It is modeled after the SVG elliptical arc command.
@@ -1717,7 +1769,7 @@ void QQuickPathCatmullRomCurve::addToPath(QPainterPath &path, const QQuickPathDa
Note that a single PathArc cannot be used to specify a circle. Instead, you can
use two PathArc elements, each specifying half of the circle.
- \sa Path, PathLine, PathQuad, PathCubic, PathCurve, PathSvg
+ \sa Path, PathLine, PathQuad, PathCubic, PathAngleArc, PathCurve, PathSvg
*/
/*!
@@ -1909,11 +1961,184 @@ void QQuickPathArc::addToPath(QPainterPath &path, const QQuickPathData &data)
/****************************************************************************/
/*!
+ \qmltype PathAngleArc
+ \instantiates QQuickPathAngleArc
+ \inqmlmodule QtQuick
+ \ingroup qtquick-animation-paths
+ \brief Defines an arc with the given radii and center.
+
+ PathAngleArc provides a simple way of specifying an arc. While PathArc is designed
+ to work as part of a larger path (specifying start and end), PathAngleArc is designed
+ to make a path where the arc is primary (such as a circular progress indicator) more intuitive.
+
+ \sa Path, PathLine, PathQuad, PathCubic, PathCurve, PathSvg, PathArc
+*/
+
+/*!
+ \qmlproperty real QtQuick::PathAngleArc::centerX
+ \qmlproperty real QtQuick::PathAngleArc::centerY
+
+ Defines the center of the arc.
+*/
+
+qreal QQuickPathAngleArc::centerX() const
+{
+ return _centerX;
+}
+
+void QQuickPathAngleArc::setCenterX(qreal centerX)
+{
+ if (_centerX == centerX)
+ return;
+
+ _centerX = centerX;
+ emit centerXChanged();
+ emit changed();
+}
+
+qreal QQuickPathAngleArc::centerY() const
+{
+ return _centerY;
+}
+
+void QQuickPathAngleArc::setCenterY(qreal centerY)
+{
+ if (_centerY == centerY)
+ return;
+
+ _centerY = centerY;
+ emit centerYChanged();
+ emit changed();
+}
+
+/*!
+ \qmlproperty real QtQuick::PathAngleArc::radiusX
+ \qmlproperty real QtQuick::PathAngleArc::radiusY
+
+ Defines the radii of the ellipse of which the arc is part.
+*/
+
+qreal QQuickPathAngleArc::radiusX() const
+{
+ return _radiusX;
+}
+
+void QQuickPathAngleArc::setRadiusX(qreal radius)
+{
+ if (_radiusX == radius)
+ return;
+
+ _radiusX = radius;
+ emit radiusXChanged();
+ emit changed();
+}
+
+qreal QQuickPathAngleArc::radiusY() const
+{
+ return _radiusY;
+}
+
+void QQuickPathAngleArc::setRadiusY(qreal radius)
+{
+ if (_radiusY == radius)
+ return;
+
+ _radiusY = radius;
+ emit radiusYChanged();
+ emit changed();
+}
+
+/*!
+ \qmlproperty real QtQuick::PathAngleArc::startAngle
+
+ Defines the start angle of the arc.
+
+ The start angle is reported clockwise, with zero degrees at the 3 o'clock position.
+*/
+
+qreal QQuickPathAngleArc::startAngle() const
+{
+ return _startAngle;
+}
+
+void QQuickPathAngleArc::setStartAngle(qreal angle)
+{
+ if (_startAngle == angle)
+ return;
+
+ _startAngle = angle;
+ emit startAngleChanged();
+ emit changed();
+}
+
+/*!
+ \qmlproperty real QtQuick::PathAngleArc::sweepAngle
+
+ Defines the sweep angle of the arc.
+
+ The arc will begin at startAngle and continue sweepAngle degrees, with a value of 360
+ resulting in a full circle. Positive numbers are clockwise and negative numbers are counterclockwise.
+*/
+
+qreal QQuickPathAngleArc::sweepAngle() const
+{
+ return _sweepAngle;
+}
+
+void QQuickPathAngleArc::setSweepAngle(qreal angle)
+{
+ if (_sweepAngle == angle)
+ return;
+
+ _sweepAngle = angle;
+ emit sweepAngleChanged();
+ emit changed();
+}
+
+/*!
+ \qmlproperty bool QtQuick::PathAngleArc::moveToStart
+
+ Whether this element should be disconnected from the previous Path element (or startX/Y).
+
+ The default value is true. If set to false, the previous element's end-point
+ (or startX/Y if PathAngleArc is the first element) will be connected to the arc's
+ start-point with a straight line.
+*/
+
+bool QQuickPathAngleArc::moveToStart() const
+{
+ return _moveToStart;
+}
+
+void QQuickPathAngleArc::setMoveToStart(bool move)
+{
+ if (_moveToStart == move)
+ return;
+
+ _moveToStart = move;
+ emit moveToStartChanged();
+ emit changed();
+}
+
+void QQuickPathAngleArc::addToPath(QPainterPath &path, const QQuickPathData &)
+{
+ qreal x = _centerX - _radiusX;
+ qreal y = _centerY - _radiusY;
+ qreal width = _radiusX * 2;
+ qreal height = _radiusY * 2;
+ if (_moveToStart)
+ path.arcMoveTo(x, y, width, height, -_startAngle);
+ path.arcTo(x, y, width, height, -_startAngle, -_sweepAngle);
+}
+
+/****************************************************************************/
+
+/*!
\qmltype PathSvg
\instantiates QQuickPathSvg
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Defines a path using an SVG path data string
+ \brief Defines a path using an SVG path data string.
The following QML produces the path shown below:
\table
@@ -1933,7 +2158,7 @@ void QQuickPathArc::addToPath(QPainterPath &path, const QQuickPathData &data)
ShapePath can contain one or more PathSvg elements, or one or more other
type of elements, but not both.
- \sa Path, PathLine, PathQuad, PathCubic, PathArc, PathCurve
+ \sa Path, PathLine, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve
*/
/*!
@@ -1972,7 +2197,7 @@ void QQuickPathSvg::addToPath(QPainterPath &path, const QQuickPathData &)
\instantiates QQuickPathPercent
\inqmlmodule QtQuick
\ingroup qtquick-animation-paths
- \brief Manipulates the way a path is interpreted
+ \brief Manipulates the way a path is interpreted.
PathPercent allows you to manipulate the spacing between items on a
PathView's path. You can use it to bunch together items on part of
diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h
index b7fde5c272..6b9a40fe6d 100644
--- a/src/quick/util/qquickpath_p.h
+++ b/src/quick/util/qquickpath_p.h
@@ -78,7 +78,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathElement : public QObject
{
Q_OBJECT
public:
- QQuickPathElement(QObject *parent=0) : QObject(parent) {}
+ QQuickPathElement(QObject *parent=nullptr) : QObject(parent) {}
Q_SIGNALS:
void changed();
};
@@ -90,7 +90,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathAttribute : public QQuickPathElement
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
public:
- QQuickPathAttribute(QObject *parent=0) : QQuickPathElement(parent), _value(0) {}
+ QQuickPathAttribute(QObject *parent=nullptr) : QQuickPathElement(parent) {}
QString name() const;
@@ -105,7 +105,7 @@ Q_SIGNALS:
private:
QString _name;
- qreal _value;
+ qreal _value = 0;
};
class Q_QUICK_PRIVATE_EXPORT QQuickCurve : public QQuickPathElement
@@ -117,7 +117,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickCurve : public QQuickPathElement
Q_PROPERTY(qreal relativeX READ relativeX WRITE setRelativeX NOTIFY relativeXChanged)
Q_PROPERTY(qreal relativeY READ relativeY WRITE setRelativeY NOTIFY relativeYChanged)
public:
- QQuickCurve(QObject *parent=0) : QQuickPathElement(parent) {}
+ QQuickCurve(QObject *parent=nullptr) : QQuickPathElement(parent) {}
qreal x() const;
void setX(qreal x);
@@ -154,7 +154,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathLine : public QQuickCurve
{
Q_OBJECT
public:
- QQuickPathLine(QObject *parent=0) : QQuickCurve(parent) {}
+ QQuickPathLine(QObject *parent=nullptr) : QQuickCurve(parent) {}
void addToPath(QPainterPath &path, const QQuickPathData &) override;
};
@@ -163,7 +163,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathMove : public QQuickCurve
{
Q_OBJECT
public:
- QQuickPathMove(QObject *parent=0) : QQuickCurve(parent) {}
+ QQuickPathMove(QObject *parent=nullptr) : QQuickCurve(parent) {}
void addToPath(QPainterPath &path, const QQuickPathData &) override;
};
@@ -177,7 +177,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathQuad : public QQuickCurve
Q_PROPERTY(qreal relativeControlX READ relativeControlX WRITE setRelativeControlX NOTIFY relativeControlXChanged)
Q_PROPERTY(qreal relativeControlY READ relativeControlY WRITE setRelativeControlY NOTIFY relativeControlYChanged)
public:
- QQuickPathQuad(QObject *parent=0) : QQuickCurve(parent), _controlX(0), _controlY(0) {}
+ QQuickPathQuad(QObject *parent=nullptr) : QQuickCurve(parent) {}
qreal controlX() const;
void setControlX(qreal x);
@@ -202,8 +202,8 @@ Q_SIGNALS:
void relativeControlYChanged();
private:
- qreal _controlX;
- qreal _controlY;
+ qreal _controlX = 0;
+ qreal _controlY = 0;
QQmlNullableValue<qreal> _relativeControlX;
QQmlNullableValue<qreal> _relativeControlY;
};
@@ -221,7 +221,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathCubic : public QQuickCurve
Q_PROPERTY(qreal relativeControl2X READ relativeControl2X WRITE setRelativeControl2X NOTIFY relativeControl2XChanged)
Q_PROPERTY(qreal relativeControl2Y READ relativeControl2Y WRITE setRelativeControl2Y NOTIFY relativeControl2YChanged)
public:
- QQuickPathCubic(QObject *parent=0) : QQuickCurve(parent), _control1X(0), _control1Y(0), _control2X(0), _control2Y(0) {}
+ QQuickPathCubic(QObject *parent=nullptr) : QQuickCurve(parent) {}
qreal control1X() const;
void setControl1X(qreal x);
@@ -264,10 +264,10 @@ Q_SIGNALS:
void relativeControl2YChanged();
private:
- qreal _control1X;
- qreal _control1Y;
- qreal _control2X;
- qreal _control2Y;
+ qreal _control1X = 0;
+ qreal _control1Y = 0;
+ qreal _control2X = 0;
+ qreal _control2Y = 0;
QQmlNullableValue<qreal> _relativeControl1X;
QQmlNullableValue<qreal> _relativeControl1Y;
QQmlNullableValue<qreal> _relativeControl2X;
@@ -278,7 +278,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathCatmullRomCurve : public QQuickCurve
{
Q_OBJECT
public:
- QQuickPathCatmullRomCurve(QObject *parent=0) : QQuickCurve(parent) {}
+ QQuickPathCatmullRomCurve(QObject *parent=nullptr) : QQuickCurve(parent) {}
void addToPath(QPainterPath &path, const QQuickPathData &) override;
};
@@ -293,8 +293,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathArc : public QQuickCurve
Q_PROPERTY(qreal xAxisRotation READ xAxisRotation WRITE setXAxisRotation NOTIFY xAxisRotationChanged REVISION 2)
public:
- QQuickPathArc(QObject *parent=0)
- : QQuickCurve(parent), _radiusX(0), _radiusY(0), _useLargeArc(false), _direction(Clockwise), _xAxisRotation(0) {}
+ QQuickPathArc(QObject *parent=nullptr)
+ : QQuickCurve(parent) {}
enum ArcDirection { Clockwise, Counterclockwise };
Q_ENUM(ArcDirection)
@@ -324,11 +324,68 @@ Q_SIGNALS:
Q_REVISION(2) void xAxisRotationChanged();
private:
- qreal _radiusX;
- qreal _radiusY;
- bool _useLargeArc;
- ArcDirection _direction;
- qreal _xAxisRotation;
+ qreal _radiusX = 0;
+ qreal _radiusY = 0;
+ bool _useLargeArc = false;
+ ArcDirection _direction = Clockwise;
+ qreal _xAxisRotation = 0;
+};
+
+class Q_QUICK_PRIVATE_EXPORT QQuickPathAngleArc : public QQuickCurve
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal centerX READ centerX WRITE setCenterX NOTIFY centerXChanged)
+ Q_PROPERTY(qreal centerY READ centerY WRITE setCenterY NOTIFY centerYChanged)
+ Q_PROPERTY(qreal radiusX READ radiusX WRITE setRadiusX NOTIFY radiusXChanged)
+ Q_PROPERTY(qreal radiusY READ radiusY WRITE setRadiusY NOTIFY radiusYChanged)
+ Q_PROPERTY(qreal startAngle READ startAngle WRITE setStartAngle NOTIFY startAngleChanged)
+ Q_PROPERTY(qreal sweepAngle READ sweepAngle WRITE setSweepAngle NOTIFY sweepAngleChanged)
+ Q_PROPERTY(bool moveToStart READ moveToStart WRITE setMoveToStart NOTIFY moveToStartChanged)
+
+public:
+ QQuickPathAngleArc(QObject *parent=nullptr)
+ : QQuickCurve(parent) {}
+
+ qreal centerX() const;
+ void setCenterX(qreal);
+
+ qreal centerY() const;
+ void setCenterY(qreal);
+
+ qreal radiusX() const;
+ void setRadiusX(qreal);
+
+ qreal radiusY() const;
+ void setRadiusY(qreal);
+
+ qreal startAngle() const;
+ void setStartAngle(qreal);
+
+ qreal sweepAngle() const;
+ void setSweepAngle(qreal);
+
+ bool moveToStart() const;
+ void setMoveToStart(bool);
+
+ void addToPath(QPainterPath &path, const QQuickPathData &) override;
+
+Q_SIGNALS:
+ void centerXChanged();
+ void centerYChanged();
+ void radiusXChanged();
+ void radiusYChanged();
+ void startAngleChanged();
+ void sweepAngleChanged();
+ void moveToStartChanged();
+
+private:
+ qreal _centerX = 0;
+ qreal _centerY = 0;
+ qreal _radiusX = 0;
+ qreal _radiusY = 0;
+ qreal _startAngle = 0;
+ qreal _sweepAngle = 0;
+ bool _moveToStart = true;
};
class Q_QUICK_PRIVATE_EXPORT QQuickPathSvg : public QQuickCurve
@@ -336,7 +393,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathSvg : public QQuickCurve
Q_OBJECT
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
public:
- QQuickPathSvg(QObject *parent=0) : QQuickCurve(parent) {}
+ QQuickPathSvg(QObject *parent=nullptr) : QQuickCurve(parent) {}
QString path() const;
void setPath(const QString &path);
@@ -355,7 +412,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPathPercent : public QQuickPathElement
Q_OBJECT
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged)
public:
- QQuickPathPercent(QObject *parent=0) : QQuickPathElement(parent), _value(0) {}
+ QQuickPathPercent(QObject *parent=nullptr) : QQuickPathElement(parent) {}
qreal value() const;
void setValue(qreal value);
@@ -364,18 +421,18 @@ Q_SIGNALS:
void valueChanged();
private:
- qreal _value;
+ qreal _value = 0;
};
struct QQuickCachedBezier
{
- QQuickCachedBezier() : isValid(false) {}
+ QQuickCachedBezier() {}
QBezier bezier;
int element;
qreal bezLength;
qreal currLength;
qreal p;
- bool isValid;
+ bool isValid = false;
};
class QQuickPathPrivate;
@@ -391,8 +448,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickPath : public QObject, public QQmlParserStatu
Q_CLASSINFO("DefaultProperty", "pathElements")
Q_INTERFACES(QQmlParserStatus)
public:
- QQuickPath(QObject *parent=0);
- ~QQuickPath();
+ QQuickPath(QObject *parent=nullptr);
+ ~QQuickPath() override;
QQmlListProperty<QQuickPathElement> pathElements();
@@ -410,7 +467,7 @@ public:
QStringList attributes() const;
qreal attributeAt(const QString &, qreal) const;
QPointF pointAt(qreal) const;
- QPointF sequentialPointAt(qreal p, qreal *angle = 0) const;
+ QPointF sequentialPointAt(qreal p, qreal *angle = nullptr) const;
void invalidateSequentialHistory() const;
Q_SIGNALS:
@@ -437,15 +494,15 @@ private Q_SLOTS:
private:
struct AttributePoint {
- AttributePoint() : percent(0), scale(1), origpercent(0) {}
+ AttributePoint() {}
AttributePoint(const AttributePoint &other)
: percent(other.percent), scale(other.scale), origpercent(other.origpercent), values(other.values) {}
AttributePoint &operator=(const AttributePoint &other) {
percent = other.percent; scale = other.scale; origpercent = other.origpercent; values = other.values; return *this;
}
- qreal percent; //massaged percent along the painter path
- qreal scale;
- qreal origpercent; //'real' percent along the painter path
+ qreal percent = 0; //massaged percent along the painter path
+ qreal scale = 1;
+ qreal origpercent = 0; //'real' percent along the painter path
QHash<QString, qreal> values;
};
@@ -455,8 +512,8 @@ private:
static void interpolate(QList<AttributePoint> &points, int idx, const QString &name, qreal value);
static void endpoint(QList<AttributePoint> &attributePoints, const QString &name);
- static QPointF forwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle = 0);
- static QPointF backwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle = 0);
+ static QPointF forwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle = nullptr);
+ static QPointF backwardsPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle = nullptr);
private:
Q_DISABLE_COPY(QQuickPath)
@@ -464,8 +521,9 @@ private:
friend class QQuickPathAnimationUpdater;
public:
- QPainterPath createPath(const QPointF &startPoint, const QPointF &endPoint, const QStringList &attributes, qreal &pathLength, QList<AttributePoint> &attributePoints, bool *closed = 0);
- static QPointF sequentialPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle = 0);
+ QPainterPath createPath(const QPointF &startPoint, const QPointF &endPoint, const QStringList &attributes, qreal &pathLength, QList<AttributePoint> &attributePoints, bool *closed = nullptr);
+ QPainterPath createShapePath(const QPointF &startPoint, const QPointF &endPoint, qreal &pathLength, bool *closed = nullptr);
+ static QPointF sequentialPointAt(const QPainterPath &path, const qreal &pathLength, const QList<AttributePoint> &attributePoints, QQuickCachedBezier &prevBez, qreal p, qreal *angle = nullptr);
};
QT_END_NAMESPACE
@@ -479,6 +537,7 @@ QML_DECLARE_TYPE(QQuickPathQuad)
QML_DECLARE_TYPE(QQuickPathCubic)
QML_DECLARE_TYPE(QQuickPathCatmullRomCurve)
QML_DECLARE_TYPE(QQuickPathArc)
+QML_DECLARE_TYPE(QQuickPathAngleArc)
QML_DECLARE_TYPE(QQuickPathSvg)
QML_DECLARE_TYPE(QQuickPathPercent)
QML_DECLARE_TYPE(QQuickPath)
diff --git a/src/quick/util/qquickpath_p_p.h b/src/quick/util/qquickpath_p_p.h
index 8ce85dbf0f..9735d51264 100644
--- a/src/quick/util/qquickpath_p_p.h
+++ b/src/quick/util/qquickpath_p_p.h
@@ -72,7 +72,7 @@ public:
static QQuickPathPrivate* get(QQuickPath *path) { return path->d_func(); }
static const QQuickPathPrivate* get(const QQuickPath *path) { return path->d_func(); }
- QQuickPathPrivate() : pathLength(0), closed(false), componentComplete(true) { }
+ QQuickPathPrivate() {}
QPainterPath _path;
QList<QQuickPathElement*> _pathElements;
@@ -83,9 +83,10 @@ public:
mutable QQuickCachedBezier prevBez;
QQmlNullableValue<qreal> startX;
QQmlNullableValue<qreal> startY;
- qreal pathLength;
- bool closed;
- bool componentComplete;
+ qreal pathLength = 0;
+ bool closed = false;
+ bool componentComplete = true;
+ bool isShapePath = false;
};
QT_END_NAMESPACE
diff --git a/src/quick/util/qquickpathinterpolator.cpp b/src/quick/util/qquickpathinterpolator.cpp
index 838213042e..c27ca795e8 100644
--- a/src/quick/util/qquickpathinterpolator.cpp
+++ b/src/quick/util/qquickpathinterpolator.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickPathInterpolator
\inqmlmodule QtQuick
\ingroup qtquick-animation-control
- \brief Specifies how to manually animate along a path
+ \brief Specifies how to manually animate along a path.
PathInterpolator provides \c x, \c y, and \c angle information for a particular \c progress
along a path.
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
*/
QQuickPathInterpolator::QQuickPathInterpolator(QObject *parent) :
- QObject(parent), _path(0), _x(0), _y(0), _angle(0), _progress(0)
+ QObject(parent), _path(nullptr), _x(0), _y(0), _angle(0), _progress(0)
{
}
diff --git a/src/quick/util/qquickpathinterpolator_p.h b/src/quick/util/qquickpathinterpolator_p.h
index 0fdb1a444f..60a9ff2e22 100644
--- a/src/quick/util/qquickpathinterpolator_p.h
+++ b/src/quick/util/qquickpathinterpolator_p.h
@@ -70,7 +70,7 @@ class Q_AUTOTEST_EXPORT QQuickPathInterpolator : public QObject
Q_PROPERTY(qreal y READ y NOTIFY yChanged)
Q_PROPERTY(qreal angle READ angle NOTIFY angleChanged)
public:
- explicit QQuickPathInterpolator(QObject *parent = 0);
+ explicit QQuickPathInterpolator(QObject *parent = nullptr);
QQuickPath *path() const;
void setPath(QQuickPath *path);
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index e026608150..ced0acd9ab 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -39,6 +39,7 @@
#include "qquickpixmapcache_p.h"
#include <qquickimageprovider.h>
+#include "qquickimageprovider_p.h"
#include <qqmlengine.h>
#include <private/qqmlglobal_p.h>
@@ -49,6 +50,7 @@
#include <qpa/qplatformintegration.h>
#include <QtQuick/private/qsgtexture_p.h>
+#include <QtQuick/private/qsgtexturereader_p.h>
#include <QQuickWindow>
#include <QCoreApplication>
@@ -59,9 +61,7 @@
#include <QThread>
#include <QMutex>
#include <QMutexLocker>
-#include <QWaitCondition>
#include <QBuffer>
-#include <QWaitCondition>
#include <QtCore/qdebug.h>
#include <private/qobject_p.h>
#include <QQmlFile>
@@ -178,6 +178,8 @@ public:
QQuickPixmapReaderThreadObject(QQuickPixmapReader *);
void processJobs();
bool event(QEvent *e) override;
+public slots:
+ void asyncResponseFinished(QQuickImageResponse *response);
private slots:
void networkRequestDone();
void asyncResponseFinished();
@@ -218,7 +220,6 @@ private:
QMutex mutex;
QQuickPixmapReaderThreadObject *threadObject;
- QWaitCondition waitCondition;
#if QT_CONFIG(qml_network)
QNetworkAccessManager *networkAccessManager();
@@ -243,8 +244,8 @@ public:
: refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Error),
url(u), errorString(e), requestSize(s),
providerOptions(po), appliedTransform(QQuickImageProviderOptions::UsePluginDefaultTransform),
- textureFactory(0), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
+ textureFactory(nullptr), reply(nullptr), prevUnreferenced(nullptr),
+ prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr)
{
declarativePixmaps.insert(pixmap);
}
@@ -253,8 +254,8 @@ public:
: refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Loading),
url(u), requestSize(r),
providerOptions(po), appliedTransform(aTransform),
- textureFactory(0), reply(0), prevUnreferenced(0), prevUnreferencedPtr(0),
- nextUnreferenced(0)
+ textureFactory(nullptr), reply(nullptr), prevUnreferenced(nullptr), prevUnreferencedPtr(nullptr),
+ nextUnreferenced(nullptr)
{
declarativePixmaps.insert(pixmap);
}
@@ -264,8 +265,8 @@ public:
: refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Ready),
url(u), implicitSize(s), requestSize(r),
providerOptions(po), appliedTransform(aTransform),
- textureFactory(texture), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
+ textureFactory(texture), reply(nullptr), prevUnreferenced(nullptr),
+ prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr)
{
declarativePixmaps.insert(pixmap);
}
@@ -273,8 +274,8 @@ public:
QQuickPixmapData(QQuickPixmap *pixmap, QQuickTextureFactory *texture)
: refCount(1), inCache(false), pixmapStatus(QQuickPixmap::Ready),
appliedTransform(QQuickImageProviderOptions::UsePluginDefaultTransform),
- textureFactory(texture), reply(0), prevUnreferenced(0),
- prevUnreferencedPtr(0), nextUnreferenced(0)
+ textureFactory(texture), reply(nullptr), prevUnreferenced(nullptr),
+ prevUnreferencedPtr(nullptr), nextUnreferenced(nullptr)
{
if (texture)
requestSize = implicitSize = texture->textureSize();
@@ -286,7 +287,7 @@ public:
while (!declarativePixmaps.isEmpty()) {
QQuickPixmap *referencer = declarativePixmaps.first();
declarativePixmaps.remove(referencer);
- referencer->d = 0;
+ referencer->d = nullptr;
}
delete textureFactory;
}
@@ -368,15 +369,27 @@ static void maybeRemoveAlpha(QImage *image)
switch (image->format()) {
case QImage::Format_RGBA8888:
case QImage::Format_RGBA8888_Premultiplied:
+ if (image->data_ptr()->convertInPlace(QImage::Format_RGBX8888, Qt::AutoColor))
+ break;
+
*image = image->convertToFormat(QImage::Format_RGBX8888);
break;
case QImage::Format_A2BGR30_Premultiplied:
+ if (image->data_ptr()->convertInPlace(QImage::Format_BGR30, Qt::AutoColor))
+ break;
+
*image = image->convertToFormat(QImage::Format_BGR30);
break;
case QImage::Format_A2RGB30_Premultiplied:
+ if (image->data_ptr()->convertInPlace(QImage::Format_RGB30, Qt::AutoColor))
+ break;
+
*image = image->convertToFormat(QImage::Format_RGB30);
break;
default:
+ if (image->data_ptr()->convertInPlace(QImage::Format_RGB32, Qt::AutoColor))
+ break;
+
*image = image->convertToFormat(QImage::Format_RGB32);
break;
}
@@ -413,16 +426,64 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e
}
}
+static QStringList fromLatin1List(const QList<QByteArray> &list)
+{
+ QStringList res;
+ res.reserve(list.size());
+ for (const QByteArray &item : list)
+ res.append(QString::fromLatin1(item));
+ return res;
+}
+
+class BackendSupport
+{
+public:
+ BackendSupport()
+ {
+ delete QSGContext::createTextureFactoryFromImage(QImage()); // Force init of backend data
+ hasOpenGL = QQuickWindow::sceneGraphBackend().isEmpty(); // i.e. default
+ QList<QByteArray> list;
+ if (hasOpenGL)
+ list.append(QSGTextureReader::supportedFileFormats());
+ list.append(QImageReader::supportedImageFormats());
+ fileSuffixes = fromLatin1List(list);
+ }
+ bool hasOpenGL;
+ QStringList fileSuffixes;
+};
+Q_GLOBAL_STATIC(BackendSupport, backendSupport);
+
+static QString existingImageFileForPath(const QString &localFile)
+{
+ // Do nothing if given filepath exists or already has a suffix
+ QFileInfo fi(localFile);
+ if (!fi.suffix().isEmpty() || fi.exists())
+ return localFile;
+
+ QString tryFile = localFile + QStringLiteral(".xxxx");
+ const int suffixIdx = localFile.length() + 1;
+ for (const QString &suffix : backendSupport()->fileSuffixes) {
+ tryFile.replace(suffixIdx, 10, suffix);
+ if (QFileInfo::exists(tryFile))
+ return tryFile;
+ }
+ return localFile;
+}
+
QQuickPixmapReader::QQuickPixmapReader(QQmlEngine *eng)
-: QThread(eng), engine(eng), threadObject(0)
+: QThread(eng), engine(eng), threadObject(nullptr)
#if QT_CONFIG(qml_network)
-, accessManager(0)
+, accessManager(nullptr)
#endif
{
eventLoopQuitHack = new QObject;
eventLoopQuitHack->moveToThread(this);
connect(eventLoopQuitHack, SIGNAL(destroyed(QObject*)), SLOT(quit()), Qt::DirectConnection);
start(QThread::LowestPriority);
+#if !QT_CONFIG(thread)
+ // call nonblocking run ourself, as nothread qthread does not
+ run();
+#endif
}
QQuickPixmapReader::~QQuickPixmapReader()
@@ -435,7 +496,7 @@ QQuickPixmapReader::~QQuickPixmapReader()
// manually cancel all outstanding jobs.
for (QQuickPixmapReply *reply : qAsConst(jobs)) {
if (reply->data && reply->data->reply == reply)
- reply->data->reply = 0;
+ reply->data->reply = nullptr;
delete reply;
}
jobs.clear();
@@ -444,7 +505,7 @@ QQuickPixmapReader::~QQuickPixmapReader()
const auto cancelJob = [this](QQuickPixmapReply *reply) {
if (reply->loading) {
cancelled.append(reply);
- reply->data = 0;
+ reply->data = nullptr;
}
};
@@ -518,7 +579,7 @@ void QQuickPixmapReader::asyncResponseFinished(QQuickImageResponse *response)
QQuickPixmapReply *job = asyncResponses.take(response);
if (job) {
- QQuickTextureFactory *t = 0;
+ QQuickTextureFactory *t = nullptr;
QQuickPixmapReply::ReadError error = QQuickPixmapReply::NoError;
QString errorString;
if (!response->errorString().isEmpty()) {
@@ -568,10 +629,15 @@ void QQuickPixmapReaderThreadObject::networkRequestDone()
#endif
}
+void QQuickPixmapReaderThreadObject::asyncResponseFinished(QQuickImageResponse *response)
+{
+ reader->asyncResponseFinished(response);
+}
+
void QQuickPixmapReaderThreadObject::asyncResponseFinished()
{
QQuickImageResponse *response = static_cast<QQuickImageResponse *>(sender());
- reader->asyncResponseFinished(response);
+ asyncResponseFinished(response);
}
void QQuickPixmapReader::processJobs()
@@ -617,7 +683,7 @@ void QQuickPixmapReader::processJobs()
const QUrl url = job->url;
QString localFile;
QQuickImageProvider::ImageType imageType = QQuickImageProvider::Invalid;
- QQuickImageProvider *provider = 0;
+ QQuickImageProvider *provider = nullptr;
if (url.scheme() == QLatin1String("image")) {
provider = static_cast<QQuickImageProvider *>(engine->imageProvider(imageProviderId(url)));
@@ -666,7 +732,7 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
QString errorStr = QQuickPixmap::tr("Invalid image provider: %1").arg(url.toString());
mutex.lock();
if (!cancelled.contains(runningJob))
- runningJob->postReply(QQuickPixmapReply::Loading, errorStr, readSize, 0);
+ runningJob->postReply(QQuickPixmapReply::Loading, errorStr, readSize, nullptr);
mutex.unlock();
return;
}
@@ -755,7 +821,14 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
response = asyncProvider->requestImageResponse(imageId(url), runningJob->requestSize);
}
- QObject::connect(response, SIGNAL(finished()), threadObject, SLOT(asyncResponseFinished()));
+ // Might be that the async provider was so quick it emitted the signal before we
+ // could connect to it.
+ if (static_cast<QQuickImageResponsePrivate*>(QObjectPrivate::get(response))->finished) {
+ QMetaObject::invokeMethod(threadObject, "asyncResponseFinished",
+ Qt::QueuedConnection, Q_ARG(QQuickImageResponse*, response));
+ } else {
+ QObject::connect(response, SIGNAL(finished()), threadObject, SLOT(asyncResponseFinished()));
+ }
asyncResponses.insert(response, runningJob);
break;
@@ -768,11 +841,32 @@ void QQuickPixmapReader::processJob(QQuickPixmapReply *runningJob, const QUrl &u
QImage image;
QQuickPixmapReply::ReadError errorCode = QQuickPixmapReply::NoError;
QString errorStr;
- QFile f(localFile);
+ QFile f(existingImageFileForPath(localFile));
QSize readSize;
if (f.open(QIODevice::ReadOnly)) {
- if (!readImage(url, &f, &image, &errorStr, &readSize, runningJob->requestSize, runningJob->providerOptions))
- errorCode = QQuickPixmapReply::Loading;
+ QSGTextureReader texReader(&f, localFile);
+ if (backendSupport()->hasOpenGL && texReader.isTexture()) {
+ QQuickTextureFactory *factory = texReader.read();
+ if (factory) {
+ readSize = factory->textureSize();
+ } else {
+ errorStr = QQuickPixmap::tr("Error decoding: %1").arg(url.toString());
+ if (f.fileName() != localFile)
+ errorStr += QString::fromLatin1(" (%1)").arg(f.fileName());
+ errorCode = QQuickPixmapReply::Decoding;
+ }
+ mutex.lock();
+ if (!cancelled.contains(runningJob))
+ runningJob->postReply(errorCode, errorStr, readSize, factory);
+ mutex.unlock();
+ return;
+ } else {
+ if (!readImage(url, &f, &image, &errorStr, &readSize, runningJob->requestSize, runningJob->providerOptions)) {
+ errorCode = QQuickPixmapReply::Loading;
+ if (f.fileName() != localFile)
+ errorStr += QString::fromLatin1(" (%1)").arg(f.fileName());
+ }
+ }
} else {
errorStr = QQuickPixmap::tr("Cannot open: %1").arg(url.toString());
errorCode = QQuickPixmapReply::Loading;
@@ -834,7 +928,7 @@ void QQuickPixmapReader::cancel(QQuickPixmapReply *reply)
mutex.lock();
if (reply->loading) {
cancelled.append(reply);
- reply->data = 0;
+ reply->data = nullptr;
// XXX
if (threadObject) threadObject->processJobs();
} else {
@@ -867,8 +961,11 @@ void QQuickPixmapReader::run()
processJobs();
exec();
+#if QT_CONFIG(thread)
+ // nothread exec is empty and returns
delete threadObject;
- threadObject = 0;
+ threadObject = nullptr;
+#endif
}
class QQuickPixmapKey
@@ -921,7 +1018,7 @@ Q_GLOBAL_STATIC(QQuickPixmapStore, pixmapStore);
QQuickPixmapStore::QQuickPixmapStore()
- : m_unreferencedPixmaps(0), m_lastUnreferencedPixmap(0), m_unreferencedCost(0), m_timerId(-1), m_destroying(false)
+ : m_unreferencedPixmaps(nullptr), m_lastUnreferencedPixmap(nullptr), m_unreferencedCost(0), m_timerId(-1), m_destroying(false)
{
}
@@ -938,7 +1035,8 @@ QQuickPixmapStore::~QQuickPixmapStore()
m_timerId = -2;
// unreference all (leaked) pixmaps
- for (auto *pixmap : qAsConst(m_cache)) {
+ const auto cache = m_cache; // NOTE: intentional copy (QTBUG-65077); releasing items from the cache modifies m_cache.
+ for (auto *pixmap : cache) {
int currRefCount = pixmap->refCount;
if (currRefCount) {
#ifndef QT_NO_DEBUG
@@ -964,9 +1062,9 @@ QQuickPixmapStore::~QQuickPixmapStore()
void QQuickPixmapStore::unreferencePixmap(QQuickPixmapData *data)
{
- Q_ASSERT(data->prevUnreferenced == 0);
- Q_ASSERT(data->prevUnreferencedPtr == 0);
- Q_ASSERT(data->nextUnreferenced == 0);
+ Q_ASSERT(data->prevUnreferenced == nullptr);
+ Q_ASSERT(data->prevUnreferencedPtr == nullptr);
+ Q_ASSERT(data->nextUnreferenced == nullptr);
data->nextUnreferenced = m_unreferencedPixmaps;
data->prevUnreferencedPtr = &m_unreferencedPixmaps;
@@ -1002,9 +1100,9 @@ void QQuickPixmapStore::referencePixmap(QQuickPixmapData *data)
if (m_lastUnreferencedPixmap == data)
m_lastUnreferencedPixmap = data->prevUnreferenced;
- data->nextUnreferenced = 0;
- data->prevUnreferencedPtr = 0;
- data->prevUnreferenced = 0;
+ data->nextUnreferenced = nullptr;
+ data->prevUnreferencedPtr = nullptr;
+ data->prevUnreferenced = nullptr;
m_unreferencedCost -= data->cost();
}
@@ -1013,12 +1111,12 @@ void QQuickPixmapStore::shrinkCache(int remove)
{
while ((remove > 0 || m_unreferencedCost > cache_limit) && m_lastUnreferencedPixmap) {
QQuickPixmapData *data = m_lastUnreferencedPixmap;
- Q_ASSERT(data->nextUnreferenced == 0);
+ Q_ASSERT(data->nextUnreferenced == nullptr);
- *data->prevUnreferencedPtr = 0;
+ *data->prevUnreferencedPtr = nullptr;
m_lastUnreferencedPixmap = data->prevUnreferenced;
- data->prevUnreferencedPtr = 0;
- data->prevUnreferenced = 0;
+ data->prevUnreferencedPtr = nullptr;
+ data->prevUnreferenced = nullptr;
if (!m_destroying) {
remove -= data->cost();
@@ -1035,7 +1133,7 @@ void QQuickPixmapStore::timerEvent(QTimerEvent *)
shrinkCache(removalCost);
- if (m_unreferencedPixmaps == 0) {
+ if (m_unreferencedPixmaps == nullptr) {
killTimer(m_timerId);
m_timerId = -1;
}
@@ -1052,7 +1150,7 @@ void QQuickPixmap::purgeCache()
}
QQuickPixmapReply::QQuickPixmapReply(QQuickPixmapData *d)
-: data(d), engineForReader(0), requestSize(d->requestSize), url(d->url), loading(false), providerOptions(d->providerOptions), redirectCount(0)
+: data(d), engineForReader(nullptr), requestSize(d->requestSize), url(d->url), loading(false), providerOptions(d->providerOptions), redirectCount(0)
{
if (finishedIndex == -1) {
finishedIndex = QMetaMethod::fromSignal(&QQuickPixmapReply::finished).methodIndex();
@@ -1075,10 +1173,10 @@ bool QQuickPixmapReply::event(QEvent *event)
data->pixmapStatus = (de->error == NoError) ? QQuickPixmap::Ready : QQuickPixmap::Error;
if (data->pixmapStatus == QQuickPixmap::Ready) {
data->textureFactory = de->textureFactory;
- de->textureFactory = 0;
+ de->textureFactory = nullptr;
data->implicitSize = de->implicitSize;
PIXMAP_PROFILE(pixmapLoadingFinished(data->url,
- data->textureFactory != 0 && data->textureFactory->textureSize().isValid() ?
+ data->textureFactory != nullptr && data->textureFactory->textureSize().isValid() ?
data->textureFactory->textureSize() :
(data->requestSize.isValid() ? data->requestSize : data->implicitSize)));
} else {
@@ -1087,7 +1185,7 @@ bool QQuickPixmapReply::event(QEvent *event)
data->removeFromCache(); // We don't continue to cache error'd pixmaps
}
- data->reply = 0;
+ data->reply = nullptr;
emit finished();
} else {
PIXMAP_PROFILE(pixmapStateChanged<QQuickProfiler::PixmapLoadingError>(url));
@@ -1123,8 +1221,8 @@ void QQuickPixmapData::release()
if (refCount == 0) {
if (reply) {
QQuickPixmapReply *cancelReply = reply;
- reply->data = 0;
- reply = 0;
+ reply->data = nullptr;
+ reply = nullptr;
QQuickPixmapReader::readerMutex.lock();
QQuickPixmapReader *reader = QQuickPixmapReader::existingInstance(cancelReply->engineForReader);
if (reader)
@@ -1226,18 +1324,33 @@ static QQuickPixmapData* createPixmapDataSync(QQuickPixmap *declarativePixmap, Q
QString localFile = QQmlFile::urlToLocalFileOrQrc(url);
if (localFile.isEmpty())
- return 0;
+ return nullptr;
- QFile f(localFile);
+ QFile f(existingImageFileForPath(localFile));
QSize readSize;
QString errorString;
if (f.open(QIODevice::ReadOnly)) {
- QImage image;
- QQuickImageProviderOptions::AutoTransform appliedTransform = providerOptions.autoTransform();
- if (readImage(url, &f, &image, &errorString, &readSize, requestSize, providerOptions, &appliedTransform)) {
- *ok = true;
- return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, appliedTransform);
+ QSGTextureReader texReader(&f, localFile);
+ if (backendSupport()->hasOpenGL && texReader.isTexture()) {
+ QQuickTextureFactory *factory = texReader.read();
+ if (factory) {
+ *ok = true;
+ return new QQuickPixmapData(declarativePixmap, url, factory, factory->textureSize(), requestSize, providerOptions, QQuickImageProviderOptions::UsePluginDefaultTransform);
+ } else {
+ errorString = QQuickPixmap::tr("Error decoding: %1").arg(url.toString());
+ if (f.fileName() != localFile)
+ errorString += QString::fromLatin1(" (%1)").arg(f.fileName());
+ }
+ } else {
+ QImage image;
+ QQuickImageProviderOptions::AutoTransform appliedTransform = providerOptions.autoTransform();
+ if (readImage(url, &f, &image, &errorString, &readSize, requestSize, providerOptions, &appliedTransform)) {
+ *ok = true;
+ return new QQuickPixmapData(declarativePixmap, url, QQuickTextureFactory::textureFactoryForImage(image), readSize, requestSize, providerOptions, appliedTransform);
+ } else if (f.fileName() != localFile) {
+ errorString += QString::fromLatin1(" (%1)").arg(f.fileName());
+ }
}
} else {
errorString = QQuickPixmap::tr("Cannot open: %1").arg(url.toString());
@@ -1253,18 +1366,18 @@ struct QQuickPixmapNull {
Q_GLOBAL_STATIC(QQuickPixmapNull, nullPixmap);
QQuickPixmap::QQuickPixmap()
-: d(0)
+: d(nullptr)
{
}
QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url)
-: d(0)
+: d(nullptr)
{
load(engine, url);
}
QQuickPixmap::QQuickPixmap(QQmlEngine *engine, const QUrl &url, const QSize &size)
-: d(0)
+: d(nullptr)
{
load(engine, url, size);
}
@@ -1280,13 +1393,13 @@ QQuickPixmap::~QQuickPixmap()
if (d) {
d->declarativePixmaps.remove(this);
d->release();
- d = 0;
+ d = nullptr;
}
}
bool QQuickPixmap::isNull() const
{
- return d == 0;
+ return d == nullptr;
}
bool QQuickPixmap::isReady() const
@@ -1357,7 +1470,7 @@ QQuickTextureFactory *QQuickPixmap::textureFactory() const
if (d)
return d->textureFactory;
- return 0;
+ return nullptr;
}
QImage QQuickPixmap::image() const
@@ -1435,7 +1548,7 @@ void QQuickPixmap::load(QQmlEngine *engine, const QUrl &url, const QSize &reques
if (d) {
d->declarativePixmaps.remove(this);
d->release();
- d = 0;
+ d = nullptr;
}
QQuickPixmapKey key = { &url, &requestSize, providerOptions };
@@ -1507,7 +1620,7 @@ void QQuickPixmap::clear()
if (d) {
d->declarativePixmaps.remove(this);
d->release();
- d = 0;
+ d = nullptr;
}
}
@@ -1515,10 +1628,10 @@ void QQuickPixmap::clear(QObject *obj)
{
if (d) {
if (d->reply)
- QObject::disconnect(d->reply, 0, obj, 0);
+ QObject::disconnect(d->reply, nullptr, obj, nullptr);
d->declarativePixmaps.remove(this);
d->release();
- d = 0;
+ d = nullptr;
}
}
diff --git a/src/quick/util/qquickprofiler.cpp b/src/quick/util/qquickprofiler.cpp
index 402cd44ff0..decc6eac31 100644
--- a/src/quick/util/qquickprofiler.cpp
+++ b/src/quick/util/qquickprofiler.cpp
@@ -47,12 +47,12 @@
QT_BEGIN_NAMESPACE
// instance will be set, unset in constructor. Allows static methods to be inlined.
-QQuickProfiler *QQuickProfiler::s_instance = 0;
+QQuickProfiler *QQuickProfiler::s_instance = nullptr;
quint64 QQuickProfiler::featuresEnabled = 0;
void QQuickProfiler::initialize(QObject *parent)
{
- Q_ASSERT(s_instance == 0);
+ Q_ASSERT(s_instance == nullptr);
s_instance = new QQuickProfiler(parent);
}
@@ -99,7 +99,7 @@ QQuickProfiler::~QQuickProfiler()
{
QMutexLocker lock(&m_dataMutex);
featuresEnabled = 0;
- s_instance = 0;
+ s_instance = nullptr;
}
void QQuickProfiler::startProfilingImpl(quint64 features)
@@ -116,9 +116,8 @@ void QQuickProfiler::stopProfilingImpl()
m_data.clear();
}
-void QQuickProfiler::reportDataImpl(bool trackLocations)
+void QQuickProfiler::reportDataImpl()
{
- Q_UNUSED(trackLocations);
QMutexLocker lock(&m_dataMutex);
emit dataReady(m_data);
m_data.clear();
diff --git a/src/quick/util/qquickprofiler_p.h b/src/quick/util/qquickprofiler_p.h
index d2fa935ad4..28b058c2e8 100644
--- a/src/quick/util/qquickprofiler_p.h
+++ b/src/quick/util/qquickprofiler_p.h
@@ -52,9 +52,12 @@
//
#include <QtCore/private/qabstractanimation_p.h>
-#include <QtQml/private/qqmlprofilerdefinitions_p.h>
#include <QtQuick/private/qtquickglobal_p.h>
+#if QT_CONFIG(qml_debug)
+#include <QtQml/private/qqmlprofilerdefinitions_p.h>
+#endif
+
#include <QtCore/qurl.h>
#include <QtCore/qsize.h>
#include <QtCore/qmutex.h>
@@ -62,7 +65,7 @@
QT_BEGIN_NAMESPACE
-#ifdef QT_NO_QML_DEBUGGER
+#if !QT_CONFIG(qml_debug)
#define Q_QUICK_PROFILE_IF_ENABLED(feature, Code)
@@ -330,7 +333,7 @@ public:
static void initialize(QObject *parent);
- virtual ~QQuickProfiler();
+ ~QQuickProfiler() override;
signals:
void dataReady(const QVector<QQuickProfilerData> &data);
@@ -354,11 +357,11 @@ protected:
void startProfilingImpl(quint64 features);
void stopProfilingImpl();
- void reportDataImpl(bool trackLocations);
+ void reportDataImpl();
void setTimer(const QElapsedTimer &t);
};
-#endif // QT_NO_QML_DEBUGGER
+#endif // QT_CONFIG(qml_debug)
#define Q_QUICK_PROFILE(feature, Method)\
Q_QUICK_PROFILE_IF_ENABLED(feature, QQuickProfiler::Method)
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index 8d76bd986f..d739c8a017 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -101,7 +101,7 @@ QT_BEGIN_NAMESPACE
\l {Item::}{parent} value, use ParentChange instead.
- \section2 Resetting property values
+ \section2 Resetting Property Values
The \c undefined value can be used to reset the property value for a state.
In the following example, when \c myText changes to the \e widerText
@@ -111,7 +111,7 @@ QT_BEGIN_NAMESPACE
\snippet qml/propertychanges.qml reset
- \section2 Immediate property changes in transitions
+ \section2 Immediate Property Changes in Transitions
When \l{Animation and Transitions in Qt Quick}{Transitions} are used to animate
state changes, they animate properties from their values in the current
@@ -180,7 +180,7 @@ public:
rewindExpression = QQmlPropertyPrivate::signalExpression(property);
}
- bool override(QQuickStateActionEvent *other) override {
+ bool mayOverride(QQuickStateActionEvent *other) override {
if (other == this)
return true;
if (other->type() != type())
@@ -208,18 +208,20 @@ public:
bool isExplicit : 1;
void decode();
- void decodeBinding(const QString &propertyPrefix, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding);
+ void decodeBinding(const QString &propertyPrefix, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &qmlUnit, const QV4::CompiledData::Binding *binding);
class ExpressionChange {
public:
ExpressionChange(const QString &_name,
+ const QV4::CompiledData::Binding *_binding,
QQmlBinding::Identifier _id,
const QString& _expr,
const QUrl &_url,
int _line,
int _column)
- : name(_name), id(_id), expression(_expr), url(_url), line(_line), column(_column) {}
+ : name(_name), binding(_binding), id(_id), expression(_expr), url(_url), line(_line), column(_column) {}
QString name;
+ const QV4::CompiledData::Binding *binding;
QQmlBinding::Identifier id;
QString expression;
QUrl url;
@@ -234,19 +236,19 @@ public:
QQmlProperty property(const QString &);
};
-void QQuickPropertyChangesParser::verifyList(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding)
+void QQuickPropertyChangesParser::verifyList(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding)
{
if (binding->type == QV4::CompiledData::Binding::Type_Object) {
- error(qmlUnit->objectAt(binding->value.objectIndex), QQuickPropertyChanges::tr("PropertyChanges does not support creating state-specific objects."));
+ error(compilationUnit->objectAt(binding->value.objectIndex), QQuickPropertyChanges::tr("PropertyChanges does not support creating state-specific objects."));
return;
}
if (binding->type == QV4::CompiledData::Binding::Type_GroupProperty
|| binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) {
- const QV4::CompiledData::Object *subObj = qmlUnit->objectAt(binding->value.objectIndex);
+ const QV4::CompiledData::Object *subObj = compilationUnit->objectAt(binding->value.objectIndex);
const QV4::CompiledData::Binding *subBinding = subObj->bindingTable();
for (quint32 i = 0; i < subObj->nBindings; ++i, ++subBinding) {
- verifyList(qmlUnit, subBinding);
+ verifyList(compilationUnit, subBinding);
}
}
}
@@ -257,43 +259,46 @@ void QQuickPropertyChangesPrivate::decode()
return;
for (const QV4::CompiledData::Binding *binding : qAsConst(bindings))
- decodeBinding(QString(), compilationUnit->data, binding);
+ decodeBinding(QString(), compilationUnit, binding);
bindings.clear();
decoded = true;
}
-void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix, const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding)
+void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding)
{
Q_Q(QQuickPropertyChanges);
- QString propertyName = propertyPrefix + qmlUnit->stringAt(binding->propertyNameIndex);
+ QString propertyName = propertyPrefix + compilationUnit->stringAt(binding->propertyNameIndex);
if (binding->type == QV4::CompiledData::Binding::Type_GroupProperty
|| binding->type == QV4::CompiledData::Binding::Type_AttachedProperty) {
QString pre = propertyName + QLatin1Char('.');
- const QV4::CompiledData::Object *subObj = qmlUnit->objectAt(binding->value.objectIndex);
+ const QV4::CompiledData::Object *subObj = compilationUnit->objectAt(binding->value.objectIndex);
const QV4::CompiledData::Binding *subBinding = subObj->bindingTable();
for (quint32 i = 0; i < subObj->nBindings; ++i, ++subBinding) {
- decodeBinding(pre, qmlUnit, subBinding);
+ decodeBinding(pre, compilationUnit, subBinding);
}
return;
}
- QQmlProperty prop = property(propertyName); //### better way to check for signal property?
-
- if (prop.type() & QQmlProperty::SignalProperty) {
- QQuickReplaceSignalHandler *handler = new QQuickReplaceSignalHandler;
- handler->property = prop;
- handler->expression.take(new QQmlBoundSignalExpression(object, QQmlPropertyPrivate::get(prop)->signalIndex(),
- QQmlContextData::get(qmlContext(q)), object, compilationUnit->runtimeFunctions.at(binding->value.compiledScriptIndex)));
- signalReplacements << handler;
- return;
+ if (propertyName.count() >= 3 &&
+ propertyName.at(0) == QLatin1Char('o') &&
+ propertyName.at(1) == QLatin1Char('n') &&
+ propertyName.at(2).isUpper()) {
+ QQmlProperty prop = property(propertyName);
+ if (prop.isSignalProperty()) {
+ QQuickReplaceSignalHandler *handler = new QQuickReplaceSignalHandler;
+ handler->property = prop;
+ handler->expression.take(new QQmlBoundSignalExpression(object, QQmlPropertyPrivate::get(prop)->signalIndex(),
+ QQmlContextData::get(qmlContext(q)), object, compilationUnit->runtimeFunctions.at(binding->value.compiledScriptIndex)));
+ signalReplacements << handler;
+ return;
+ }
}
- if (binding->type == QV4::CompiledData::Binding::Type_Script) {
- QString expression = binding->valueAsString(qmlUnit);
+ if (binding->type == QV4::CompiledData::Binding::Type_Script || binding->isTranslationBinding()) {
QUrl url = QUrl();
int line = -1;
int column = -1;
@@ -305,25 +310,35 @@ void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix,
column = ddata->columnNumber;
}
- expressions << ExpressionChange(propertyName, binding->value.compiledScriptIndex, expression, url, line, column);
+ QString expression;
+ QQmlBinding::Identifier id = QQmlBinding::Invalid;
+
+ if (!binding->isTranslationBinding()) {
+ expression = binding->valueAsString(compilationUnit.data());
+ id = binding->value.compiledScriptIndex;
+ }
+ expressions << ExpressionChange(propertyName, binding, id, expression, url, line, column);
return;
}
QVariant var;
switch (binding->type) {
case QV4::CompiledData::Binding::Type_Script:
- Q_UNREACHABLE();
case QV4::CompiledData::Binding::Type_Translation:
case QV4::CompiledData::Binding::Type_TranslationById:
+ Q_UNREACHABLE();
case QV4::CompiledData::Binding::Type_String:
- var = binding->valueAsString(qmlUnit);
+ var = binding->valueAsString(compilationUnit.data());
break;
case QV4::CompiledData::Binding::Type_Number:
- var = binding->valueAsNumber();
+ var = binding->valueAsNumber(compilationUnit->constants);
break;
case QV4::CompiledData::Binding::Type_Boolean:
var = binding->valueAsBoolean();
break;
+ case QV4::CompiledData::Binding::Type_Null:
+ var = QVariant::fromValue(nullptr);
+ break;
default:
break;
}
@@ -331,13 +346,13 @@ void QQuickPropertyChangesPrivate::decodeBinding(const QString &propertyPrefix,
properties << qMakePair(propertyName, var);
}
-void QQuickPropertyChangesParser::verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props)
+void QQuickPropertyChangesParser::verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props)
{
for (int ii = 0; ii < props.count(); ++ii)
- verifyList(qmlUnit, props.at(ii));
+ verifyList(compilationUnit, props.at(ii));
}
-void QQuickPropertyChangesParser::applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
+void QQuickPropertyChangesParser::applyBindings(QObject *obj, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings)
{
QQuickPropertyChangesPrivate *p =
static_cast<QQuickPropertyChangesPrivate *>(QObjectPrivate::get(obj));
@@ -395,7 +410,10 @@ QQmlProperty
QQuickPropertyChangesPrivate::property(const QString &property)
{
Q_Q(QQuickPropertyChanges);
- QQmlProperty prop(object, property, qmlContext(q));
+ QQmlContextData *context = nullptr;
+ if (QQmlData *ddata = QQmlData::get(q))
+ context = ddata->outerContext;
+ QQmlProperty prop = QQmlPropertyPrivate::create(object, property, context);
if (!prop.isValid()) {
qmlWarning(q) << QQuickPropertyChanges::tr("Cannot assign to non-existent property \"%1\"").arg(property);
return QQmlProperty();
@@ -415,9 +433,10 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
ActionList list;
for (int ii = 0; ii < d->properties.count(); ++ii) {
+ QQmlProperty prop = d->property(d->properties.at(ii).first);
- QQuickStateAction a(d->object, d->properties.at(ii).first,
- qmlContext(this), d->properties.at(ii).second);
+ QQuickStateAction a(d->object, prop, d->properties.at(ii).first,
+ d->properties.at(ii).second);
if (a.property.isValid()) {
a.restore = restoreEntryValues();
@@ -426,7 +445,6 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
}
for (int ii = 0; ii < d->signalReplacements.count(); ++ii) {
-
QQuickReplaceSignalHandler *handler = d->signalReplacements.at(ii);
if (handler->property.isValid()) {
@@ -452,14 +470,15 @@ QQuickPropertyChanges::ActionList QQuickPropertyChanges::actions()
QQmlContextData *context = QQmlContextData::get(qmlContext(this));
- QQmlBinding *newBinding = 0;
- if (e.id != QQmlBinding::Invalid) {
- QV4::Scope scope(QQmlEnginePrivate::getV4Engine(qmlEngine(this)));
+ QQmlBinding *newBinding = nullptr;
+ if (e.binding && e.binding->isTranslationBinding()) {
+ newBinding = QQmlBinding::createTranslationBinding(d->compilationUnit, e.binding, object(), context);
+ } else if (e.id != QQmlBinding::Invalid) {
+ QV4::Scope scope(qmlEngine(this)->handle());
QV4::Scoped<QV4::QmlContext> qmlContext(scope, QV4::QmlContext::create(scope.engine->rootContext(), context, object()));
newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core,
d->compilationUnit->runtimeFunctions.at(e.id), object(), context, qmlContext);
}
-// QQmlBinding *newBinding = e.id != QQmlBinding::Invalid ? QQmlBinding::createBinding(e.id, object(), qmlContext(this)) : 0;
if (!newBinding)
newBinding = QQmlBinding::create(&QQmlPropertyPrivate::get(prop)->core,
e.expression, object(), context, e.url.toString(), e.line);
@@ -638,7 +657,7 @@ void QQuickPropertyChanges::changeExpression(const QString &name, const QString
}
// adding a new expression.
- expressionIterator.insert(ExpressionEntry(name, QQmlBinding::Invalid, expression, QUrl(), -1, -1));
+ expressionIterator.insert(ExpressionEntry(name, nullptr, QQmlBinding::Invalid, expression, QUrl(), -1, -1));
if (state() && state()->isStateActive()) {
if (hadValue) {
diff --git a/src/quick/util/qquickpropertychanges_p.h b/src/quick/util/qquickpropertychanges_p.h
index 35b37e84cb..74fe511d6e 100644
--- a/src/quick/util/qquickpropertychanges_p.h
+++ b/src/quick/util/qquickpropertychanges_p.h
@@ -101,10 +101,10 @@ public:
QQuickPropertyChangesParser()
: QQmlCustomParser(AcceptsAttachedProperties) {}
- void verifyList(const QV4::CompiledData::Unit *qmlUnit, const QV4::CompiledData::Binding *binding);
+ void verifyList(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QV4::CompiledData::Binding *binding);
- void verifyBindings(const QV4::CompiledData::Unit *qmlUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
- void applyBindings(QObject *obj, QV4::CompiledData::CompilationUnit *compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
+ void verifyBindings(const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &props) override;
+ void applyBindings(QObject *obj, const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit, const QList<const QV4::CompiledData::Binding *> &bindings) override;
};
diff --git a/src/quick/util/qquickshortcut.cpp b/src/quick/util/qquickshortcut.cpp
index 2fe4962b1a..730a14369e 100644
--- a/src/quick/util/qquickshortcut.cpp
+++ b/src/quick/util/qquickshortcut.cpp
@@ -41,6 +41,7 @@
#include <QtQuick/qquickitem.h>
#include <QtQuick/qquickwindow.h>
+#include <QtQuick/qquickrendercontrol.h>
#include <QtQuick/private/qtquickglobal_p.h>
#include <QtGui/private/qguiapplication_p.h>
@@ -50,7 +51,7 @@
\inqmlmodule QtQuick
\since 5.5
\ingroup qtquick-input
- \brief Provides keyboard shortcuts
+ \brief Provides keyboard shortcuts.
The Shortcut type provides a way of handling keyboard shortcuts. The shortcut can
be set to one of the \l{QKeySequence::StandardKey}{standard keyboard shortcuts},
@@ -102,6 +103,8 @@ static bool qQuickShortcutContextMatcher(QObject *obj, Qt::ShortcutContext conte
if (QQuickItem *item = qobject_cast<QQuickItem *>(obj))
obj = item->window();
}
+ if (QWindow *renderWindow = QQuickRenderControl::renderWindowFor(qobject_cast<QQuickWindow *>(obj)))
+ obj = renderWindow;
return obj && obj == QGuiApplication::focusWindow();
default:
return false;
@@ -119,7 +122,8 @@ Q_QUICK_PRIVATE_EXPORT ContextMatcher qt_quick_shortcut_context_matcher()
Q_QUICK_PRIVATE_EXPORT void qt_quick_set_shortcut_context_matcher(ContextMatcher matcher)
{
- *ctxMatcher() = matcher;
+ if (!ctxMatcher.isDestroyed())
+ *ctxMatcher() = matcher;
}
QT_BEGIN_NAMESPACE
diff --git a/src/quick/util/qquickshortcut_p.h b/src/quick/util/qquickshortcut_p.h
index db918058b2..c5d5501cb7 100644
--- a/src/quick/util/qquickshortcut_p.h
+++ b/src/quick/util/qquickshortcut_p.h
@@ -74,7 +74,7 @@ class QQuickShortcut : public QObject, public QQmlParserStatus
Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext NOTIFY contextChanged FINAL)
public:
- explicit QQuickShortcut(QObject *parent = Q_NULLPTR);
+ explicit QQuickShortcut(QObject *parent = nullptr);
~QQuickShortcut();
QVariant sequence() const;
@@ -106,9 +106,9 @@ Q_SIGNALS:
void activatedAmbiguously();
protected:
- void classBegin() Q_DECL_OVERRIDE;
- void componentComplete() Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ void classBegin() override;
+ void componentComplete() override;
+ bool event(QEvent *event) override;
struct Shortcut {
Shortcut() : id(0) { }
diff --git a/src/quick/util/qquicksmoothedanimation.cpp b/src/quick/util/qquicksmoothedanimation.cpp
index 607f39768b..bae57172d1 100644
--- a/src/quick/util/qquicksmoothedanimation.cpp
+++ b/src/quick/util/qquicksmoothedanimation.cpp
@@ -324,7 +324,7 @@ void QSmoothedAnimation::debugAnimation(QDebug d) const
\inqmlmodule QtQuick
\ingroup qtquick-transitions-animations
\inherits NumberAnimation
- \brief Allows a property to smoothly track a value
+ \brief Allows a property to smoothly track a value.
A SmoothedAnimation animates a property's value to a set target value
using an ease in/out quad easing curve. When the target value changes,
diff --git a/src/quick/util/qquicksmoothedanimation_p.h b/src/quick/util/qquicksmoothedanimation_p.h
index 2f0e3bc0d8..7bceba387c 100644
--- a/src/quick/util/qquicksmoothedanimation_p.h
+++ b/src/quick/util/qquicksmoothedanimation_p.h
@@ -73,7 +73,7 @@ public:
enum ReversingMode { Eased, Immediate, Sync };
Q_ENUM(ReversingMode)
- QQuickSmoothedAnimation(QObject *parent = 0);
+ QQuickSmoothedAnimation(QObject *parent = nullptr);
~QQuickSmoothedAnimation();
ReversingMode reversingMode() const;
@@ -91,7 +91,7 @@ public:
QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0) override;
+ QObject *defaultTarget = nullptr) override;
Q_SIGNALS:
void velocityChanged();
void reversingModeChanged();
diff --git a/src/quick/util/qquicksmoothedanimation_p_p.h b/src/quick/util/qquicksmoothedanimation_p_p.h
index a415fdb55f..7850562594 100644
--- a/src/quick/util/qquicksmoothedanimation_p_p.h
+++ b/src/quick/util/qquicksmoothedanimation_p_p.h
@@ -65,7 +65,7 @@ class QSmoothedAnimationTimer : public QTimer
{
Q_OBJECT
public:
- explicit QSmoothedAnimationTimer(QSmoothedAnimation *animation, QObject *parent = 0);
+ explicit QSmoothedAnimationTimer(QSmoothedAnimation *animation, QObject *parent = nullptr);
~QSmoothedAnimationTimer();
public Q_SLOTS:
void stopAnimation();
@@ -78,7 +78,7 @@ class Q_AUTOTEST_EXPORT QSmoothedAnimation : public QAbstractAnimationJob
{
Q_DISABLE_COPY(QSmoothedAnimation)
public:
- QSmoothedAnimation(QQuickSmoothedAnimationPrivate * = 0);
+ QSmoothedAnimation(QQuickSmoothedAnimationPrivate * = nullptr);
~QSmoothedAnimation();
qreal to;
@@ -98,7 +98,7 @@ public:
void init();
void prepareForRestart();
- void clearTemplate() { animationTemplate = 0; }
+ void clearTemplate() { animationTemplate = nullptr; }
protected:
void updateCurrentTime(int) override;
diff --git a/src/quick/util/qquickspringanimation.cpp b/src/quick/util/qquickspringanimation.cpp
index bf844589ba..9012d20f9a 100644
--- a/src/quick/util/qquickspringanimation.cpp
+++ b/src/quick/util/qquickspringanimation.cpp
@@ -58,7 +58,7 @@ class Q_AUTOTEST_EXPORT QSpringAnimation : public QAbstractAnimationJob
{
Q_DISABLE_COPY(QSpringAnimation)
public:
- QSpringAnimation(QQuickSpringAnimationPrivate * = 0);
+ QSpringAnimation(QQuickSpringAnimationPrivate * = nullptr);
~QSpringAnimation();
int duration() const override;
@@ -94,7 +94,7 @@ public:
typedef QHash<QQmlProperty, QSpringAnimation*> ActiveAnimationHash;
typedef ActiveAnimationHash::Iterator ActiveAnimationHashIt;
- void clearTemplate() { animationTemplate = 0; }
+ void clearTemplate() { animationTemplate = nullptr; }
protected:
void updateCurrentTime(int time) override;
@@ -352,7 +352,7 @@ void QQuickSpringAnimationPrivate::updateMode()
\ingroup qtquick-transitions-animations
\inherits NumberAnimation
- \brief Allows a property to track a value in a spring-like motion
+ \brief Allows a property to track a value in a spring-like motion.
SpringAnimation mimics the oscillatory behavior of a spring, with the appropriate \l spring constant to
control the acceleration and the \l damping to control how quickly the effect dies away.
diff --git a/src/quick/util/qquickspringanimation_p.h b/src/quick/util/qquickspringanimation_p.h
index ffb2c41e6b..2014a4311a 100644
--- a/src/quick/util/qquickspringanimation_p.h
+++ b/src/quick/util/qquickspringanimation_p.h
@@ -73,7 +73,7 @@ class Q_AUTOTEST_EXPORT QQuickSpringAnimation : public QQuickNumberAnimation
Q_PROPERTY(qreal mass READ mass WRITE setMass NOTIFY massChanged)
public:
- QQuickSpringAnimation(QObject *parent=0);
+ QQuickSpringAnimation(QObject *parent=nullptr);
~QQuickSpringAnimation();
qreal velocity() const;
@@ -97,7 +97,7 @@ public:
QAbstractAnimationJob* transition(QQuickStateActions &actions,
QQmlProperties &modified,
TransitionDirection direction,
- QObject *defaultTarget = 0) override;
+ QObject *defaultTarget = nullptr) override;
Q_SIGNALS:
void modulusChanged();
diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp
index 0a49d41491..3ca6440784 100644
--- a/src/quick/util/qquickstate.cpp
+++ b/src/quick/util/qquickstate.cpp
@@ -52,8 +52,8 @@ QT_BEGIN_NAMESPACE
DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG);
QQuickStateAction::QQuickStateAction()
-: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(0), event(0),
- specifiedObject(0)
+: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false), fromBinding(nullptr), event(nullptr),
+ specifiedObject(nullptr)
{
}
@@ -61,18 +61,17 @@ QQuickStateAction::QQuickStateAction(QObject *target, const QString &propertyNam
const QVariant &value)
: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
property(target, propertyName, qmlEngine(target)), toValue(value),
- fromBinding(0), event(0),
+ fromBinding(nullptr), event(nullptr),
specifiedObject(target), specifiedProperty(propertyName)
{
if (property.isValid())
fromValue = property.read();
}
-QQuickStateAction::QQuickStateAction(QObject *target, const QString &propertyName,
- QQmlContext *context, const QVariant &value)
+QQuickStateAction::QQuickStateAction(QObject *target, const QQmlProperty &property, const QString &propertyName, const QVariant &value)
: restore(true), actionDone(false), reverseEvent(false), deletableToBinding(false),
- property(target, propertyName, context), toValue(value),
- fromBinding(0), event(0),
+ property(property), toValue(value),
+ fromBinding(nullptr), event(nullptr),
specifiedObject(target), specifiedProperty(propertyName)
{
if (property.isValid())
@@ -106,7 +105,7 @@ void QQuickStateActionEvent::clearBindings()
{
}
-bool QQuickStateActionEvent::override(QQuickStateActionEvent *other)
+bool QQuickStateActionEvent::mayOverride(QQuickStateActionEvent *other)
{
Q_UNUSED(other);
return false;
@@ -122,7 +121,7 @@ QQuickStateOperation::QQuickStateOperation(QObjectPrivate &dd, QObject *parent)
\instantiates QQuickState
\inqmlmodule QtQuick
\ingroup qtquick-states
- \brief Defines configurations of objects and properties
+ \brief Defines configurations of objects and properties.
A \e state is a set of batched changes from the default configuration.
@@ -193,7 +192,7 @@ bool QQuickState::isNamed() const
bool QQuickState::isWhenKnown() const
{
Q_D(const QQuickState);
- return d->when != 0;
+ return d->when != nullptr;
}
/*!
@@ -223,7 +222,7 @@ bool QQuickState::isWhenKnown() const
QQmlBinding *QQuickState::when() const
{
Q_D(const QQuickState);
- return d->when;
+ return d->when.data();
}
void QQuickState::setWhen(QQmlBinding *when)
@@ -363,7 +362,7 @@ void QQuickStateAction::deleteFromBinding()
{
if (fromBinding) {
QQmlPropertyPrivate::removeBinding(property);
- fromBinding = 0;
+ fromBinding = nullptr;
}
}
@@ -531,7 +530,7 @@ QQmlAbstractBinding *QQuickState::bindingInRevertList(QObject *target, const QSt
}
}
- return 0;
+ return nullptr;
}
bool QQuickState::isStateActive() const
@@ -574,7 +573,7 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert)
for (int jj = 0; jj < d->revertList.count(); ++jj) {
QQuickStateActionEvent *event = d->revertList.at(jj).event();
if (event && event->type() == action.event->type()) {
- if (action.event->override(event)) {
+ if (action.event->mayOverride(event)) {
found = true;
if (action.event != d->revertList.at(jj).event() && action.event->needsCopy()) {
@@ -636,7 +635,7 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert)
for (int jj = 0; !found && jj < applyList.count(); ++jj) {
const QQuickStateAction &action = applyList.at(jj);
if (action.event && action.event->type() == event->type()) {
- if (action.event->override(event))
+ if (action.event->mayOverride(event))
found = true;
}
}
diff --git a/src/quick/util/qquickstate_p.h b/src/quick/util/qquickstate_p.h
index 7d22ca9f8c..79874ee78e 100644
--- a/src/quick/util/qquickstate_p.h
+++ b/src/quick/util/qquickstate_p.h
@@ -69,8 +69,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickStateAction
public:
QQuickStateAction();
QQuickStateAction(QObject *, const QString &, const QVariant &);
- QQuickStateAction(QObject *, const QString &,
- QQmlContext *, const QVariant &);
+ QQuickStateAction(QObject *, const QQmlProperty &property, const QString &,
+ const QVariant &);
bool restore:1;
bool actionDone:1;
@@ -115,7 +115,7 @@ public:
virtual bool changesBindings();
virtual void clearBindings();
- virtual bool override(QQuickStateActionEvent*other);
+ virtual bool mayOverride(QQuickStateActionEvent*other);
};
//### rename to QQuickStateChange?
@@ -126,7 +126,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickStateOperation : public QObject
{
Q_OBJECT
public:
- QQuickStateOperation(QObject *parent = 0)
+ QQuickStateOperation(QObject *parent = nullptr)
: QObject(parent) {}
typedef QList<QQuickStateAction> ActionList;
@@ -136,7 +136,7 @@ public:
void setState(QQuickState *state);
protected:
- QQuickStateOperation(QObjectPrivate &dd, QObject *parent = 0);
+ QQuickStateOperation(QObjectPrivate &dd, QObject *parent = nullptr);
private:
Q_DECLARE_PRIVATE(QQuickStateOperation)
@@ -159,8 +159,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickState : public QObject
Q_CLASSINFO("DeferredPropertyNames", "changes")
public:
- QQuickState(QObject *parent=0);
- virtual ~QQuickState();
+ QQuickState(QObject *parent=nullptr);
+ ~QQuickState() override;
QString name() const;
void setName(const QString &);
diff --git a/src/quick/util/qquickstate_p_p.h b/src/quick/util/qquickstate_p_p.h
index eba1dabecf..61472b4d06 100644
--- a/src/quick/util/qquickstate_p_p.h
+++ b/src/quick/util/qquickstate_p_p.h
@@ -178,8 +178,8 @@ private:
class QQuickRevertAction
{
public:
- QQuickRevertAction() : event(0) {}
- QQuickRevertAction(const QQmlProperty &prop) : property(prop), event(0) {}
+ QQuickRevertAction() : event(nullptr) {}
+ QQuickRevertAction(const QQmlProperty &prop) : property(prop), event(nullptr) {}
QQuickRevertAction(QQuickStateActionEvent *e) : event(e) {}
QQmlProperty property;
QQuickStateActionEvent *event;
@@ -192,7 +192,7 @@ class QQuickStateOperationPrivate : public QObjectPrivate
public:
QQuickStateOperationPrivate()
- : m_state(0) {}
+ : m_state(nullptr) {}
QQuickState *m_state;
};
@@ -203,12 +203,12 @@ class QQuickStatePrivate : public QObjectPrivate
public:
QQuickStatePrivate()
- : when(0), named(false), inState(false), group(0) {}
+ : named(false), inState(false), group(nullptr) {}
typedef QList<QQuickSimpleAction> SimpleActionList;
QString name;
- QQmlBinding *when;
+ QQmlBinding::Ptr when;
bool named;
struct OperationGuard : public QQmlGuard<QQuickStateOperation>
@@ -233,7 +233,7 @@ public:
QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
QMutableListIterator<OperationGuard> listIterator(*list);
while(listIterator.hasNext())
- listIterator.next()->setState(0);
+ listIterator.next()->setState(nullptr);
list->clear();
}
static int operations_count(QQmlListProperty<QQuickStateOperation> *prop) {
diff --git a/src/quick/util/qquickstatechangescript.cpp b/src/quick/util/qquickstatechangescript.cpp
index a70fa1a676..f971d7e551 100644
--- a/src/quick/util/qquickstatechangescript.cpp
+++ b/src/quick/util/qquickstatechangescript.cpp
@@ -69,7 +69,7 @@ public:
\instantiates QQuickStateChangeScript
\inqmlmodule QtQuick
\ingroup qtquick-states
- \brief Specifies how to run a script in a state
+ \brief Specifies how to run a script in a state.
A StateChangeScript is run upon entering a state. You can optionally use
ScriptAction to specify the point in the transition at which
diff --git a/src/quick/util/qquickstatechangescript_p.h b/src/quick/util/qquickstatechangescript_p.h
index a1315ae2ef..ff509a7cf5 100644
--- a/src/quick/util/qquickstatechangescript_p.h
+++ b/src/quick/util/qquickstatechangescript_p.h
@@ -66,7 +66,7 @@ class Q_AUTOTEST_EXPORT QQuickStateChangeScript : public QQuickStateOperation, p
Q_PROPERTY(QString name READ name WRITE setName)
public:
- QQuickStateChangeScript(QObject *parent=0);
+ QQuickStateChangeScript(QObject *parent=nullptr);
~QQuickStateChangeScript();
ActionList actions() override;
diff --git a/src/quick/util/qquickstategroup.cpp b/src/quick/util/qquickstategroup.cpp
index ebcbbf93ed..d8daec2f07 100644
--- a/src/quick/util/qquickstategroup.cpp
+++ b/src/quick/util/qquickstategroup.cpp
@@ -60,7 +60,7 @@ class QQuickStateGroupPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QQuickStateGroup)
public:
QQuickStateGroupPrivate()
- : nullState(0), componentComplete(true),
+ : nullState(nullptr), componentComplete(true),
ignoreTrans(false), applyingState(false), unnamedCount(0) {}
QString currentState;
@@ -94,7 +94,7 @@ public:
\instantiates QQuickStateGroup
\inqmlmodule QtQuick
\ingroup qtquick-states
- \brief Provides built-in state support for non-Item types
+ \brief Provides built-in state support for non-Item types.
Item (and all derived types) provides built in support for states and transitions
via its \l{Item::state}{state}, \l{Item::states}{states} and \l{Item::transitions}{transitions} properties. StateGroup provides an easy way to
@@ -129,7 +129,7 @@ QQuickStateGroup::~QQuickStateGroup()
{
Q_D(const QQuickStateGroup);
for (int i = 0; i < d->states.count(); ++i)
- d->states.at(i)->setStateGroup(0);
+ d->states.at(i)->setStateGroup(nullptr);
}
QList<QQuickState *> QQuickStateGroup::states() const
@@ -194,7 +194,7 @@ void QQuickStateGroupPrivate::clear_states(QQmlListProperty<QQuickState> *list)
QQuickStateGroup *_this = static_cast<QQuickStateGroup *>(list->object);
_this->d_func()->setCurrentStateInternal(QString(), true);
for (int i = 0; i < _this->d_func()->states.count(); ++i) {
- _this->d_func()->states.at(i)->setStateGroup(0);
+ _this->d_func()->states.at(i)->setStateGroup(nullptr);
}
_this->d_func()->states.clear();
}
@@ -302,10 +302,19 @@ void QQuickStateGroup::componentComplete()
Q_D(QQuickStateGroup);
d->componentComplete = true;
+ QVarLengthArray<QString, 4> names;
+ names.reserve(d->states.count());
for (int ii = 0; ii < d->states.count(); ++ii) {
QQuickState *state = d->states.at(ii);
if (!state->isNamed())
state->setName(QLatin1String("anonymousState") + QString::number(++d->unnamedCount));
+
+ const QString stateName = state->name();
+ if (names.contains(stateName)) {
+ qmlWarning(state->parent()) << "Found duplicate state name: " << stateName;
+ } else {
+ names.append(std::move(stateName));
+ }
}
if (d->updateAutoState()) {
@@ -364,7 +373,7 @@ bool QQuickStateGroupPrivate::updateAutoState()
QQuickTransition *QQuickStateGroupPrivate::findTransition(const QString &from, const QString &to)
{
- QQuickTransition *highest = 0;
+ QQuickTransition *highest = nullptr;
int score = 0;
bool reversed = false;
bool done = false;
@@ -444,7 +453,7 @@ void QQuickStateGroupPrivate::setCurrentStateInternal(const QString &state,
applyingState = true;
- QQuickTransition *transition = ignoreTrans ? 0 : findTransition(currentState, state);
+ QQuickTransition *transition = ignoreTrans ? nullptr : findTransition(currentState, state);
if (stateChangeDebug()) {
qWarning() << this << "Changing state. From" << currentState << ". To" << state;
if (transition)
@@ -452,7 +461,7 @@ void QQuickStateGroupPrivate::setCurrentStateInternal(const QString &state,
<< transition->toState();
}
- QQuickState *oldState = 0;
+ QQuickState *oldState = nullptr;
if (!currentState.isEmpty()) {
for (int ii = 0; ii < states.count(); ++ii) {
if (states.at(ii)->name() == currentState) {
@@ -465,7 +474,7 @@ void QQuickStateGroupPrivate::setCurrentStateInternal(const QString &state,
currentState = state;
emit q->stateChanged(currentState);
- QQuickState *newState = 0;
+ QQuickState *newState = nullptr;
for (int ii = 0; ii < states.count(); ++ii) {
if (states.at(ii)->name() == currentState) {
newState = states.at(ii);
@@ -473,7 +482,7 @@ void QQuickStateGroupPrivate::setCurrentStateInternal(const QString &state,
}
}
- if (oldState == 0 || newState == 0) {
+ if (oldState == nullptr || newState == nullptr) {
if (!nullState) {
nullState = new QQuickState;
QQml_setParent_noEvent(nullState, q);
@@ -496,7 +505,7 @@ QQuickState *QQuickStateGroup::findState(const QString &name) const
return state;
}
- return 0;
+ return nullptr;
}
void QQuickStateGroup::removeState(QQuickState *state)
diff --git a/src/quick/util/qquickstategroup_p.h b/src/quick/util/qquickstategroup_p.h
index eebe3a9e56..7235066d99 100644
--- a/src/quick/util/qquickstategroup_p.h
+++ b/src/quick/util/qquickstategroup_p.h
@@ -67,7 +67,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickStateGroup : public QObject, public QQmlParse
Q_PROPERTY(QQmlListProperty<QQuickTransition> transitions READ transitionsProperty DESIGNABLE false)
public:
- QQuickStateGroup(QObject * = 0);
+ QQuickStateGroup(QObject * = nullptr);
virtual ~QQuickStateGroup();
QString state() const;
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp
index ae8719341d..7d545cdb2f 100644
--- a/src/quick/util/qquickstyledtext.cpp
+++ b/src/quick/util/qquickstyledtext.cpp
@@ -50,6 +50,8 @@
QQuickStyledText supports few tags:
<b></b> - bold
+ <del></del> - strike out (removed content)
+ <s></s> - strike out (no longer accurate or no longer relevant content)
<strong></strong> - bold
<i></i> - italic
<br> - new line
@@ -379,8 +381,16 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn,
format.setFontWeight(QFont::Bold);
return true;
}
- } else if (tag == QLatin1String("strong")) {
- format.setFontWeight(QFont::Bold);
+ } else if (char0 == QLatin1Char('s')) {
+ if (tagLength == 1) {
+ format.setFontStrikeOut(true);
+ return true;
+ } else if (tag == QLatin1String("strong")) {
+ format.setFontWeight(QFont::Bold);
+ return true;
+ }
+ } else if (tag == QLatin1String("del")) {
+ format.setFontStrikeOut(true);
return true;
} else if (tag == QLatin1String("ol")) {
List listItem;
@@ -511,7 +521,13 @@ bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &tex
return true;
} else if (tag == QLatin1String("font")) {
return true;
- } else if (tag == QLatin1String("strong")) {
+ } else if (char0 == QLatin1Char('s')) {
+ if (tagLength == 1) {
+ return true;
+ } else if (tag == QLatin1String("strong")) {
+ return true;
+ }
+ } else if (tag == QLatin1String("del")) {
return true;
} else if (tag == QLatin1String("ol")) {
if (!listStack.isEmpty()) {
@@ -659,7 +675,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
{
qreal imgWidth = 0.0;
QFontMetricsF fm(layout.font());
- const qreal spaceWidth = fm.width(QChar::Nbsp);
+ const qreal spaceWidth = fm.horizontalAdvance(QChar::Nbsp);
const bool trailingSpace = textOut.endsWith(space);
if (!updateImagePositions) {
@@ -695,7 +711,7 @@ void QQuickStyledTextPrivate::parseImageAttributes(const QChar *&ch, const QStri
image->size = image->pix->implicitSize();
} else {
delete image->pix;
- image->pix = 0;
+ image->pix = nullptr;
}
}
}
diff --git a/src/quick/util/qquickstyledtext_p.h b/src/quick/util/qquickstyledtext_p.h
index 2a2e234224..51f1b7d8f9 100644
--- a/src/quick/util/qquickstyledtext_p.h
+++ b/src/quick/util/qquickstyledtext_p.h
@@ -67,9 +67,7 @@ class QQmlContext;
class Q_AUTOTEST_EXPORT QQuickStyledTextImgTag
{
public:
- QQuickStyledTextImgTag()
- : position(0), offset(0.0), align(QQuickStyledTextImgTag::Bottom), pix(0)
- { }
+ QQuickStyledTextImgTag() { }
~QQuickStyledTextImgTag() { delete pix; }
@@ -82,10 +80,10 @@ public:
QUrl url;
QPointF pos;
QSize size;
- int position;
- qreal offset; // this offset allows us to compensate for flooring reserved space
- Align align;
- QQuickPixmap *pix;
+ int position = 0;
+ qreal offset = 0.0; // this offset allows us to compensate for flooring reserved space
+ Align align = QQuickStyledTextImgTag::Bottom;
+ QQuickPixmap *pix = nullptr;
};
class Q_AUTOTEST_EXPORT QQuickStyledText
diff --git a/src/quick/util/qquicksvgparser.cpp b/src/quick/util/qquicksvgparser.cpp
index 310b600965..0687913565 100644
--- a/src/quick/util/qquicksvgparser.cpp
+++ b/src/quick/util/qquicksvgparser.cpp
@@ -45,8 +45,6 @@
QT_BEGIN_NAMESPACE
-static const double Q_PI = 3.14159265358979323846; // pi
-
//copied from Qt SVG (qsvghandler.cpp).
Q_CORE_EXPORT double qstrtod(const char *s00, char const **se, bool *ok);
// '0' is 0x30 and '9' is 0x39
@@ -128,7 +126,7 @@ static qreal toDouble(const QChar *&str)
val = -val;
} else {
bool ok = false;
- val = qstrtod(temp, 0, &ok);
+ val = qstrtod(temp, nullptr, &ok);
}
return val;
@@ -253,11 +251,11 @@ void QQuickSvgParser::pathArc(QPainterPath &path,
th_arc = th1 - th0;
if (th_arc < 0 && sweep_flag)
- th_arc += 2 * Q_PI;
+ th_arc += 2 * M_PI;
else if (th_arc > 0 && !sweep_flag)
- th_arc -= 2 * Q_PI;
+ th_arc -= 2 * M_PI;
- n_segs = qCeil(qAbs(th_arc / (Q_PI * 0.5 + 0.001)));
+ n_segs = qCeil(qAbs(th_arc / (M_PI * 0.5 + 0.001)));
for (i = 0; i < n_segs; i++) {
pathArcSegment(path, xc, yc,
@@ -282,11 +280,8 @@ bool QQuickSvgParser::parsePathDataFast(const QString &dataStr, QPainterPath &pa
++str;
QChar pathElem = *str;
++str;
- QChar endc = *end;
- *const_cast<QChar *>(end) = 0; // parseNumbersArray requires 0-termination that QStringRef cannot guarantee
QVarLengthArray<qreal, 8> arg;
parseNumbersArray(str, arg);
- *const_cast<QChar *>(end) = endc;
if (pathElem == QLatin1Char('z') || pathElem == QLatin1Char('Z'))
arg.append(0);//dummy
const qreal *num = arg.constData();
diff --git a/src/quick/util/qquicksystempalette.cpp b/src/quick/util/qquicksystempalette.cpp
index c5768a5d9f..413b87aa93 100644
--- a/src/quick/util/qquicksystempalette.cpp
+++ b/src/quick/util/qquicksystempalette.cpp
@@ -58,7 +58,7 @@ public:
\instantiates QQuickSystemPalette
\inqmlmodule QtQuick
\ingroup qtquick-visual-utility
- \brief Provides access to the Qt palettes
+ \brief Provides access to the Qt palettes.
The SystemPalette type provides access to the Qt application
palettes. This provides information about the standard colors used
diff --git a/src/quick/util/qquicksystempalette_p.h b/src/quick/util/qquicksystempalette_p.h
index 086fb31993..9a3a520ed1 100644
--- a/src/quick/util/qquicksystempalette_p.h
+++ b/src/quick/util/qquicksystempalette_p.h
@@ -81,7 +81,7 @@ class Q_AUTOTEST_EXPORT QQuickSystemPalette : public QObject
Q_PROPERTY(QColor highlightedText READ highlightedText NOTIFY paletteChanged)
public:
- QQuickSystemPalette(QObject *parent=0);
+ QQuickSystemPalette(QObject *parent=nullptr);
~QQuickSystemPalette();
enum ColorGroup { Active = QPalette::Active, Inactive = QPalette::Inactive, Disabled = QPalette::Disabled };
diff --git a/src/quick/util/qquicktextmetrics.cpp b/src/quick/util/qquicktextmetrics.cpp
index 43945b0f5a..959980b267 100644
--- a/src/quick/util/qquicktextmetrics.cpp
+++ b/src/quick/util/qquicktextmetrics.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
\inqmlmodule QtQuick
\since 5.4
\ingroup qtquick-text-utility
- \brief Provides metrics for a given font and text
+ \brief Provides metrics for a given font and text.
TextMetrics calculates various properties of a given string of text for a
particular font.
@@ -186,7 +186,7 @@ void QQuickTextMetrics::setElideWidth(qreal elideWidth)
*/
qreal QQuickTextMetrics::advanceWidth() const
{
- return m_metrics.width(m_text);
+ return m_metrics.horizontalAdvance(m_text);
}
/*!
diff --git a/src/quick/util/qquicktimeline.cpp b/src/quick/util/qquicktimeline.cpp
index b3f0caa2b3..ac9f75979e 100644
--- a/src/quick/util/qquicktimeline.cpp
+++ b/src/quick/util/qquicktimeline.cpp
@@ -57,7 +57,7 @@ struct Update {
Update(QQuickTimeLineValue *_g, qreal _v)
: g(_g), v(_v) {}
Update(const QQuickTimeLineCallback &_e)
- : g(0), v(0), e(_e) {}
+ : g(nullptr), v(0), e(_e) {}
QQuickTimeLineValue *g;
qreal v;
@@ -104,11 +104,11 @@ struct QQuickTimeLinePrivate
};
struct TimeLine
{
- TimeLine() : length(0), consumedOpLength(0), base(0.) {}
+ TimeLine() {}
QList<Op> ops;
- int length;
- int consumedOpLength;
- qreal base;
+ int length = 0;
+ int consumedOpLength = 0;
+ qreal base = 0.;
};
int length;
@@ -133,7 +133,7 @@ struct QQuickTimeLinePrivate
};
QQuickTimeLinePrivate::QQuickTimeLinePrivate(QQuickTimeLine *parent)
-: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QQuickTimeLine::LocalSync), syncAdj(0), updateQueue(0)
+: length(0), syncPoint(0), q(parent), clockRunning(false), prevTime(0), order(0), syncMode(QQuickTimeLine::LocalSync), syncAdj(0), updateQueue(nullptr)
{
}
@@ -326,9 +326,9 @@ QQuickTimeLine::~QQuickTimeLine()
for (QQuickTimeLinePrivate::Ops::Iterator iter = d->ops.begin();
iter != d->ops.end();
++iter)
- iter.key()->_t = 0;
+ iter.key()->_t = nullptr;
- delete d; d = 0;
+ delete d; d = nullptr;
}
/*!
@@ -514,7 +514,7 @@ void QQuickTimeLine::reset(QQuickTimeLineValue &timeLineValue)
return;
}
remove(&timeLineValue);
- timeLineValue._t = 0;
+ timeLineValue._t = nullptr;
}
int QQuickTimeLine::duration() const
@@ -666,7 +666,7 @@ void QQuickTimeLine::complete()
void QQuickTimeLine::clear()
{
for (QQuickTimeLinePrivate::Ops::const_iterator iter = d->ops.cbegin(), cend = d->ops.cend(); iter != cend; ++iter)
- iter.key()->_t = 0;
+ iter.key()->_t = nullptr;
d->ops.clear();
d->length = 0;
d->syncPoint = 0;
@@ -800,7 +800,7 @@ int QQuickTimeLinePrivate::advance(int t)
if (tl.ops.isEmpty()) {
iter = ops.erase(iter);
- v->_t = 0;
+ v->_t = nullptr;
} else {
if (tl.ops.first().type == Op::Pause && pauseTime != 0) {
int opPauseTime = tl.ops.first().length - tl.consumedOpLength;
@@ -826,7 +826,7 @@ int QQuickTimeLinePrivate::advance(int t)
v.e.d0(v.e.d1);
}
}
- updateQueue = 0;
+ updateQueue = nullptr;
} while(t);
return pauseTime;
@@ -854,7 +854,7 @@ void QQuickTimeLine::remove(QQuickTimeLineObject *v)
if (d->ops.isEmpty()) {
stop();
d->clockRunning = false;
- } else if (/*!GfxClock::isActive()*/ state() != Running) {
+ } else if (state() != Running) { // was !GfxClock::isActive()
stop();
d->prevTime = 0;
d->clockRunning = true;
@@ -913,7 +913,7 @@ void QQuickTimeLine::remove(QQuickTimeLineObject *v)
QQuickTimeLineObject::QQuickTimeLineObject()
-: _t(0)
+: _t(nullptr)
{
}
@@ -921,12 +921,12 @@ QQuickTimeLineObject::~QQuickTimeLineObject()
{
if (_t) {
_t->remove(this);
- _t = 0;
+ _t = nullptr;
}
}
QQuickTimeLineCallback::QQuickTimeLineCallback()
-: d0(0), d1(0), d2(0)
+: d0(nullptr), d1(nullptr), d2(nullptr)
{
}
diff --git a/src/quick/util/qquicktimeline_p_p.h b/src/quick/util/qquicktimeline_p_p.h
index ae1087487b..abb5369b7b 100644
--- a/src/quick/util/qquicktimeline_p_p.h
+++ b/src/quick/util/qquicktimeline_p_p.h
@@ -65,7 +65,7 @@ class Q_AUTOTEST_EXPORT QQuickTimeLine : public QObject, QAbstractAnimationJob
{
Q_OBJECT
public:
- QQuickTimeLine(QObject *parent = 0);
+ QQuickTimeLine(QObject *parent = nullptr);
~QQuickTimeLine();
enum SyncMode { LocalSync, GlobalSync };
@@ -152,7 +152,7 @@ public:
typedef void (*Callback)(void *);
QQuickTimeLineCallback();
- QQuickTimeLineCallback(QQuickTimeLineObject *b, Callback, void * = 0);
+ QQuickTimeLineCallback(QQuickTimeLineObject *b, Callback, void * = nullptr);
QQuickTimeLineCallback(const QQuickTimeLineCallback &o);
QQuickTimeLineCallback &operator=(const QQuickTimeLineCallback &o);
@@ -170,7 +170,7 @@ class QQuickTimeLineValueProxy : public QQuickTimeLineValue
{
public:
QQuickTimeLineValueProxy(T *cls, void (T::*func)(qreal), qreal v = 0.)
- : QQuickTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(0)
+ : QQuickTimeLineValue(v), _class(cls), _setFunctionReal(func), _setFunctionInt(nullptr)
{
Q_ASSERT(_class);
}
diff --git a/src/quick/util/qquicktransition.cpp b/src/quick/util/qquicktransition.cpp
index 29690a4857..c8699426f2 100644
--- a/src/quick/util/qquicktransition.cpp
+++ b/src/quick/util/qquicktransition.cpp
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
\instantiates QQuickTransition
\inqmlmodule QtQuick
\ingroup qtquick-transitions-animations
- \brief Defines animated transitions that occur on state changes
+ \brief Defines animated transitions that occur on state changes.
A Transition defines the animations to be applied when a \l State change occurs.
@@ -109,7 +109,7 @@ protected:
void updateState(QAbstractAnimationJob::State newState, QAbstractAnimationJob::State oldState) override;
};
-class QQuickTransitionPrivate : public QObjectPrivate, QAnimationJobChangeListener
+class QQuickTransitionPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QQuickTransition)
public:
@@ -120,11 +120,8 @@ public:
{
}
- void removeStateChangeListener(QAbstractAnimationJob *anim)
- {
- if (anim)
- anim->removeAnimationChangeListener(this, QAbstractAnimationJob::StateChange);
- }
+ static QQuickTransitionPrivate *get(QQuickTransition *q) { return q->d_func(); }
+ void animationStateChanged(QAbstractAnimationJob::State newState);
QString fromState;
QString toState;
@@ -134,7 +131,6 @@ public:
bool reversible;
bool enabled;
protected:
- void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) override;
static void append_animation(QQmlListProperty<QQuickAbstractAnimation> *list, QQuickAbstractAnimation *a);
static int animation_count(QQmlListProperty<QQuickAbstractAnimation> *list);
@@ -171,7 +167,16 @@ void QQuickTransitionPrivate::clear_animations(QQmlListProperty<QQuickAbstractAn
}
}
-void QQuickTransitionPrivate::animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
+void QQuickTransitionInstance::animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State newState, QAbstractAnimationJob::State)
+{
+ if (!m_transition)
+ return;
+
+ QQuickTransitionPrivate *transition = QQuickTransitionPrivate::get(m_transition);
+ transition->animationStateChanged(newState);
+}
+
+void QQuickTransitionPrivate::animationStateChanged(QAbstractAnimationJob::State newState)
{
Q_Q(QQuickTransition);
@@ -197,15 +202,16 @@ void ParallelAnimationWrapper::updateState(QAbstractAnimationJob::State newState
}
}
-QQuickTransitionInstance::QQuickTransitionInstance(QQuickTransitionPrivate *transition, QAbstractAnimationJob *anim)
+QQuickTransitionInstance::QQuickTransitionInstance(QQuickTransition *transition, QAbstractAnimationJob *anim)
: m_transition(transition)
, m_anim(anim)
{
+ anim->addAnimationChangeListener(this, QAbstractAnimationJob::StateChange);
}
QQuickTransitionInstance::~QQuickTransitionInstance()
{
- m_transition->removeStateChangeListener(m_anim);
+ removeStateChangeListener();
delete m_anim;
}
@@ -257,7 +263,7 @@ QQuickTransitionInstance *QQuickTransition::prepare(QQuickStateOperation::Action
int start = d->reversed ? d->animations.count() - 1 : 0;
int end = d->reversed ? -1 : d->animations.count();
- QAbstractAnimationJob *anim = 0;
+ QAbstractAnimationJob *anim = nullptr;
for (int i = start; i != end;) {
anim = d->animations.at(i)->transition(actions, after, direction, defaultTarget);
if (anim) {
@@ -270,8 +276,7 @@ QQuickTransitionInstance *QQuickTransition::prepare(QQuickStateOperation::Action
group->setDirection(d->reversed ? QAbstractAnimationJob::Backward : QAbstractAnimationJob::Forward);
- group->addAnimationChangeListener(d, QAbstractAnimationJob::StateChange);
- QQuickTransitionInstance *wrapper = new QQuickTransitionInstance(d, group);
+ QQuickTransitionInstance *wrapper = new QQuickTransitionInstance(this, group);
return wrapper;
}
diff --git a/src/quick/util/qquicktransition_p.h b/src/quick/util/qquicktransition_p.h
index d6f365f99e..c7d06b8832 100644
--- a/src/quick/util/qquicktransition_p.h
+++ b/src/quick/util/qquicktransition_p.h
@@ -53,6 +53,7 @@
#include "qquickstate_p.h"
#include <private/qabstractanimationjob_p.h>
+#include <private/qqmlguard_p.h>
#include <qqml.h>
#include <QtCore/qobject.h>
@@ -64,10 +65,10 @@ class QQuickTransitionPrivate;
class QQuickTransitionManager;
class QQuickTransition;
-class QQuickTransitionInstance
+class QQuickTransitionInstance : QAnimationJobChangeListener
{
public:
- QQuickTransitionInstance(QQuickTransitionPrivate *transition, QAbstractAnimationJob *anim);
+ QQuickTransitionInstance(QQuickTransition *transition, QAbstractAnimationJob *anim);
~QQuickTransitionInstance();
void start();
@@ -75,8 +76,16 @@ public:
bool isRunning() const;
+protected:
+ void animationStateChanged(QAbstractAnimationJob *, QAbstractAnimationJob::State, QAbstractAnimationJob::State) override;
+
+ void removeStateChangeListener()
+ {
+ m_anim->removeAnimationChangeListener(this, QAbstractAnimationJob::StateChange);
+ }
+
private:
- QQuickTransitionPrivate *m_transition;
+ QQmlGuard<QQuickTransition> m_transition;
QAbstractAnimationJob *m_anim;
friend class QQuickTransition;
};
@@ -96,7 +105,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTransition : public QObject
Q_CLASSINFO("DeferredPropertyNames", "animations")
public:
- QQuickTransition(QObject *parent=0);
+ QQuickTransition(QObject *parent=nullptr);
~QQuickTransition();
QString fromState() const;
diff --git a/src/quick/util/qquicktransitionmanager.cpp b/src/quick/util/qquicktransitionmanager.cpp
index 714e6d62b6..e51de1a02a 100644
--- a/src/quick/util/qquicktransitionmanager.cpp
+++ b/src/quick/util/qquicktransitionmanager.cpp
@@ -56,7 +56,7 @@ class QQuickTransitionManagerPrivate
{
public:
QQuickTransitionManagerPrivate()
- : state(0), transitionInstance(0) {}
+ : state(nullptr), transitionInstance(nullptr) {}
void applyBindings();
typedef QList<QQuickSimpleAction> SimpleActionList;
@@ -79,7 +79,7 @@ void QQuickTransitionManager::setState(QQuickState *s)
QQuickTransitionManager::~QQuickTransitionManager()
{
delete d->transitionInstance;
- delete d; d = 0;
+ delete d; d = nullptr;
}
bool QQuickTransitionManager::isRunning() const
@@ -91,10 +91,10 @@ void QQuickTransitionManager::complete()
{
d->applyBindings();
- for (int ii = 0; ii < d->completeList.count(); ++ii) {
- const QQmlProperty &prop = d->completeList.at(ii).property();
- prop.write(d->completeList.at(ii).value());
- }
+ // Explicitly take a copy in case the write action triggers a script that modifies the list.
+ QQuickTransitionManagerPrivate::SimpleActionList completeListCopy = d->completeList;
+ for (const QQuickSimpleAction &action : qAsConst(completeListCopy))
+ action.property().write(action.value());
d->completeList.clear();
@@ -131,7 +131,9 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
{
cancel();
+ // The copy below is ON PURPOSE, because firing actions might involve scripts that modify the list.
QQuickStateOperation::ActionList applyList = list;
+
// Determine which actions are binding changes and disable any current bindings
for (const QQuickStateAction &action : qAsConst(applyList)) {
if (action.toBinding)
@@ -156,8 +158,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
if (transition && !d->bindingsList.isEmpty()) {
// Apply all the property and binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- const QQuickStateAction &action = applyList.at(ii);
+ for (const QQuickStateAction &action : qAsConst(applyList)) {
if (action.toBinding) {
QQmlPropertyPrivate::setBinding(action.toBinding.data(), QQmlPropertyPrivate::None, QQmlPropertyData::BypassInterceptor | QQmlPropertyData::DontRemoveBinding);
} else if (!action.event) {
@@ -170,17 +171,15 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
}
}
- // Read all the end values for binding changes
- for (int ii = 0; ii < applyList.size(); ++ii) {
- QQuickStateAction *action = &applyList[ii];
- if (action->event) {
- action->event->saveTargetValues();
+ // Read all the end values for binding changes.
+ for (auto it = applyList.begin(), eit = applyList.end(); it != eit; ++it) {
+ if (it->event) {
+ it->event->saveTargetValues();
continue;
}
- const QQmlProperty &prop = action->property;
- if (action->toBinding || !action->toValue.isValid()) {
- action->toValue = prop.read();
- }
+ const QQmlProperty &prop = it->property;
+ if (it->toBinding || !it->toValue.isValid())
+ it->toValue = prop.read();
}
// Revert back to the original values
@@ -210,29 +209,20 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
delete oldInstance;
// Modify the action list to remove actions handled in the transition
- for (int ii = 0; ii < applyList.count(); ++ii) {
- const QQuickStateAction &action = applyList.at(ii);
-
+ auto isHandledInTransition = [this, touched](const QQuickStateAction &action) {
if (action.event) {
-
- if (action.actionDone) {
- applyList.removeAt(ii);
- --ii;
- }
-
+ return action.actionDone;
} else {
-
if (touched.contains(action.property)) {
if (action.toValue != action.fromValue)
- d->completeList <<
- QQuickSimpleAction(action, QQuickSimpleAction::EndState);
-
- applyList.removeAt(ii);
- --ii;
+ d->completeList << QQuickSimpleAction(action, QQuickSimpleAction::EndState);
+ return true;
}
-
}
- }
+ return false;
+ };
+ auto newEnd = std::remove_if(applyList.begin(), applyList.end(), isHandledInTransition);
+ applyList.erase(newEnd, applyList.end());
}
// Any actions remaining have not been handled by the transition and should
@@ -270,12 +260,9 @@ void QQuickTransitionManager::cancel()
if (d->transitionInstance && d->transitionInstance->isRunning())
d->transitionInstance->stop();
- for(int i = 0; i < d->bindingsList.count(); ++i) {
- QQuickStateAction action = d->bindingsList[i];
+ for (const QQuickStateAction &action : qAsConst(d->bindingsList)) {
if (action.toBinding && action.deletableToBinding) {
QQmlPropertyPrivate::removeBinding(action.property);
- action.toBinding = 0;
- action.deletableToBinding = false;
} else if (action.event) {
//### what do we do here?
}
diff --git a/src/quick/util/qquicktransitionmanager_p_p.h b/src/quick/util/qquicktransitionmanager_p_p.h
index 68daf6db3c..89317e1e07 100644
--- a/src/quick/util/qquicktransitionmanager_p_p.h
+++ b/src/quick/util/qquicktransitionmanager_p_p.h
@@ -66,7 +66,7 @@ public:
bool isRunning() const;
- void transition(const QList<QQuickStateAction> &, QQuickTransition *transition, QObject *defaultTarget = 0);
+ void transition(const QList<QQuickStateAction> &, QQuickTransition *transition, QObject *defaultTarget = nullptr);
void cancel();
diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp
index b2e5b84cf4..5147ebc6f6 100644
--- a/src/quick/util/qquickutilmodule.cpp
+++ b/src/quick/util/qquickutilmodule.cpp
@@ -132,4 +132,9 @@ void QQuickUtilModule::defineModule()
qmlRegisterType<QQuickShortcut,9>("QtQuick", 2, 9, "Shortcut");
#endif
+
+ qmlRegisterUncreatableType<QQuickAbstractAnimation, 12>("QtQuick", 2, 12, "Animation",
+ QQuickAbstractAnimation::tr("Animation is an abstract class"));
+ // 5.13
+ qmlRegisterType<QQuickBehavior, 13>("QtQuick", 2, 13, "Behavior");
}
diff --git a/src/quick/util/qquickvalidator.cpp b/src/quick/util/qquickvalidator.cpp
index a05117bd06..b2b773cd94 100644
--- a/src/quick/util/qquickvalidator.cpp
+++ b/src/quick/util/qquickvalidator.cpp
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
\instantiates QIntValidator
\inqmlmodule QtQuick
\ingroup qtquick-text-utility
- \brief Defines a validator for integer values
+ \brief Defines a validator for integer values.
The IntValidator type provides a validator for integer values.
@@ -111,7 +111,7 @@ void QQuickIntValidator::resetLocaleName()
\instantiates QDoubleValidator
\inqmlmodule QtQuick
\ingroup qtquick-text-utility
- \brief Defines a validator for non-integer numbers
+ \brief Defines a validator for non-integer numbers.
The DoubleValidator type provides a validator for non-integer numbers.
@@ -205,7 +205,7 @@ void QQuickDoubleValidator::resetLocaleName()
\instantiates QRegExpValidator
\inqmlmodule QtQuick
\ingroup qtquick-text-utility
- \brief Provides a string validator
+ \brief Provides a string validator.
The RegExpValidator type provides a validator, which counts as valid any string which
matches a specified regular expression.
@@ -219,6 +219,25 @@ void QQuickDoubleValidator::resetLocaleName()
matching "a".
By default, this property contains a regular expression with the pattern .* that matches any string.
+
+ Below you can find an example of a \l TextInput object with a RegExpValidator specified:
+
+ \snippet qml/regexp.qml 0
+
+ Some more examples of regular expressions:
+
+ \list
+ \li A list of numbers with one to three positions separated by a comma:
+ \badcode
+ /\d{1,3}(?:,\d{1,3})+$/
+ \endcode
+
+ \li An amount consisting of up to 3 numbers before the decimal point, and
+ 1 to 2 after the decimal point:
+ \badcode
+ /(\d{1,3})([.,]\d{1,2})?$/
+ \endcode
+ \endlist
*/
#endif // validator
diff --git a/src/quick/util/qquickvalidator_p.h b/src/quick/util/qquickvalidator_p.h
index ba188e947a..812e552d8e 100644
--- a/src/quick/util/qquickvalidator_p.h
+++ b/src/quick/util/qquickvalidator_p.h
@@ -62,7 +62,7 @@ class Q_AUTOTEST_EXPORT QQuickIntValidator : public QIntValidator
Q_OBJECT
Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged)
public:
- QQuickIntValidator(QObject *parent = 0);
+ QQuickIntValidator(QObject *parent = nullptr);
QString localeName() const;
void setLocaleName(const QString &name);
@@ -77,7 +77,7 @@ class Q_AUTOTEST_EXPORT QQuickDoubleValidator : public QDoubleValidator
Q_OBJECT
Q_PROPERTY(QString locale READ localeName WRITE setLocaleName RESET resetLocaleName NOTIFY localeNameChanged)
public:
- QQuickDoubleValidator(QObject *parent = 0);
+ QQuickDoubleValidator(QObject *parent = nullptr);
QString localeName() const;
void setLocaleName(const QString &name);
diff --git a/src/quick/util/qquickvaluetypes.cpp b/src/quick/util/qquickvaluetypes.cpp
index 4d34c6d661..e4a03f3b52 100644
--- a/src/quick/util/qquickvaluetypes.cpp
+++ b/src/quick/util/qquickvaluetypes.cpp
@@ -757,6 +757,29 @@ void QQuickFontValueType::setHintingPreference(QQuickFontValueType::HintingPrefe
v.setHintingPreference(QFont::HintingPreference(hintingPreference));
}
+bool QQuickFontValueType::kerning() const
+{
+ return v.kerning();
+}
+
+void QQuickFontValueType::setKerning(bool b)
+{
+ v.setKerning(b);
+}
+
+bool QQuickFontValueType::preferShaping() const
+{
+ return (v.styleStrategy() & QFont::PreferNoShaping) == 0;
+}
+
+void QQuickFontValueType::setPreferShaping(bool enable)
+{
+ if (enable)
+ v.setStyleStrategy(static_cast<QFont::StyleStrategy>(v.styleStrategy() & ~QFont::PreferNoShaping));
+ else
+ v.setStyleStrategy(static_cast<QFont::StyleStrategy>(v.styleStrategy() | QFont::PreferNoShaping));
+}
+
QT_END_NAMESPACE
#include "moc_qquickvaluetypes_p.cpp"
diff --git a/src/quick/util/qquickvaluetypes_p.h b/src/quick/util/qquickvaluetypes_p.h
index 4a1598ec5c..5a9af970e8 100644
--- a/src/quick/util/qquickvaluetypes_p.h
+++ b/src/quick/util/qquickvaluetypes_p.h
@@ -323,6 +323,8 @@ class QQuickFontValueType
Q_PROPERTY(qreal letterSpacing READ letterSpacing WRITE setLetterSpacing FINAL)
Q_PROPERTY(qreal wordSpacing READ wordSpacing WRITE setWordSpacing FINAL)
Q_PROPERTY(HintingPreference hintingPreference READ hintingPreference WRITE setHintingPreference FINAL)
+ Q_PROPERTY(bool kerning READ kerning WRITE setKerning FINAL)
+ Q_PROPERTY(bool preferShaping READ preferShaping WRITE setPreferShaping FINAL)
public:
enum FontWeight { Thin = QFont::Thin,
@@ -393,6 +395,12 @@ public:
HintingPreference hintingPreference() const;
void setHintingPreference(HintingPreference);
+
+ bool kerning() const;
+ void setKerning(bool b);
+
+ bool preferShaping() const;
+ void setPreferShaping(bool b);
};
QT_END_NAMESPACE
diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri
index b53b132cce..c51f082d03 100644
--- a/src/quick/util/util.pri
+++ b/src/quick/util/util.pri
@@ -28,7 +28,7 @@ SOURCES += \
$$PWD/qquicktextmetrics.cpp \
$$PWD/qquickvalidator.cpp
-!contains(QT_CONFIG, no-qml-debug): SOURCES += $$PWD/qquickprofiler.cpp
+qtConfig(qml-debug): SOURCES += $$PWD/qquickprofiler.cpp
HEADERS += \
$$PWD/qquickapplication_p.h\
@@ -53,6 +53,7 @@ HEADERS += \
$$PWD/qquickfontloader_p.h \
$$PWD/qquickstyledtext_p.h \
$$PWD/qquickimageprovider.h \
+ $$PWD/qquickimageprovider_p.h \
$$PWD/qquicksvgparser_p.h \
$$PWD/qquickvaluetypes_p.h \
$$PWD/qquickanimator_p.h \