summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation
diff options
context:
space:
mode:
authorAndreas Buhr <andreas.buhr@qt.io>2020-12-17 10:04:17 +0100
committerAndreas Buhr <andreas.buhr@qt.io>2021-04-19 15:18:46 +0200
commit7b6cef0e654eef0d932d1f8afe986eaa9b2299d4 (patch)
treef566ef4c5e337e8b0307b80f8b4b49097d8a08f1 /src/corelib/animation
parent97a8727f0ed87d1f9cb79d702f7d1da3951c2e2a (diff)
Port QSequentialAnimationGroup to new property system
There is only one property in QSequentialAnimationGroup, currentAnimation. This patch ports this property to the new property system Task-number: QTBUG-85520 Change-Id: Id528d30f551e88a6165bbb6a3c09d44e89257de5 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/animation')
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp9
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.h6
-rw-r--r--src/corelib/animation/qsequentialanimationgroup_p.h11
3 files changed, 18 insertions, 8 deletions
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 1d0b799fef..7ce8658628 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -301,6 +301,11 @@ QAbstractAnimation *QSequentialAnimationGroup::currentAnimation() const
return d->currentAnimation;
}
+QBindable<QAbstractAnimation *> QSequentialAnimationGroup::bindableCurrentAnimation() const
+{
+ return &d_func()->currentAnimation;
+}
+
/*!
\reimp
*/
@@ -424,6 +429,8 @@ bool QSequentialAnimationGroup::event(QEvent *event)
void QSequentialAnimationGroupPrivate::setCurrentAnimation(int index, bool intermediate)
{
Q_Q(QSequentialAnimationGroup);
+ // currentAnimation.removeBindingUnlessInWrapper()
+ // is not necessary here, since it is read only
index = qMin(index, animations.count() - 1);
@@ -443,8 +450,8 @@ void QSequentialAnimationGroupPrivate::setCurrentAnimation(int index, bool inter
if (currentAnimation)
currentAnimation->stop();
- currentAnimation = animations.at(index);
currentAnimationIndex = index;
+ currentAnimation = animations.at(index);
emit q->currentAnimationChanged(currentAnimation);
diff --git a/src/corelib/animation/qsequentialanimationgroup.h b/src/corelib/animation/qsequentialanimationgroup.h
index a33ff07abf..34be474fe2 100644
--- a/src/corelib/animation/qsequentialanimationgroup.h
+++ b/src/corelib/animation/qsequentialanimationgroup.h
@@ -52,7 +52,8 @@ class QSequentialAnimationGroupPrivate;
class Q_CORE_EXPORT QSequentialAnimationGroup : public QAnimationGroup
{
Q_OBJECT
- Q_PROPERTY(QAbstractAnimation* currentAnimation READ currentAnimation NOTIFY currentAnimationChanged)
+ Q_PROPERTY(QAbstractAnimation *currentAnimation READ currentAnimation NOTIFY
+ currentAnimationChanged BINDABLE bindableCurrentAnimation)
public:
QSequentialAnimationGroup(QObject *parent = nullptr);
@@ -62,10 +63,11 @@ public:
QPauseAnimation *insertPause(int index, int msecs);
QAbstractAnimation *currentAnimation() const;
+ QBindable<QAbstractAnimation *> bindableCurrentAnimation() const;
int duration() const override;
Q_SIGNALS:
- void currentAnimationChanged(QAbstractAnimation *current);
+ void currentAnimationChanged(QAbstractAnimation *current) const;
protected:
QSequentialAnimationGroup(QSequentialAnimationGroupPrivate &dd, QObject *parent);
diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h
index b788771fe5..369856cb55 100644
--- a/src/corelib/animation/qsequentialanimationgroup_p.h
+++ b/src/corelib/animation/qsequentialanimationgroup_p.h
@@ -53,6 +53,7 @@
#include "qsequentialanimationgroup.h"
#include "private/qanimationgroup_p.h"
+#include "private/qproperty_p.h"
QT_REQUIRE_CONFIG(animation);
@@ -62,10 +63,7 @@ class QSequentialAnimationGroupPrivate : public QAnimationGroupPrivate
{
Q_DECLARE_PUBLIC(QSequentialAnimationGroup)
public:
- QSequentialAnimationGroupPrivate()
- : currentAnimation(nullptr), currentAnimationIndex(-1), lastLoop(0)
- { }
-
+ QSequentialAnimationGroupPrivate() : currentAnimationIndex(-1), lastLoop(0) { }
struct AnimationIndex
{
@@ -87,7 +85,10 @@ public:
bool atEnd() const;
- QAbstractAnimation *currentAnimation;
+ Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QSequentialAnimationGroupPrivate, QAbstractAnimation *,
+ currentAnimation,
+ nullptr // initial value
+ )
int currentAnimationIndex;
// this is the actual duration of uncontrolled animations