[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kstyles/keramik
From:       Waldo Bastian <bastian () kde ! org>
Date:       2004-11-24 22:26:25
Message-ID: 20041124222625.5B64C1D1FF () office ! kde ! org
[Download RAW message or body]

CVS commit by waba: 

Be gentle on the cpu:
only enable the progressbar timer when a progressbar is visible.


  M +20 -4     keramik.cpp   1.136
  M +4 -1      keramik.h   1.28


--- kdelibs/kstyles/keramik/keramik.cpp  #1.135:1.136
@@ -291,7 +291,6 @@ KeramikStyle::KeramikStyle()
         if (animateProgressBar)
         {
-                QTimer* timer = new QTimer( this );
-                timer->start(50, false);
-                connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressPos()));
+                animationTimer = new QTimer( this );
+                connect( animationTimer, SIGNAL(timeout()), this, \
SLOT(updateProgressPos()) );  }
         
@@ -303,4 +302,5 @@ void KeramikStyle::updateProgressPos()
         //Update the registered progressbars.
         QMap<QProgressBar*, int>::iterator iter;
+        bool visible = false;
         for (iter = progAnimWidgets.begin(); iter != progAnimWidgets.end(); iter++)
         {
@@ -314,5 +314,10 @@ void KeramikStyle::updateProgressPos()
                         iter.key()->update();
                 }
+                if (iter.key()->isVisible())
+                        visible = true;
+                
         }
+        if (!visible)
+                animationTimer->stop();
 }
 
@@ -361,6 +366,9 @@ void KeramikStyle::polish(QWidget* widge
         if (animateProgressBar && ::qt_cast<QProgressBar*>(widget))
         {
+                widget->installEventFilter(this);
                 progAnimWidgets[static_cast<QProgressBar*>(widget)] = 0;
                 connect(widget, SIGNAL(destroyed(QObject*)), this, \
SLOT(progressBarDestroyed(QObject*))); +                if \
(!animationTimer->isActive()) +                        animationTimer->start( 50, \
false );  }
 
@@ -2913,4 +2921,12 @@ bool KeramikStyle::eventFilter( QObject*
 
         }
+        // Track show events for progress bars
+        if ( animateProgressBar && ::qt_cast<QProgressBar*>(object) )
+        {
+                if ((event->type() == QEvent::Show) && !animationTimer->isActive())
+                {
+                        animationTimer->start( 50, false );
+                }
+        }
         return false;
 }

--- kdelibs/kstyles/keramik/keramik.h  #1.27:1.28
@@ -192,4 +192,7 @@ private:
         bool kickerMode;
 
+        // For progress bar animation
+        QTimer *animationTimer;
+
         QRect subRect(SubRect r, const QWidget *widget) const;
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic