Mac: Adapt scrollbar fadeout animation for QStyleAnimation
authorGabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Fri, 19 Oct 2012 14:35:54 +0000 (16:35 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 19 Oct 2012 15:53:26 +0000 (17:53 +0200)
Change-Id: I39f1089e8d6ba1bb412d33aa4ebc0971aba52681
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
src/widgets/styles/qmacstyle_mac.mm
src/widgets/styles/qmacstyle_mac_p.h

index 38f4dc3..2b6f271 100644 (file)
@@ -1739,7 +1739,6 @@ bool QMacStylePrivate::addWidget(QWidget *w)
         bool isScrollBar = (qobject_cast<QScrollBar *>(w));
         if (isScrollBar) {
             w->installEventFilter(q);
-            startAnimate(AquaScrollBar, w);
             return true;
         }
     }
@@ -5106,6 +5105,14 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
                                           QMacStylePrivate::ScrollBarFadeOutDuration);
                 info.cleared = opacity <= 0.0;
 
+                if (info.animating && info.cleared) {
+                    d->stopAnimation(slider->styleObject);
+                    info.animating = false;
+                } else if (!info.animating && !info.cleared) {
+                    d->startAnimation(new QStyleAnimation(slider->styleObject));
+                    info.animating = true;
+                }
+
                 CGContextBeginTransparencyLayerWithRect(cg, qt_hirectForQRect(slider->rect), NULL);
                 CGContextSetAlpha(cg, opacity);
 
index 812c79e..66691c6 100644 (file)
@@ -211,7 +211,8 @@ public:
               lastUpdate(QDateTime::currentMSecsSinceEpoch()),
               hovered(false),
               lastHovered(0),
-              cleared(false)
+              cleared(false),
+              animating(false)
         {}
         int lastValue;
         int lastMinimum;
@@ -221,6 +222,7 @@ public:
         bool hovered;
         qint64 lastHovered;
         bool cleared;
+        bool animating;
     };
     mutable QMap<const QWidget*, OverlayScrollBarInfo> scrollBarInfos;