[Digikam-devel] branches/extragear/kde3/graphics/digikam

Gilles Caulier caulier.gilles at gmail.com
Wed Jun 27 14:13:38 BST 2007


SVN commit 680933 by cgilles:

digiKam from KDE3 branch : new splashscreen implemetation based on QSplashScreen. More portable. will be backported later on KDE4 branch
CCMAIL: digikam-devel at kde.org


 M  +1 -0      digikam/digikamapp.cpp  
 M  +58 -120   libs/widgets/common/splashscreen.cpp  
 M  +14 -20    libs/widgets/common/splashscreen.h  
 M  +9 -9      project/project.kdevelop  
 M  +1 -0      showfoto/showfoto.cpp  


--- branches/extragear/kde3/graphics/digikam/digikam/digikamapp.cpp #680932:680933
@@ -107,6 +107,7 @@
        !kapp->isRestored())
     {
         d->splashScreen = new SplashScreen("digikam-splash.png");
+        d->splashScreen->show();
     }
 
     d->albumSettings = new AlbumSettings();
--- branches/extragear/kde3/graphics/digikam/libs/widgets/common/splashscreen.cpp #680932:680933
@@ -22,12 +22,12 @@
  *
  * ============================================================ */
 
-// Qt includes. 
- 
-#include <qpixmap.h>
-#include <qapplication.h>
+// Qt includes.
+
 #include <qtimer.h>
-#include <qpainter.h>
+#include <qfont.h>
+#include <qstring.h>
+#include <qcolor.h>
 
 // KDE includes.
 
@@ -40,10 +40,6 @@
 #include "splashscreen.h"
 #include "splashscreen.moc"
 
-#if defined(Q_WS_X11)
-void qt_wait_for_window_manager( QWidget *widget );
-#endif
-
 namespace Digikam
 {
 
@@ -53,144 +49,83 @@
 
     SplashScreenPriv()
     {
-        currState       = 0;
+        state           = 0;
         progressBarSize = 3;
-        pix             = 0;
-        timer           = 0;
+        state           = 0;
     }
 
-    bool     close;
-
-    int      currAlign;
-    int      currState;
-    int      progressBarSize;
-
-    QPixmap *pix;
-
-    QTimer  *timer;
-
-    QString  currStatus;
-
-    QColor   currColor;
+    int     state;
+    int     progressBarSize;
+    int     alignment;
+       
+    QString string;
+    
+    QColor  color;
 };
 
-SplashScreen::SplashScreen(const QString& splash)
-            : QWidget(0, 0, WStyle_Customize|WStyle_Splash)
+SplashScreen::SplashScreen(const QString& splash, WFlags f)
+            : QSplashScreen(QPixmap(locate("appdata", splash)), f)
 {
     d = new SplashScreenPriv;
     
-    QString file = locate( "appdata", splash );
-
-    d->pix = new QPixmap(file);
-
-    setErasePixmap( *d->pix );
-    resize( d->pix->size() );
-    QRect scr = QApplication::desktop()->screenGeometry();
-    move( scr.center() - rect().center() );
-    show();
-    animate();
-
-    d->close = false;
+	QTimer *timer = new QTimer( this );
     
-    d->timer = new QTimer;
-    connect(d->timer, SIGNAL(timeout()),
-            this,   SLOT(slotClose()));
-    d->timer->start(1000, true);
+	connect(timer, SIGNAL(timeout()),
+            this, SLOT(animate()));
+            
+    timer->start(150);
 }
 
 SplashScreen::~SplashScreen()
 {
-    delete d->pix;
-    delete d->timer;
     delete d;
 }
 
-void SplashScreen::finish( QWidget *mainWin )
-{
-#if defined(Q_WS_X11)
-    qt_wait_for_window_manager( mainWin );
-#endif
-    d->close = true;
-    slotClose();
-}
-
-void SplashScreen::repaint()
-{
-    drawContents();
-    QWidget::repaint();
-    QApplication::flush();
-}
-
-void SplashScreen::mousePressEvent( QMouseEvent * )
-{
-    hide();
-}
-
-void SplashScreen::slotClose()
-{
-    if (!d->close) 
-    {
-        d->timer->start(500, true);
-        return;
-    }
-    
-    if (d->timer->isActive()) return;
-    delete this;
-}
-
-void SplashScreen::message(const QString &message, int alignment,
-                           const QColor &color )
-{
-    d->currStatus = message;
-    d->currAlign = alignment;
-    d->currColor = color;
-    animate();
-}
-
 void SplashScreen::animate()
 {
-    d->currState = ((d->currState + 1) % (2*d->progressBarSize-1));
-    repaint();
+	d->state = ((d->state + 1) % (2*d->progressBarSize-1));
+	repaint();
 }
 
-void SplashScreen::drawContents()
+void SplashScreen::message( const QString &message, int alignment, const QColor &color)
 {
-    QPixmap textPix = *d->pix;
-    QPainter painter(&textPix, this);
-    drawContents(&painter);
-    setErasePixmap(textPix);
+    d->string    = message;
+    d->color     = color;
+    d->alignment = alignment;
+    QSplashScreen::message(d->string, d->alignment, d->color);
+	animate();
 }
 
-void SplashScreen::drawContents( QPainter *painter )
+void SplashScreen::drawContents(QPainter* painter)
 {
     int position;
     QColor basecolor (155, 192, 231);
 
-    // Draw background circles
-    painter->setPen(NoPen);
-    painter->setBrush(QColor(225,234,231));
-    painter->drawEllipse(21,7,9,9);
-    painter->drawEllipse(32,7,9,9);
-    painter->drawEllipse(43,7,9,9);
-    
-    // Draw animated circles, increments are chosen
-    // to get close to background's color
-    // (didn't work well with QColor::light function)
-    for (int i=0; i < d->progressBarSize; i++)
-    {
-        position = (d->currState+i)%(2*d->progressBarSize-1);
+	// Draw background circles
+	painter->setPen(NoPen);
+    painter->setBrush(QColor(225, 234, 231));
+    painter->drawEllipse(21, 7, 9, 9);
+    painter->drawEllipse(32, 7, 9, 9);
+    painter->drawEllipse(43, 7, 9, 9);
+
+	// Draw animated circles, increments are chosen
+	// to get close to background's color
+	// (didn't work well with QColor::light function)
+	for (int i=0; i < d->progressBarSize; i++)
+	{
+		position = (d->state+i)%(2*d->progressBarSize-1);
         if (position < 3)
         {
-            painter->setBrush(QColor(basecolor.red()-18*i,
-                              basecolor.green()-28*i,
-                              basecolor.blue()-10*i));
-            painter->drawEllipse(21+position*11,7,9,9);
+            painter->setBrush(QColor(basecolor.red()  -18*i,
+                                     basecolor.green()-28*i,
+                                     basecolor.blue() -10*i));
+    
+            painter->drawEllipse(21+position*11, 7, 9, 9);
         }
-    }
+	}
+
+	painter->setPen(d->color);
     
-    
-    painter->setPen(d->currColor);
-    
     QFont fnt(KGlobalSettings::generalFont());
     int fntSize = fnt.pointSize();
     if (fntSize > 0)
@@ -203,11 +138,14 @@
         fnt.setPixelSize(fntSize-2);
     }
     painter->setFont(fnt);
-   
-    QRect r = rect();
+
+	QRect r = rect();
     r.setRect( r.x() + 59, r.y() + 5, r.width() - 10, r.height() - 10 );
-    painter->drawText(r, d->currAlign, d->currStatus);
+
+	// Draw message at given position, limited to 43 chars
+	// If message is too long, string is truncated
+	if (d->string.length() > 40) {d->string.truncate(39); d->string += "...";}
+    painter->drawText(r, d->alignment, d->string);
 }
 
 }   // namespace Digikam
-
--- branches/extragear/kde3/graphics/digikam/libs/widgets/common/splashscreen.h #680932:680933
@@ -21,14 +21,14 @@
  * GNU General Public License for more details.
  *
  * ============================================================ */
-
+ 
 #ifndef SPLASHSCREEN_H
 #define SPLASHSCREEN_H
 
 // Qt includes.
 
-#include <qwidget.h>
-#include <qstring.h>
+#include <qsplashscreen.h>
+#include <qpainter.h>
 
 // Local Includes.
 
@@ -39,31 +39,25 @@
 
 class SplashScreenPriv;
 
-class DIGIKAM_EXPORT SplashScreen : public QWidget
+class DIGIKAM_EXPORT SplashScreen : public QSplashScreen
 {
-    Q_OBJECT
+Q_OBJECT
 
 public:
+	
+    SplashScreen(const QString& splash, WFlags f = 0);
+	virtual ~SplashScreen();
 
-    SplashScreen(const QString& splash);
-    ~SplashScreen();
+protected:
+	
+    void drawContents (QPainter *);
 
-    void finish( QWidget *mainWin );
-    void repaint();
+public slots:
+	
+    void animate();
     void message(const QString &message, int alignment = AlignLeft,
                  const QColor &color = white );
 
-protected:
-
-    void mousePressEvent( QMouseEvent * );
-    void drawContents();
-    void drawContents(QPainter *painter);
-    void animate();
-        
-private slots:
-
-    void slotClose();
-
 private:
 
     SplashScreenPriv* d;
--- branches/extragear/kde3/graphics/digikam/project/project.kdevelop #680932:680933
@@ -12,7 +12,7 @@
     </keywords>
     <projectdirectory>./</projectdirectory>
     <absoluteprojectpath>false</absoluteprojectpath>
-    <description/>
+    <description></description>
     <ignoreparts/>
     <projectname>digikam</projectname>
     <defaultencoding/>
@@ -74,11 +74,11 @@
   <kdevdebugger>
     <general>
       <dbgshell>libtool</dbgshell>
-      <programargs/>
-      <gdbpath/>
-      <configGdbScript/>
-      <runShellScript/>
-      <runGdbScript/>
+      <programargs></programargs>
+      <gdbpath></gdbpath>
+      <configGdbScript></configGdbScript>
+      <runShellScript></runShellScript>
+      <runGdbScript></runGdbScript>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>false</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
@@ -113,8 +113,8 @@
     <run>
       <directoryradio>build</directoryradio>
       <customdirectory>/</customdirectory>
-      <mainprogram>/home/gilles/Documents/devel/SVN/branch/kde3/graphics/digikam/digikam/digikam</mainprogram>
-      <programargs/>
+      <mainprogram>digikam/digikam/digikam</mainprogram>
+      <programargs></programargs>
       <terminal>false</terminal>
       <autocompile>false</autocompile>
       <envvars/>
@@ -192,7 +192,7 @@
       <includePaths>.;</includePaths>
     </codecompletion>
     <creategettersetter>
-      <prefixGet/>
+      <prefixGet></prefixGet>
       <prefixSet>set</prefixSet>
       <prefixVariable>m_,_</prefixVariable>
       <parameterName>theValue</parameterName>
--- branches/extragear/kde3/graphics/digikam/showfoto/showfoto.cpp #680932:680933
@@ -162,6 +162,7 @@
     if(config->readBoolEntry("ShowSplash", true) && !kapp->isRestored())
     {
         d->splash = new Digikam::SplashScreen("showfoto-splash.png");
+        d->splash->show();
     }
 
     // Check ICC profiles repository availability



More information about the Digikam-devel mailing list