Enable tests to turn off Windows Vista animations
Animations in that style depend on the current time, which makes it impossible to run baseline tests. Introduce a dynamic property that allows us to set the time that animations use. This way, tests can turn the animation off, or control which time should be used. To keep performance overhead low, check only once whether the dynamic property is set at all. Change-Id: I9bc57b9867fb0d852e101570eca4c7609e7fe1a8 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit 58a14d943353f02bfbee0a65f5e31c40358c8c53) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a62b8a3ad9
commit
db558fe10b
@ -86,6 +86,22 @@ bool QWindowsVistaStylePrivate::useVista()
|
|||||||
return QWindowsVistaStylePrivate::useXP();
|
return QWindowsVistaStylePrivate::useXP();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
|
||||||
|
Animations are started at a frame that is based on the current time,
|
||||||
|
which makes it impossible to run baseline tests with this style. Allow
|
||||||
|
overriding through a dynamic property.
|
||||||
|
*/
|
||||||
|
QTime QWindowsVistaStylePrivate::animationTime() const
|
||||||
|
{
|
||||||
|
Q_Q(const QWindowsVistaStyle);
|
||||||
|
static bool animationTimeOverride = q->dynamicPropertyNames().contains("_qt_animation_time");
|
||||||
|
if (animationTimeOverride)
|
||||||
|
return q->property("_qt_animation_time").toTime();
|
||||||
|
return QTime::currentTime();
|
||||||
|
}
|
||||||
|
|
||||||
/* \internal
|
/* \internal
|
||||||
Checks and returns the style object
|
Checks and returns the style object
|
||||||
*/
|
*/
|
||||||
@ -391,7 +407,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
|
|||||||
TMT_TRANSITIONDURATIONS, &duration))) {
|
TMT_TRANSITIONDURATIONS, &duration))) {
|
||||||
t->setDuration(int(duration));
|
t->setDuration(int(duration));
|
||||||
}
|
}
|
||||||
t->setStartTime(QTime::currentTime());
|
t->setStartTime(d->animationTime());
|
||||||
|
|
||||||
deleteClonedAnimationStyleOption(styleOption);
|
deleteClonedAnimationStyleOption(styleOption);
|
||||||
d->startAnimation(t);
|
d->startAnimation(t);
|
||||||
@ -899,7 +915,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
t->setDuration(int(duration));
|
t->setDuration(int(duration));
|
||||||
else
|
else
|
||||||
t->setDuration(0);
|
t->setDuration(0);
|
||||||
t->setStartTime(QTime::currentTime());
|
t->setStartTime(d->animationTime());
|
||||||
styleObject->setProperty("_q_no_animation", false);
|
styleObject->setProperty("_q_no_animation", false);
|
||||||
|
|
||||||
deleteClonedAnimationStyleOption(styleOption);
|
deleteClonedAnimationStyleOption(styleOption);
|
||||||
@ -961,7 +977,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
d->drawBackground(theme);
|
d->drawBackground(theme);
|
||||||
pulse->setStartImage(startImage);
|
pulse->setStartImage(startImage);
|
||||||
pulse->setEndImage(alternateImage);
|
pulse->setEndImage(alternateImage);
|
||||||
pulse->setStartTime(QTime::currentTime());
|
pulse->setStartTime(d->animationTime());
|
||||||
pulse->setDuration(2000);
|
pulse->setDuration(2000);
|
||||||
d->startAnimation(pulse);
|
d->startAnimation(pulse);
|
||||||
anim = pulse;
|
anim = pulse;
|
||||||
@ -1022,7 +1038,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
vertical ? PP_FILLVERT : PP_FILL);
|
vertical ? PP_FILLVERT : PP_FILL);
|
||||||
theme.rect = option->rect;
|
theme.rect = option->rect;
|
||||||
bool reverse = (bar->direction == Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted);
|
bool reverse = (bar->direction == Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted);
|
||||||
QTime current = QTime::currentTime();
|
QTime current = d->animationTime();
|
||||||
|
|
||||||
if (isIndeterminate) {
|
if (isIndeterminate) {
|
||||||
if (QProgressStyleAnimation *a = qobject_cast<QProgressStyleAnimation *>(d->animation(styleObject(option)))) {
|
if (QProgressStyleAnimation *a = qobject_cast<QProgressStyleAnimation *>(d->animation(styleObject(option)))) {
|
||||||
@ -1030,7 +1046,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
|
int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
|
||||||
int animOffset = a->startTime().msecsTo(current) / 4;
|
int animOffset = a->startTime().msecsTo(current) / 4;
|
||||||
if (animOffset > animationWidth)
|
if (animOffset > animationWidth)
|
||||||
a->setStartTime(QTime::currentTime());
|
a->setStartTime(d->animationTime());
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setClipRect(theme.rect);
|
painter->setClipRect(theme.rect);
|
||||||
QRect animRect;
|
QRect animRect;
|
||||||
@ -1102,7 +1118,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
theme.partId = vertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY;
|
theme.partId = vertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY;
|
||||||
if (animOffset > animationWidth) {
|
if (animOffset > animationWidth) {
|
||||||
if (bar->progress < bar->maximum)
|
if (bar->progress < bar->maximum)
|
||||||
a->setStartTime(QTime::currentTime());
|
a->setStartTime(d->animationTime());
|
||||||
else
|
else
|
||||||
d->stopAnimation(styleObject(option)); //we stop the glow motion only after it has
|
d->stopAnimation(styleObject(option)); //we stop the glow motion only after it has
|
||||||
//moved out of view
|
//moved out of view
|
||||||
@ -1577,7 +1593,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
|
|||||||
styleObject->setProperty("_q_no_animation", false);
|
styleObject->setProperty("_q_no_animation", false);
|
||||||
|
|
||||||
t->setEndImage(endImage);
|
t->setEndImage(endImage);
|
||||||
t->setStartTime(QTime::currentTime());
|
t->setStartTime(d->animationTime());
|
||||||
|
|
||||||
if (option->state & State_MouseOver || option->state & State_Sunken)
|
if (option->state & State_MouseOver || option->state & State_Sunken)
|
||||||
t->setDuration(150);
|
t->setDuration(150);
|
||||||
|
@ -194,6 +194,7 @@ class QWindowsVistaStylePrivate : public QWindowsXPStylePrivate
|
|||||||
public:
|
public:
|
||||||
static int fixedPixelMetric(QStyle::PixelMetric pm);
|
static int fixedPixelMetric(QStyle::PixelMetric pm);
|
||||||
static inline bool useVista();
|
static inline bool useVista();
|
||||||
|
QTime animationTime() const;
|
||||||
bool transitionsEnabled() const;
|
bool transitionsEnabled() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ QWidgetBaselineTest::QWidgetBaselineTest()
|
|||||||
#else
|
#else
|
||||||
QApplication::style()->name();
|
QApplication::style()->name();
|
||||||
#endif
|
#endif
|
||||||
|
QApplication::style()->setProperty("_qt_animation_time", QTime());
|
||||||
QByteArray appearanceBytes;
|
QByteArray appearanceBytes;
|
||||||
{
|
{
|
||||||
QDataStream appearanceStream(&appearanceBytes, QIODevice::WriteOnly);
|
QDataStream appearanceStream(&appearanceBytes, QIODevice::WriteOnly);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user