summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qwidgetanimator.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-09-26 15:39:35 +0200
committerLiang Qi <liang.qi@qt.io>2018-10-12 14:26:15 +0000
commitc593492d1678a2ec08f1bfffcb572459b3bc6c00 (patch)
treea9427b13e0f3aa252d68decc862de5acb4dc3b17 /src/widgets/widgets/qwidgetanimator.cpp
parent0509383cf2852f2aebd1efd75413835747c8f341 (diff)
Modernize the "animation" feature
Change-Id: Ibc164b3df3cf87db569ef4813de458a9067b7f7d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qwidgetanimator.cpp')
-rw-r--r--src/widgets/widgets/qwidgetanimator.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp
index b6828a14ef..b1e527e3b6 100644
--- a/src/widgets/widgets/qwidgetanimator.cpp
+++ b/src/widgets/widgets/qwidgetanimator.cpp
@@ -37,15 +37,17 @@
**
****************************************************************************/
+#include "qwidgetanimator_p.h"
+
+#if QT_CONFIG(animation)
#include <QtCore/qpropertyanimation.h>
+#endif
#include <QtWidgets/qwidget.h>
#include <QtWidgets/qstyle.h>
#if QT_CONFIG(mainwindow)
#include <private/qmainwindowlayout_p.h>
#endif
-#include "qwidgetanimator_p.h"
-
QT_BEGIN_NAMESPACE
QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout(layout)
@@ -54,7 +56,7 @@ QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout
void QWidgetAnimator::abort(QWidget *w)
{
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
const auto it = m_animation_map.constFind(w);
if (it == m_animation_map.cend())
return;
@@ -68,16 +70,16 @@ void QWidgetAnimator::abort(QWidget *w)
#endif
#else
Q_UNUSED(w); //there is no animation to abort
-#endif //QT_NO_ANIMATION
+#endif // animation
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
void QWidgetAnimator::animationFinished()
{
QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender());
abort(static_cast<QWidget*>(anim->targetObject()));
}
-#endif //QT_NO_ANIMATION
+#endif // animation
void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate)
{
@@ -91,7 +93,7 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo
const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry :
QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size());
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
//If the QStyle has animations, animate
if (const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, widget)) {
AnimationMap::const_iterator it = m_animation_map.constFind(widget);
@@ -106,7 +108,7 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo
connect(anim, SIGNAL(finished()), SLOT(animationFinished()));
anim->start(QPropertyAnimation::DeleteWhenStopped);
} else
-#endif //QT_NO_ANIMATION
+#endif // animation
{
//we do it in one shot
widget->setGeometry(final_geometry);