summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles
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/styles
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/styles')
-rw-r--r--src/widgets/styles/qcommonstyle.cpp4
-rw-r--r--src/widgets/styles/qcommonstyle.h2
-rw-r--r--src/widgets/styles/qcommonstyle_p.h9
-rw-r--r--src/widgets/styles/qfusionstyle.cpp12
-rw-r--r--src/widgets/styles/qstyleanimation.cpp4
-rw-r--r--src/widgets/styles/qstyleanimation_p.h6
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp2
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp2
-rw-r--r--src/widgets/styles/styles.pri7
9 files changed, 26 insertions, 22 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 3b9186e61a..735ae6b080 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -105,7 +105,9 @@
#include <qsettings.h>
#include <qvariant.h>
#include <qpixmapcache.h>
+#if QT_CONFIG(animation)
#include <private/qstyleanimation_p.h>
+#endif
#include <limits.h>
@@ -1195,7 +1197,7 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w
}
#endif // QT_CONFIG(tabbar)
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
/*! \internal */
QList<const QObject*> QCommonStylePrivate::animationTargets() const
{
diff --git a/src/widgets/styles/qcommonstyle.h b/src/widgets/styles/qcommonstyle.h
index f39915295e..78c5171717 100644
--- a/src/widgets/styles/qcommonstyle.h
+++ b/src/widgets/styles/qcommonstyle.h
@@ -97,7 +97,7 @@ protected:
private:
Q_DECLARE_PRIVATE(QCommonStyle)
Q_DISABLE_COPY(QCommonStyle)
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
Q_PRIVATE_SLOT(d_func(), void _q_removeAnimation())
#endif
};
diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h
index 93db75ac2d..b347c8563a 100644
--- a/src/widgets/styles/qcommonstyle_p.h
+++ b/src/widgets/styles/qcommonstyle_p.h
@@ -43,8 +43,9 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qcommonstyle.h"
#include "qstyle_p.h"
+#if QT_CONFIG(animation)
#include "qstyleanimation_p.h"
-
+#endif
#include "qstyleoption.h"
QT_BEGIN_NAMESPACE
@@ -76,7 +77,7 @@ public:
~QCommonStylePrivate()
{
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
qDeleteAll(animations);
#endif
#if QT_CONFIG(itemviews)
@@ -115,7 +116,7 @@ public:
#endif
int animationFps;
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
void _q_removeAnimation();
QList<const QObject*> animationTargets() const;
@@ -125,7 +126,7 @@ public:
private:
mutable QHash<const QObject*, QStyleAnimation*> animations;
-#endif // QT_NO_ANIMATION
+#endif // animation
};
QT_END_NAMESPACE
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 7474cd23d6..5231f04df9 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1429,14 +1429,14 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
painter->drawRoundedRect(progressBar.adjusted(1, 1, -1, -1), 1, 1);
if (!indeterminate) {
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
(const_cast<QFusionStylePrivate*>(d))->stopAnimation(option->styleObject);
#endif
} else {
highlightedGradientStartColor.setAlpha(120);
painter->setPen(QPen(highlightedGradientStartColor, 9.0));
painter->setClipRect(progressBar.adjusted(1, 1, -1, -1));
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(option->styleObject)))
step = animation->animationStep() % 22;
else
@@ -2463,7 +2463,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
styleObject->setProperty("_q_stylestate", static_cast<QStyle::State::Int>(scrollBar->state));
styleObject->setProperty("_q_stylecontrols", static_cast<uint>(scrollBar->activeSubControls));
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
// if the scrollbar is transient or its attributes, geometry or
// state has changed, the opacity is reset back to 100% opaque
opacity = 1.0;
@@ -2481,10 +2481,10 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
} else if (anim && anim->mode() == QScrollbarStyleAnimation::Deactivating) {
d->stopAnimation(styleObject);
}
-#endif // !QT_NO_ANIMATION
+#endif // animation
}
-#ifndef QT_NO_ANIMATION
+#if QT_CONFIG(animation)
QScrollbarStyleAnimation *anim = qobject_cast<QScrollbarStyleAnimation *>(d->animation(styleObject));
if (anim && anim->mode() == QScrollbarStyleAnimation::Deactivating) {
// once a scrollbar was active (hovered/pressed), it retains
@@ -2513,7 +2513,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
}
}
painter->setOpacity(opacity);
-#endif // !QT_NO_ANIMATION
+#endif // animation
}
bool transient = proxy()->styleHint(SH_ScrollBar_Transient, option, widget);
diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp
index 0b8e32be19..b9202eae69 100644
--- a/src/widgets/styles/qstyleanimation.cpp
+++ b/src/widgets/styles/qstyleanimation.cpp
@@ -39,8 +39,6 @@
#include "qstyleanimation_p.h"
-#ifndef QT_NO_ANIMATION
-
#include <qcoreapplication.h>
#include <qwidget.h>
#include <qevent.h>
@@ -367,5 +365,3 @@ void QScrollbarStyleAnimation::updateCurrentTime(int time)
QT_END_NAMESPACE
#include "moc_qstyleanimation_p.cpp"
-
-#endif //QT_NO_ANIMATION
diff --git a/src/widgets/styles/qstyleanimation_p.h b/src/widgets/styles/qstyleanimation_p.h
index a2ad4a91da..d28fc6ebab 100644
--- a/src/widgets/styles/qstyleanimation_p.h
+++ b/src/widgets/styles/qstyleanimation_p.h
@@ -45,9 +45,9 @@
#include "qdatetime.h"
#include "qimage.h"
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(animation);
-#ifndef QT_NO_ANIMATION
+QT_BEGIN_NAMESPACE
//
// W A R N I N G
@@ -201,8 +201,6 @@ private:
bool _active;
};
-#endif // QT_NO_ANIMATION
-
QT_END_NAMESPACE
#endif // QSTYLEANIMATION_P_H
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index c046ac52f9..ceede9e72f 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -84,7 +84,9 @@
#include <qheaderview.h>
#endif
#include <private/qwindowsstyle_p_p.h>
+#if QT_CONFIG(animation)
#include <private/qstyleanimation_p.h>
+#endif
#if QT_CONFIG(tabbar)
#include <qtabbar.h>
#endif
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 7c9d917784..80ce8419f8 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -86,7 +86,9 @@
#include <private/qhighdpiscaling_p.h>
#include <private/qstylehelper_p.h>
+#if QT_CONFIG(animation)
#include <private/qstyleanimation_p.h>
+#endif
#include <algorithm>
diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri
index 0c0f8b7bc7..821c40af81 100644
--- a/src/widgets/styles/styles.pri
+++ b/src/widgets/styles/styles.pri
@@ -3,7 +3,6 @@
HEADERS += \
styles/qdrawutil.h \
styles/qstyle.h \
- styles/qstyleanimation_p.h \
styles/qstylefactory.h \
styles/qstyleoption.h \
styles/qstyleplugin.h \
@@ -21,7 +20,6 @@ HEADERS += \
SOURCES += \
styles/qdrawutil.cpp \
styles/qstyle.cpp \
- styles/qstyleanimation.cpp \
styles/qstylefactory.cpp \
styles/qstyleoption.cpp \
styles/qstyleplugin.cpp \
@@ -37,6 +35,11 @@ RESOURCES += styles/qstyle.qrc
include($$OUT_PWD/qtwidgets-config.pri)
+qtConfig(animation) {
+ HEADERS += styles/qstyleanimation_p.h
+ SOURCES += styles/qstyleanimation.cpp
+}
+
qtConfig(style-windows) {
HEADERS += styles/qwindowsstyle_p.h styles/qwindowsstyle_p_p.h
SOURCES += styles/qwindowsstyle.cpp