diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-03-07 14:57:29 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-03-09 09:11:31 +0000 |
commit | 31e64606f253663f8ee2032b94521afd1804ab11 (patch) | |
tree | 92484cb64b16db769cf0cd37470245e670fd22ae /src/quick/util/qquickanimation.cpp | |
parent | 5446be855becab2499611f2bc2280b74160f2e75 (diff) |
Animation: add finished() signal
Currently, Animation has a stopped() signal. This is executed even if
the animation is stopped manually. To react to an animation finishing
naturally, you currently have to do the following:
onRunningChanged: if (!running) doStuff()
This patch adds a dedicated signal:
onFinished: doStuff()
[ChangeLog][QtQuick][Animation] Added finished() signal to
Animation as a convenient way to react to an animation finishing
naturally.
Change-Id: I8765d3e8e2b7bf7ef66a6acb69feafb43e9619d3
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/util/qquickanimation.cpp')
-rw-r--r-- | src/quick/util/qquickanimation.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp index a89f237499..9bbf70b3a4 100644 --- a/src/quick/util/qquickanimation.cpp +++ b/src/quick/util/qquickanimation.cpp @@ -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); @@ -656,6 +677,7 @@ void QQuickAbstractAnimationPrivate::animationFinished(QAbstractAnimationJob*) if (loopCount != 1) animationInstance->setLoopCount(loopCount); } + emit q->finished(); } QQuickAbstractAnimation::ThreadingModel QQuickAbstractAnimation::threadingModel() const |