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

List:       kde-commits
Subject:    branches/extragear/graphics/digikam/libs
From:       Martin Klapetek <martin.klapetek () gmail ! com>
Date:       2010-10-01 0:36:30
Message-ID: 20101001003630.6CDA5AC891 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1181434 by mklapetek:

Improvements in thumbs painting in versions sidebar. Now it stops the timer of the \
workingWidget instead of just disconnecting the painter from it. Also a 1.5 second \
delay to the stop was added to make sure, that the painter has enough time to repaint \
the sidebar and thus show all the loaded thumbs.

 M  +17 -9     imageproperties/imagepropertiesversionsdelegate.cpp  
 M  +1 -0      imageproperties/imagepropertiesversionsdelegate.h  
 M  +12 -0     widgets/common/workingwidget.cpp  
 M  +3 -0      widgets/common/workingwidget.h  


--- branches/extragear/graphics/digikam/libs/imageproperties/imagepropertiesversionsdelegate.cpp \
#1181433:1181434 @@ -27,6 +27,7 @@
 
 #include <QPainter>
 #include <QApplication>
+#include <QTimer>
 
 // KDE includes
 
@@ -62,15 +63,13 @@
 ImagePropertiesVersionsDelegate::ImagePropertiesVersionsDelegate(QObject* parent)
                                : QStyledItemDelegate(parent), d(new \
ImagePropertiesVersionsDelegatePriv)  {
-    KColorScheme sysColors(QPalette::Normal);
-    
     d->workingWidget = new WorkingWidget();
     d->thumbsPainted = 0;
-    //TODO: get system color for views as a background
-    QColor viewBgColor = sysColors.background().color();
-    d->workingWidget->setStyleSheet(QString("background-color: rgb(%1, %2, \
                %2);").arg(viewBgColor.red(),
-                                    viewBgColor.green(), viewBgColor.blue()));
 
+    //FIXME: this doesn't work, it needs some better way how to paint it \
transparentely, ie. get the view color +    // make the workingWidget's background \
transparent +    //d->workingWidget->setStyleSheet(QString("background-color: \
rgba(255, 255, 255, 0%);")); +
     connect(d->workingWidget, SIGNAL(animationStep()),
             this, SLOT(slotAnimationStep()));
 }
@@ -118,14 +117,18 @@
         }
         if(d->thumbsPainted == index.model()->rowCount())
         {
-            //the animation gets disconnected after the last thumbnail is drawn
-            //this way it won't uselessly emit signals that model has updated data \
                (which has not)
-            disconnect(d->workingWidget, SIGNAL(animationStep()), 0, 0);
+            // the timer can be stopped after last thumbnail is drawn,
+            // but it needs to be delayed a little, so that all thumbs
+            // have enough time to get painted correctly
+            delayedAnimationTimerStop();
+            
         }
     }
     else
     {
         //when the thumbnail is not loaded yet, start the animation
+        d->workingWidget->toggleTimer(true);
+
         connect(d->workingWidget, SIGNAL(animationStep()),
                 dynamic_cast<const ImageVersionsModel*>(index.model()), \
SLOT(slotAnimationStep()));  
@@ -168,4 +171,9 @@
     d->thumbsPainted = 0;
 }
 
+void ImagePropertiesVersionsDelegate::delayedAnimationTimerStop() const
+{
+    QTimer::singleShot(1500, d->workingWidget, SLOT(toggleTimer()));
+}
+
 } // namespace Digikam
--- branches/extragear/graphics/digikam/libs/imageproperties/imagepropertiesversionsdelegate.h \
#1181433:1181434 @@ -50,6 +50,7 @@
     void paint(QPainter* painter, const QStyleOptionViewItem& option, const \
QModelIndex& index) const;  WorkingWidget* getWidget() const;
     void           resetThumbsCounter();
+    void           delayedAnimationTimerStop() const;
 
 public Q_SLOTS:
 
--- branches/extragear/graphics/digikam/libs/widgets/common/workingwidget.cpp \
#1181433:1181434 @@ -99,4 +99,16 @@
     emit animationStep();
 }
 
+void WorkingWidget::toggleTimer(bool turnOn)
+{
+    if(turnOn && !d->timer.isActive())
+    {
+        d->timer.start();
+    }
+    else if(!turnOn && d->timer.isActive())
+    {
+        d->timer.stop();
+    }
+}
+
 } // namespace Digikam
--- branches/extragear/graphics/digikam/libs/widgets/common/workingwidget.h \
#1181433:1181434 @@ -49,6 +49,9 @@
 
     void animationStep();
 
+public Q_SLOTS:
+    void toggleTimer(bool turnOn = false);
+
 private Q_SLOTS:
 
     void changeImage();


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

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