diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2013-06-25 15:58:47 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-26 09:09:06 +0200 |
commit | a98b60edfcdc5c84da6d34613a44da207e07d15e (patch) | |
tree | a01bc819c65fe5fdc2db090a8463a0f2d26e7ffe /src | |
parent | e9d539623aa97b307a0d5d7cd10dbdf392e9b92f (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 23 | ||||
-rw-r--r-- | src/widgets/styles/qmacstyle_mac_p_p.h | 2 |
2 files changed, 17 insertions, 8 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index f8905b1b1a..dad4e57d13 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -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) { diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index bf42087fcb..efeaa66e39 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -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; |