Pad Navigator example: Remove duplicated property animations
The example created two QPropertyAnimation instances that controlled the same property; this caused a clash for some transitions. Remove the smoothFlipXRotation and smoothFlipYRotation animations; they are not needed as equivalent animations are already set as defaults for the state machine. Fixes: QTBUG-28081 Change-Id: Ifa7a09d48cd4905df720e3327914320ed74ebae6 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
This commit is contained in:
parent
9f1948f59b
commit
e05511a364
@ -387,17 +387,12 @@
|
|||||||
\snippet graphicsview/padnavigator/padnavigator.cpp 7
|
\snippet graphicsview/padnavigator/padnavigator.cpp 7
|
||||||
|
|
||||||
We now create the animations that control the flip-effect when you press
|
We now create the animations that control the flip-effect when you press
|
||||||
the enter key. The main goal is to rotate the pad by 180 degrees or back,
|
the enter key. The main goal is to rotate the pad by 180 degrees or back.
|
||||||
but we also need to make sure the selection item's tilt rotations are reset
|
|
||||||
back to 0 when the pad is flipped, and restored back to their original
|
|
||||||
values when flipped back:
|
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li \c smoothFlipRotation: Animates the main 180 degree rotation of the pad.
|
\li \c smoothFlipRotation: Animates the main 180 degree rotation of the pad.
|
||||||
\li \c smoothFlipScale: Scales the pad out and then in again while the pad is rotating.
|
\li \c smoothFlipScale: Scales the pad out and then in again while the pad is rotating.
|
||||||
\li \c smoothFlipXRotation: Animates the selection item's X-tilt to 0 and back.
|
\li \c flipAnimation: A parallel animation group that ensures the above animations are run in parallel.
|
||||||
\li \c smoothFlipYRotation: Animates the selection item's Y-tilt to 0 and back.
|
|
||||||
\li \c flipAnimation: A parallel animation group that ensures all the above animations are run in parallel.
|
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
All animations are given a 500 millisecond duration and an
|
All animations are given a 500 millisecond duration and an
|
||||||
@ -447,11 +442,17 @@
|
|||||||
Each state assigns specific properties to objects on entry. Most
|
Each state assigns specific properties to objects on entry. Most
|
||||||
interesting perhaps is the assignment of the value 0.0 to the pad's \c
|
interesting perhaps is the assignment of the value 0.0 to the pad's \c
|
||||||
flipRotation angle property when in \c frontState, and 180.0 when in \c
|
flipRotation angle property when in \c frontState, and 180.0 when in \c
|
||||||
backState. At the end of this section we register default animations with
|
backState.
|
||||||
the state engine; these animations will apply to their respective objects
|
|
||||||
and properties for any state transition. Otherwise it's common to assign
|
At the end of this section we register default animations with the state
|
||||||
|
engine; these animations will apply to their respective objects and
|
||||||
|
properties for any state transition. Otherwise it's common to assign
|
||||||
animations to specific transitions.
|
animations to specific transitions.
|
||||||
|
|
||||||
|
Specifically, we use default animations to control the selection item's
|
||||||
|
movement and tilt rotations. The tilt rotations are set to 0 when the pad
|
||||||
|
is flipped, and restored back to their original values when flipped back.
|
||||||
|
|
||||||
The \c splashState state is set as the initial state. This is required
|
The \c splashState state is set as the initial state. This is required
|
||||||
before we start the state engine. We proceed with creating some
|
before we start the state engine. We proceed with creating some
|
||||||
transitions.
|
transitions.
|
||||||
|
@ -142,24 +142,16 @@ PadNavigator::PadNavigator(const QSize &size, QWidget *parent)
|
|||||||
// Flip animation setup
|
// Flip animation setup
|
||||||
QPropertyAnimation *smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle");
|
QPropertyAnimation *smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle");
|
||||||
QPropertyAnimation *smoothFlipScale = new QPropertyAnimation(pad, "scale");
|
QPropertyAnimation *smoothFlipScale = new QPropertyAnimation(pad, "scale");
|
||||||
QPropertyAnimation *smoothFlipXRotation = new QPropertyAnimation(xRotation, "angle");
|
|
||||||
QPropertyAnimation *smoothFlipYRotation = new QPropertyAnimation(yRotation, "angle");
|
|
||||||
QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this);
|
QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this);
|
||||||
smoothFlipScale->setDuration(500);
|
smoothFlipScale->setDuration(500);
|
||||||
smoothFlipRotation->setDuration(500);
|
smoothFlipRotation->setDuration(500);
|
||||||
smoothFlipXRotation->setDuration(500);
|
|
||||||
smoothFlipYRotation->setDuration(500);
|
|
||||||
smoothFlipScale->setEasingCurve(QEasingCurve::InOutQuad);
|
smoothFlipScale->setEasingCurve(QEasingCurve::InOutQuad);
|
||||||
smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad);
|
smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad);
|
||||||
smoothFlipXRotation->setEasingCurve(QEasingCurve::InOutQuad);
|
|
||||||
smoothFlipYRotation->setEasingCurve(QEasingCurve::InOutQuad);
|
|
||||||
smoothFlipScale->setKeyValueAt(0, qvariant_cast<qreal>(1.0));
|
smoothFlipScale->setKeyValueAt(0, qvariant_cast<qreal>(1.0));
|
||||||
smoothFlipScale->setKeyValueAt(0.5, qvariant_cast<qreal>(0.7));
|
smoothFlipScale->setKeyValueAt(0.5, qvariant_cast<qreal>(0.7));
|
||||||
smoothFlipScale->setKeyValueAt(1, qvariant_cast<qreal>(1.0));
|
smoothFlipScale->setKeyValueAt(1, qvariant_cast<qreal>(1.0));
|
||||||
flipAnimation->addAnimation(smoothFlipRotation);
|
flipAnimation->addAnimation(smoothFlipRotation);
|
||||||
flipAnimation->addAnimation(smoothFlipScale);
|
flipAnimation->addAnimation(smoothFlipScale);
|
||||||
flipAnimation->addAnimation(smoothFlipXRotation);
|
|
||||||
flipAnimation->addAnimation(smoothFlipYRotation);
|
|
||||||
//! [7]
|
//! [7]
|
||||||
|
|
||||||
//! [8]
|
//! [8]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user