diff options
author | Àlex Fiestas <afiestas@kde.org> | 2013-06-17 11:21:32 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-02 10:44:39 +0200 |
commit | 0ace3112137b78cf7d150e9974e69ccfe6838533 (patch) | |
tree | b2e258b302c6dbc920cbd7a38853bcf35e93d2d7 /src/widgets/widgets | |
parent | 25fc7a3068741807fb15eefb2fe57618a1b1fb84 (diff) |
Added SH_Widget_Animate in QStyle
Added SH_Widget_Animate in QStyle styleHint, and use it to determine
whether widgets should be animated or not.
In this patch QTabBar, QColumnView,QTreeView and QWidgetAnimator are
patched to obey the new Hint.
Change-Id: Iefdbddc52c7843f6653dbfb5462125942489b4d9
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qtabbar_p.h | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgetanimator.cpp | 28 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h index 7468144146..8c6e70b8d7 100644 --- a/src/widgets/widgets/qtabbar_p.h +++ b/src/widgets/widgets/qtabbar_p.h @@ -138,6 +138,10 @@ public: } *animation; void startAnimation(QTabBarPrivate *priv, int duration) { + if (!priv->isAnimated()) { + priv->moveTabFinished(priv->tabList.indexOf(*this)); + return; + } if (!animation) animation = new TabBarAnimation(this, priv); animation->setStartValue(dragOffset); @@ -162,6 +166,7 @@ public: int indexAtPos(const QPoint &p) const; + inline bool isAnimated() const { Q_Q(const QTabBar); return q->style()->styleHint(QStyle::SH_Widget_Animate, 0, q); } inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); } void setCurrentNextEnabledIndex(int offset); diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp index bbd96ca29a..1209ade536 100644 --- a/src/widgets/widgets/qwidgetanimator.cpp +++ b/src/widgets/widgets/qwidgetanimator.cpp @@ -91,24 +91,28 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size()); #ifndef QT_NO_ANIMATION - AnimationMap::const_iterator it = m_animation_map.constFind(widget); - if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry) - return; + //If the QStyle has animations, animate + if (widget->style()->styleHint(QStyle::SH_Widget_Animate, 0, widget)) { + AnimationMap::const_iterator it = m_animation_map.constFind(widget); + if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry) + return; - QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget); - anim->setDuration(animate ? 200 : 0); - anim->setEasingCurve(QEasingCurve::InOutQuad); - anim->setEndValue(final_geometry); - m_animation_map[widget] = anim; - connect(anim, SIGNAL(finished()), SLOT(animationFinished())); - anim->start(QPropertyAnimation::DeleteWhenStopped); -#else + QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget); + anim->setDuration(animate ? 200 : 0); + anim->setEasingCurve(QEasingCurve::InOutQuad); + anim->setEndValue(final_geometry); + m_animation_map[widget] = anim; + connect(anim, SIGNAL(finished()), SLOT(animationFinished())); + anim->start(QPropertyAnimation::DeleteWhenStopped); + } else +#endif //QT_NO_ANIMATION + { //we do it in one shot widget->setGeometry(final_geometry); #ifndef QT_NO_MAINWINDOW m_mainWindowLayout->animationFinished(widget); #endif //QT_NO_MAINWINDOW -#endif //QT_NO_ANIMATION + } } bool QWidgetAnimator::animating() const |