diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-02-26 10:49:49 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-02-26 14:45:24 +0000 |
commit | 41edb3bd9f373a865d5698ac8c18bf341071eae9 (patch) | |
tree | 0c7ed57d082e002e0bb07dc9d24995e649761a12 /src/quick/items/qquickanimatedsprite.cpp | |
parent | bcbdd0d22bb0d6f07d5184fd16de1a9c3a439378 (diff) |
Add finished() signal to AnimatedSprite
It's nicer to respond to a sprite finishing its animation like this:
onFinished: doStuff()
than this:
onRunningChanged: if (!running) doStuff()
In addition, the latter will get executed even if the animation
is manually stopped, whereas finished() is only emitted when the
animation finishes naturally.
[ChangeLog][QtQuick][AnimatedSprite] Added finished() signal to
AnimatedSprite as a convenient way to react to an animation finishing.
Change-Id: I558e8372b54bacacd5695cb0edf97d8b84b373f9
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickanimatedsprite.cpp')
-rw-r--r-- | src/quick/items/qquickanimatedsprite.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp index 4e71b0c65f..58eb81fbbd 100644 --- a/src/quick/items/qquickanimatedsprite.cpp +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -210,6 +210,16 @@ QT_BEGIN_NAMESPACE Stops, then starts the sprite animation. */ +/*! + \qmlsignal QtQuick::AnimatedSprite::finished() + \since 5.12 + + This signal is emitted when the sprite has finished animating. + + It is not emitted when running is set to \c false, nor for sprites whose + \l loops property is set to \c AnimatedSprite.Infinite. +*/ + //TODO: Implicitly size element to size of sprite QQuickAnimatedSprite::QQuickAnimatedSprite(QQuickItem *parent) : QQuickItem(*(new QQuickAnimatedSpritePrivate), parent) @@ -734,6 +744,7 @@ void QQuickAnimatedSprite::prepareNextFrame(QSGSpriteNode *node) frameAt = 0; d->m_running = false; emit runningChanged(false); + emit finished(); maybeUpdate(); } } else { |