QMacStyle: fix auto-default button animation
Make sure to stop any previously active (auto-default button) animation when the auto-default button changes. Task-number: QTBUG-31668 Change-Id: Iaa9bfa485b11e49cd7f765d0e54b4e6391ad2f6d Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>bb10
parent
e9d539623a
commit
a98b60edfc
|
|
@ -1630,6 +1630,19 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti
|
|||
}
|
||||
}
|
||||
|
||||
void QMacStylePrivate::setAutoDefaultButton(QObject *button) const
|
||||
{
|
||||
if (autoDefaultButton != button) {
|
||||
if (QStyleAnimation *anim = animation(autoDefaultButton)) {
|
||||
anim->updateTarget();
|
||||
stopAnimation(autoDefaultButton);
|
||||
}
|
||||
autoDefaultButton = button;
|
||||
}
|
||||
if (autoDefaultButton && !animation(autoDefaultButton))
|
||||
startAnimation(new QStyleAnimation(autoDefaultButton));
|
||||
}
|
||||
|
||||
QMacStylePrivate::QMacStylePrivate()
|
||||
: mouseDown(false)
|
||||
{
|
||||
|
|
@ -3497,15 +3510,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
|
|||
// takes precedence over a normal default button
|
||||
if (btn->features & QStyleOptionButton::AutoDefaultButton
|
||||
&& opt->state & State_Active && opt->state & State_HasFocus) {
|
||||
d->autoDefaultButton = opt->styleObject;
|
||||
if (!d->animation(opt->styleObject))
|
||||
d->startAnimation(new QStyleAnimation(opt->styleObject));
|
||||
d->setAutoDefaultButton(opt->styleObject);
|
||||
} else if (d->autoDefaultButton == opt->styleObject) {
|
||||
if (QStyleAnimation *animation = d->animation(opt->styleObject)) {
|
||||
animation->updateTarget();
|
||||
d->stopAnimation(opt->styleObject);
|
||||
}
|
||||
d->autoDefaultButton = 0;
|
||||
d->setAutoDefaultButton(0);
|
||||
}
|
||||
|
||||
if (!d->autoDefaultButton) {
|
||||
|
|
|
|||
|
|
@ -194,6 +194,8 @@ public:
|
|||
HIThemeButtonDrawInfo *bdi) const;
|
||||
QPixmap generateBackgroundPattern() const;
|
||||
|
||||
void setAutoDefaultButton(QObject *button) const;
|
||||
|
||||
public:
|
||||
mutable QPointer<QObject> pressedButton;
|
||||
mutable QPointer<QObject> defaultButton;
|
||||
|
|
|
|||
Loading…
Reference in New Issue