diff options
Diffstat (limited to 'src/corelib/animation')
20 files changed, 44 insertions, 136 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 48983def79..0be37b7dca 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -152,8 +152,7 @@ #include <QtCore/qthreadstorage.h> #include <QtCore/qcoreevent.h> #include <QtCore/qpointer.h> - -#ifndef QT_NO_ANIMATION +#include <QtCore/qscopedvaluerollback.h> #define DEFAULT_TIMER_INTERVAL 16 #define PAUSE_TIMER_COARSE_THRESHOLD 2000 @@ -317,14 +316,13 @@ void QUnifiedTimer::updateAnimationTimers(qint64 currentTick) //* it might happen in some cases that the delta is negative because the animation driver // advances faster than time.elapsed() if (delta > 0) { - insideTick = true; + QScopedValueRollback<bool> guard(insideTick, true); if (profilerCallback) profilerCallback(delta); for (currentAnimationIdx = 0; currentAnimationIdx < animationTimers.count(); ++currentAnimationIdx) { QAbstractAnimationTimer *animation = animationTimers.at(currentAnimationIdx); animation->updateAnimationsTime(delta); } - insideTick = false; currentAnimationIdx = 0; } } @@ -363,10 +361,11 @@ void QUnifiedTimer::localRestart() void QUnifiedTimer::restart() { - insideRestart = true; - for (int i = 0; i < animationTimers.count(); ++i) - animationTimers.at(i)->restartAnimationTimer(); - insideRestart = false; + { + QScopedValueRollback<bool> guard(insideRestart, true); + for (int i = 0; i < animationTimers.count(); ++i) + animationTimers.at(i)->restartAnimationTimer(); + } localRestart(); } @@ -601,14 +600,13 @@ void QAnimationTimer::updateAnimationsTime(qint64 delta) //it might happen in some cases that the time doesn't change because events are delayed //when the CPU load is high if (delta) { - insideTick = true; + QScopedValueRollback<bool> guard(insideTick, true); for (currentAnimationIdx = 0; currentAnimationIdx < animations.count(); ++currentAnimationIdx) { QAbstractAnimation *animation = animations.at(currentAnimationIdx); int elapsed = QAbstractAnimationPrivate::get(animation)->totalCurrentTime + (animation->direction() == QAbstractAnimation::Forward ? delta : -delta); animation->setCurrentTime(elapsed); } - insideTick = false; currentAnimationIdx = 0; } } @@ -775,6 +773,7 @@ QAnimationDriver::~QAnimationDriver() } +#if QT_DEPRECATED_SINCE(5, 13) /*! Sets the time at which an animation driver should start at. @@ -801,6 +800,7 @@ qint64 QAnimationDriver::startTime() const { return 0; } +#endif /*! @@ -1085,7 +1085,7 @@ QAbstractAnimation::State QAbstractAnimation::state() const /*! If this animation is part of a QAnimationGroup, this function returns a - pointer to the group; otherwise, it returns 0. + pointer to the group; otherwise, it returns \nullptr. \sa QAnimationGroup::addAnimation() */ @@ -1477,5 +1477,3 @@ QT_END_NAMESPACE #include "moc_qabstractanimation.cpp" #include "moc_qabstractanimation_p.cpp" - -#endif //QT_NO_ANIMATION diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h index 0ff6bc5176..7f2577d7f7 100644 --- a/src/corelib/animation/qabstractanimation.h +++ b/src/corelib/animation/qabstractanimation.h @@ -42,10 +42,9 @@ #include <QtCore/qobject.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(animation); -#ifndef QT_NO_ANIMATION +QT_BEGIN_NAMESPACE class QAnimationGroup; class QSequentialAnimationGroup; @@ -148,9 +147,10 @@ public: virtual qint64 elapsed() const; - // ### Qt6: Remove these two functions - void setStartTime(qint64 startTime); - qint64 startTime() const; +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED void setStartTime(qint64 startTime); + QT_DEPRECATED qint64 startTime() const; +#endif Q_SIGNALS: void started(); @@ -169,11 +169,6 @@ private: }; - - - -#endif //QT_NO_ANIMATION - QT_END_NAMESPACE #endif // QABSTRACTANIMATION_H diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h index 5593046e48..037d3be74f 100644 --- a/src/corelib/animation/qabstractanimation_p.h +++ b/src/corelib/animation/qabstractanimation_p.h @@ -58,7 +58,7 @@ #include <private/qobject_p.h> #include <qabstractanimation.h> -#ifndef QT_NO_ANIMATION +QT_REQUIRE_CONFIG(animation); QT_BEGIN_NAMESPACE @@ -78,7 +78,7 @@ public: hasRegisteredTimer(false), isPause(false), isGroup(false), - group(0) + group(nullptr) { } @@ -296,6 +296,4 @@ private: QT_END_NAMESPACE -#endif //QT_NO_ANIMATION - #endif //QABSTRACTANIMATION_P_H diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp index 486dc149ea..f47d99eb68 100644 --- a/src/corelib/animation/qanimationgroup.cpp +++ b/src/corelib/animation/qanimationgroup.cpp @@ -86,8 +86,6 @@ #include <QtCore/qcoreevent.h> #include "qanimationgroup_p.h" -#ifndef QT_NO_ANIMATION - #include <algorithm> QT_BEGIN_NAMESPACE @@ -300,5 +298,3 @@ void QAnimationGroupPrivate::animationRemoved(int index, QAbstractAnimation *) QT_END_NAMESPACE #include "moc_qanimationgroup.cpp" - -#endif //QT_NO_ANIMATION diff --git a/src/corelib/animation/qanimationgroup.h b/src/corelib/animation/qanimationgroup.h index 136ad3ca9f..7c7666f251 100644 --- a/src/corelib/animation/qanimationgroup.h +++ b/src/corelib/animation/qanimationgroup.h @@ -42,10 +42,9 @@ #include <QtCore/qabstractanimation.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(animation); -#ifndef QT_NO_ANIMATION +QT_BEGIN_NAMESPACE class QAnimationGroupPrivate; class Q_CORE_EXPORT QAnimationGroup : public QAbstractAnimation @@ -74,8 +73,6 @@ private: Q_DECLARE_PRIVATE(QAnimationGroup) }; -#endif //QT_NO_ANIMATION - QT_END_NAMESPACE #endif //QANIMATIONGROUP_H diff --git a/src/corelib/animation/qanimationgroup_p.h b/src/corelib/animation/qanimationgroup_p.h index 31c2cd08e8..215734b656 100644 --- a/src/corelib/animation/qanimationgroup_p.h +++ b/src/corelib/animation/qanimationgroup_p.h @@ -57,7 +57,7 @@ #include "private/qabstractanimation_p.h" -#ifndef QT_NO_ANIMATION +QT_REQUIRE_CONFIG(animation); QT_BEGIN_NAMESPACE @@ -76,7 +76,7 @@ public: void disconnectUncontrolledAnimation(QAbstractAnimation *anim) { //0 for the signal here because we might be called from the animation destructor - QObject::disconnect(anim, 0, q_func(), SLOT(_q_uncontrolledAnimationFinished())); + QObject::disconnect(anim, nullptr, q_func(), SLOT(_q_uncontrolledAnimationFinished())); } void connectUncontrolledAnimation(QAbstractAnimation *anim) @@ -89,6 +89,4 @@ public: QT_END_NAMESPACE -#endif //QT_NO_ANIMATION - #endif //QANIMATIONGROUP_P_H diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp index e4dfc1bd6e..492fb82e2b 100644 --- a/src/corelib/animation/qparallelanimationgroup.cpp +++ b/src/corelib/animation/qparallelanimationgroup.cpp @@ -53,13 +53,7 @@ You can treat QParallelAnimationGroup as any other QAbstractAnimation, e.g., pause, resume, or add it to other animation groups. - \code - QParallelAnimationGroup *group = new QParallelAnimationGroup; - group->addAnimation(anim1); - group->addAnimation(anim2); - - group->start(); - \endcode + \snippet code/src_corelib_animation_qparallelanimationgroup.cpp 0 In this example, \c anim1 and \c anim2 are two \l{QPropertyAnimation}s that have already been set up. @@ -72,8 +66,6 @@ #include "qparallelanimationgroup_p.h" //#define QANIMATION_DEBUG -#ifndef QT_NO_ANIMATION - QT_BEGIN_NAMESPACE typedef QList<QAbstractAnimation *>::ConstIterator AnimationListConstIt; @@ -339,5 +331,3 @@ bool QParallelAnimationGroup::event(QEvent *event) QT_END_NAMESPACE #include "moc_qparallelanimationgroup.cpp" - -#endif //QT_NO_ANIMATION diff --git a/src/corelib/animation/qparallelanimationgroup.h b/src/corelib/animation/qparallelanimationgroup.h index 09a439ef24..683d933861 100644 --- a/src/corelib/animation/qparallelanimationgroup.h +++ b/src/corelib/animation/qparallelanimationgroup.h @@ -42,10 +42,9 @@ #include <QtCore/qanimationgroup.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(animation); -#ifndef QT_NO_ANIMATION +QT_BEGIN_NAMESPACE class QParallelAnimationGroupPrivate; class Q_CORE_EXPORT QParallelAnimationGroup : public QAnimationGroup @@ -72,8 +71,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_uncontrolledAnimationFinished()) }; -#endif //QT_NO_ANIMATION - QT_END_NAMESPACE #endif // QPARALLELANIMATIONGROUP diff --git a/src/corelib/animation/qparallelanimationgroup_p.h b/src/corelib/animation/qparallelanimationgroup_p.h index 1c9c3072f7..fc8f809d5a 100644 --- a/src/corelib/animation/qparallelanimationgroup_p.h +++ b/src/corelib/animation/qparallelanimationgroup_p.h @@ -55,7 +55,7 @@ #include "private/qanimationgroup_p.h" #include <QtCore/qhash.h> -#ifndef QT_NO_ANIMATION +QT_REQUIRE_CONFIG(animation); QT_BEGIN_NAMESPACE @@ -86,6 +86,4 @@ public: QT_END_NAMESPACE -#endif //QT_NO_ANIMATION - #endif //QPARALLELANIMATIONGROUP_P_H diff --git a/src/corelib/animation/qpauseanimation.cpp b/src/corelib/animation/qpauseanimation.cpp index 654ba701da..5f8a8b3590 100644 --- a/src/corelib/animation/qpauseanimation.cpp +++ b/src/corelib/animation/qpauseanimation.cpp @@ -64,9 +64,6 @@ #include "qpauseanimation.h" #include "qabstractanimation_p.h" - -#ifndef QT_NO_ANIMATION - QT_BEGIN_NAMESPACE class QPauseAnimationPrivate : public QAbstractAnimationPrivate @@ -150,5 +147,3 @@ void QPauseAnimation::updateCurrentTime(int) QT_END_NAMESPACE #include "moc_qpauseanimation.cpp" - -#endif //QT_NO_ANIMATION diff --git a/src/corelib/animation/qpauseanimation.h b/src/corelib/animation/qpauseanimation.h index e2095a39d6..6bdbeefdbd 100644 --- a/src/corelib/animation/qpauseanimation.h +++ b/src/corelib/animation/qpauseanimation.h @@ -42,10 +42,9 @@ #include <QtCore/qanimationgroup.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(animation); -#ifndef QT_NO_ANIMATION +QT_BEGIN_NAMESPACE class QPauseAnimationPrivate; @@ -70,8 +69,6 @@ private: Q_DECLARE_PRIVATE(QPauseAnimation) }; -#endif //QT_NO_ANIMATION - QT_END_NAMESPACE #endif // QPAUSEANIMATION_H diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 927f4f4810..271be248ec 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -56,14 +56,7 @@ makes it possible to animate many of Qt's widgets. Let's look at an example: - \code - QPropertyAnimation *animation = new QPropertyAnimation(myWidget, "geometry"); - animation->setDuration(10000); - animation->setStartValue(QRect(0, 0, 100, 30)); - animation->setEndValue(QRect(250, 250, 100, 30)); - - animation->start(); - \endcode + \snippet code/src_corelib_animation_qpropertyanimation.cpp 0 The property name and the QObject instance of which property should be animated are passed to the constructor. You can then @@ -93,8 +86,6 @@ #include <QtCore/QMutex> -#ifndef QT_NO_ANIMATION - QT_BEGIN_NAMESPACE void QPropertyAnimationPrivate::updateMetaProperty() @@ -315,5 +306,3 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State newState, QT_END_NAMESPACE #include "moc_qpropertyanimation.cpp" - -#endif //QT_NO_ANIMATION diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h index 3270591d1d..a1caafcad5 100644 --- a/src/corelib/animation/qpropertyanimation.h +++ b/src/corelib/animation/qpropertyanimation.h @@ -42,10 +42,9 @@ #include <QtCore/qvariantanimation.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(animation); -#ifndef QT_NO_ANIMATION +QT_BEGIN_NAMESPACE class QPropertyAnimationPrivate; class Q_CORE_EXPORT QPropertyAnimation : public QVariantAnimation @@ -75,8 +74,6 @@ private: Q_DECLARE_PRIVATE(QPropertyAnimation) }; -#endif //QT_NO_ANIMATION - QT_END_NAMESPACE #endif // QPROPERTYANIMATION_H diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h index cfb1f247e0..cbd3ce287d 100644 --- a/src/corelib/animation/qpropertyanimation_p.h +++ b/src/corelib/animation/qpropertyanimation_p.h @@ -55,7 +55,7 @@ #include "private/qvariantanimation_p.h" -#ifndef QT_NO_ANIMATION +QT_REQUIRE_CONFIG(animation); QT_BEGIN_NAMESPACE @@ -64,7 +64,7 @@ class QPropertyAnimationPrivate : public QVariantAnimationPrivate Q_DECLARE_PUBLIC(QPropertyAnimation) public: QPropertyAnimationPrivate() - : targetValue(0), propertyType(0), propertyIndex(-1) + : targetValue(nullptr), propertyType(0), propertyIndex(-1) { } @@ -83,6 +83,4 @@ public: QT_END_NAMESPACE -#endif //QT_NO_ANIMATION - #endif //QPROPERTYANIMATION_P_H diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp index f5f538337e..150e74d7d6 100644 --- a/src/corelib/animation/qsequentialanimationgroup.cpp +++ b/src/corelib/animation/qsequentialanimationgroup.cpp @@ -61,14 +61,7 @@ groups. You can also call addPause() or insertPause() to add a pause to a sequential animation group. - \code - QSequentialAnimationGroup *group = new QSequentialAnimationGroup; - - group->addAnimation(anim1); - group->addAnimation(anim2); - - group->start(); - \endcode + \snippet code/src_corelib_animation_qsequentialanimationgroup.cpp 0 In this example, \c anim1 and \c anim2 are two already set up \l{QPropertyAnimation}s. @@ -83,8 +76,6 @@ #include <QtCore/qdebug.h> -#ifndef QT_NO_ANIMATION - QT_BEGIN_NAMESPACE typedef QList<QAbstractAnimation *>::ConstIterator AnimationListConstIt; @@ -582,5 +573,3 @@ void QSequentialAnimationGroupPrivate::animationRemoved(int index, QAbstractAnim QT_END_NAMESPACE #include "moc_qsequentialanimationgroup.cpp" - -#endif //QT_NO_ANIMATION diff --git a/src/corelib/animation/qsequentialanimationgroup.h b/src/corelib/animation/qsequentialanimationgroup.h index 1c8e67d256..a33ff07abf 100644 --- a/src/corelib/animation/qsequentialanimationgroup.h +++ b/src/corelib/animation/qsequentialanimationgroup.h @@ -42,10 +42,9 @@ #include <QtCore/qanimationgroup.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(animation); -#ifndef QT_NO_ANIMATION +QT_BEGIN_NAMESPACE class QPauseAnimation; class QSequentialAnimationGroupPrivate; @@ -82,8 +81,6 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_uncontrolledAnimationFinished()) }; -#endif //QT_NO_ANIMATION - QT_END_NAMESPACE #endif //QSEQUENTIALANIMATIONGROUP_H diff --git a/src/corelib/animation/qsequentialanimationgroup_p.h b/src/corelib/animation/qsequentialanimationgroup_p.h index e4f3d9c96a..c082d6b524 100644 --- a/src/corelib/animation/qsequentialanimationgroup_p.h +++ b/src/corelib/animation/qsequentialanimationgroup_p.h @@ -54,7 +54,7 @@ #include "qsequentialanimationgroup.h" #include "private/qanimationgroup_p.h" -#ifndef QT_NO_ANIMATION +QT_REQUIRE_CONFIG(animation); QT_BEGIN_NAMESPACE @@ -63,7 +63,7 @@ class QSequentialAnimationGroupPrivate : public QAnimationGroupPrivate Q_DECLARE_PUBLIC(QSequentialAnimationGroup) public: QSequentialAnimationGroupPrivate() - : currentAnimation(0), currentAnimationIndex(-1), lastLoop(0) + : currentAnimation(nullptr), currentAnimationIndex(-1), lastLoop(0) { } @@ -107,6 +107,4 @@ public: QT_END_NAMESPACE -#endif //QT_NO_ANIMATION - #endif //QSEQUENTIALANIMATIONGROUP_P_H diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 3c90d71c7d..e935ac711e 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -46,8 +46,6 @@ #include <algorithm> -#ifndef QT_NO_ANIMATION - QT_BEGIN_NAMESPACE /*! @@ -118,15 +116,7 @@ QT_BEGIN_NAMESPACE and the current progress. Example: - \code - QVariant myColorInterpolator(const QColor &start, const QColor &end, qreal progress) - { - ... - return QColor(...); - } - ... - qRegisterAnimationInterpolator<QColor>(myColorInterpolator); - \endcode + \snippet code/src_corelib_animation_qvariantanimation.cpp 0 Another option is to reimplement interpolated(), which returns interpolation values for the value being interpolated. @@ -418,9 +408,7 @@ static QBasicMutex registeredInterpolatorsMutex; This is a typedef for a pointer to a function with the following signature: - \code - QVariant myInterpolator(const QVariant &from, const QVariant &to, qreal progress); - \endcode + \snippet code/src_corelib_animation_qvariantanimation.cpp 1 */ @@ -700,5 +688,3 @@ void QVariantAnimation::updateCurrentTime(int) QT_END_NAMESPACE #include "moc_qvariantanimation.cpp" - -#endif //QT_NO_ANIMATION diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h index d6346e1706..e47fa14b1c 100644 --- a/src/corelib/animation/qvariantanimation.h +++ b/src/corelib/animation/qvariantanimation.h @@ -46,10 +46,9 @@ #include <QtCore/qvariant.h> #include <QtCore/qpair.h> -QT_BEGIN_NAMESPACE - +QT_REQUIRE_CONFIG(animation); -#ifndef QT_NO_ANIMATION +QT_BEGIN_NAMESPACE class QVariantAnimationPrivate; class Q_CORE_EXPORT QVariantAnimation : public QAbstractAnimation @@ -116,8 +115,6 @@ void qRegisterAnimationInterpolator(QVariant (*func)(const T &from, const T &to, QVariantAnimation::registerInterpolator(reinterpret_cast<QVariantAnimation::Interpolator>(reinterpret_cast<void(*)()>(func)), qMetaTypeId<T>()); } -#endif //QT_NO_ANIMATION - QT_END_NAMESPACE #endif //QVARIANTANIMATION_H diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h index 9f0f2e3030..57b59cf876 100644 --- a/src/corelib/animation/qvariantanimation_p.h +++ b/src/corelib/animation/qvariantanimation_p.h @@ -60,7 +60,7 @@ #include <type_traits> -#ifndef QT_NO_ANIMATION +QT_REQUIRE_CONFIG(animation); QT_BEGIN_NAMESPACE @@ -129,6 +129,4 @@ template<typename T > inline QVariant _q_interpolateVariant(const T &from, const QT_END_NAMESPACE -#endif //QT_NO_ANIMATION - #endif //QVARIANTANIMATION_P_H |