[Kstars-devel] KDE/kdeedu/kstars/kstars

Médéric Boquien mboquien at free.fr
Sat Mar 14 17:01:06 CET 2009


SVN commit 939307 by mboquien:

Use KSplashScreen for the splash screen rather than a custom QDialog. Now it looks like a real splash screen. The code is much shorter/simpler and the splash screen is a bit smaller. The progress 
messages are displayed on the top left hand corner in light grey rather than at the bottom.

The splash screen is used at startup ad when reindexing stars, i am not sure how to trigger this so if someone could check it works fine it would be great.

CCMAIL: kstars-devel at kde.org


 M  +0 -1      kstars.cpp  
 M  +8 -75     kstarssplash.cpp  
 M  +3 -16     kstarssplash.h  
 M  +1 -1      skycomponents/starcomponent.cpp  


--- trunk/KDE/kdeedu/kstars/kstars/kstars.cpp #939306:939307
@@ -91,7 +91,6 @@
 
     if ( doSplash ) {
         splash = new KStarsSplash(0);
-        connect( splash, SIGNAL( closeWindow() ), qApp, SLOT( quit() ) );
         connect( kstarsData, SIGNAL( progressText(QString) ), splash, SLOT( setMessage(QString) ));
 
         //Uncomment to show startup messages on console also
--- trunk/KDE/kdeedu/kstars/kstars/kstarssplash.cpp #939306:939307
@@ -24,95 +24,28 @@
 #include <QFrame>
 #include <QPaintEvent>
 #include <QPainter>
-#include <QCloseEvent>
 #include <QApplication>
 
 #include <klocale.h>
 #include <kdebug.h>
+#include <KStandardDirs>
 
 #include "ksutils.h"
 
-//FIXME: program was crashing with KStarsSplash derived from KDialog,
-//so I am temporarily using QDialog.  Try switching back to KDialog
-//later on (this message added 20-June-2006)
-KStarsSplash::KStarsSplash( QWidget *parent, const QString& customMessage)
-        : QDialog( parent )
+KStarsSplash::KStarsSplash(const QString& customMessage )
+        : KSplashScreen(QPixmap() )
 {
-
-    QString message = customMessage.isEmpty() ?
+    setPixmap(KStandardDirs::locate("appdata","kstars.png"));
+    setMessage( customMessage.isEmpty() ?
                       i18n( "Welcome to KStars. Please stand by while loading..." ) :
-                      customMessage;
-
-    QPalette p = palette();
-    p.setColor( QPalette::Window, Qt::black );
-    setPalette( p );
-
-    //Set up widgets for splashscreen.
-    // KDialog stuff:
-    //	QFrame *page = new QFrame( this );
-    //        setMainWidget( page );
-    //        setCaption( i18n( "Loading KStars..." ) );
-    //        setButtons( 0 );
-
-    setWindowTitle( i18n("KStars") );
-
-    QVBoxLayout *topLayout = new QVBoxLayout( this );
-    topLayout->setMargin( 0 );
-    topLayout->setSpacing( 0 );
-
-    //Load the KStars banner.  Use an empty image if it can't be opened.
-    QFile imFile;
-    QPixmap pmSplash;
-    if ( KSUtils::openDataFile( imFile, "kstars.png" ) ) {
-        imFile.close(); //Just need the filename...
-        pmSplash.load( imFile.fileName() );
-    }
-
-    Banner = new QLabel( this ); //reparent to "page" if KDialog
-    Banner->setPixmap( pmSplash );
-    topLayout->addWidget( Banner );
-
-    //initialize the "Welcome to KStars message label
-    label = new QLabel( this ); //reparent to "page" if KDialog
-    label->setObjectName( "label1" );
-
-    QPalette pal( label->palette() );
-    pal.setColor( QPalette::Normal, QPalette::Window, QColor( "Black" ) );
-    pal.setColor( QPalette::Inactive, QPalette::Window, QColor( "Black" ) );
-    pal.setColor( QPalette::Normal, QPalette::WindowText, QColor( "White" ) );
-    pal.setColor( QPalette::Inactive, QPalette::WindowText, QColor( "White" ) );
-    label->setPalette( pal );
-    label->setAlignment( Qt::AlignHCenter );
-    label->setText( message );
-    topLayout->addWidget( label );
-
-    //initialize the progress message label
-    textCurrentStatus = new QLabel( this ); //reparent to "page" if KDialog
-    textCurrentStatus->setObjectName( "label2" );
-    textCurrentStatus->setPalette( pal );
-    textCurrentStatus->setAlignment( Qt::AlignHCenter );
-    topLayout->addWidget( textCurrentStatus );
-
-    setMessage(QString());  // force repaint of widget with no text
+                      customMessage);
 }
 
 KStarsSplash::~KStarsSplash() {
 }
 
-void KStarsSplash::closeEvent( QCloseEvent *e ) {
-    e->ignore();
-    emit closeWindow();
+void KStarsSplash::setMessage(const QString& message) {
+    showMessage( message, Qt::AlignLeft, Qt::lightGray);
 }
 
-void KStarsSplash::setMessage( const QString &s ) {
-    textCurrentStatus->setText( s );
-    //repaint();  // repaint splash screen  -jbb: this seems no longer needed
-    /**
-    	*Flush all event data. This is needed because events will buffered and
-    	*repaint call will queued in event buffer. With flush all X11 events of
-    	*this application will flushed.
-    	*/
-    //qApp->flush();                       -jbb: this seems no longer needed
-}
-
 #include "kstarssplash.moc"
--- trunk/KDE/kdeedu/kstars/kstars/kstarssplash.h #939306:939307
@@ -23,8 +23,7 @@
 #include <QPaintEvent>
 #include <QCloseEvent>
 
-#include <QDialog>
-//#include <kdialog.h>
+#include <KSplashScreen>
 
 /**@class KStarsSplash
 	*The KStars Splash Screen.  The splash screen shows the KStars logo and 
@@ -36,7 +35,7 @@
 
 class QLabel;
 
-class KStarsSplash : public QDialog
+class KStarsSplash : public KSplashScreen
 {
     Q_OBJECT
 
@@ -44,7 +43,7 @@
     /**Constructor. Create widgets.  Load KStars logo.  Start load timer.
      * A non-empty customMessage will replace "Welcome to KStars [...]".
     */
-    explicit KStarsSplash( QWidget *parent, const QString& customMessage="" );
+    explicit KStarsSplash( const QString& customMessage="" );
 
     /**Destructor
     	*/
@@ -54,18 +53,6 @@
     /**Display the text argument in the Splash Screen's status label.
     	*This is connected to KStarsData::progressText(QString)*/
     void setMessage(const QString &s);
-
-protected:
-    /**If the user clicks on the "X" close-window button, then abort loading
-    	*as soon as possible and shut down the program.
-    	*/
-    void closeEvent( QCloseEvent *e );
-
-signals:
-    void closeWindow();
-
-private:
-    QLabel *textCurrentStatus, *label, *Banner;
 };
 
 #endif
--- trunk/KDE/kdeedu/kstars/kstars/skycomponents/starcomponent.cpp #939306:939307
@@ -151,7 +151,7 @@
 void StarComponent::reindexAll( KSNumbers *num )
 {
     if (  0 && ! m_reindexSplash ) {
-        m_reindexSplash = new KStarsSplash(0,
+        m_reindexSplash = new KStarsSplash(
                                            i18n("Please wait while re-indexing stars ...") );
         QObject::connect( KStarsData::Instance(),
                           SIGNAL( progressText( QString ) ),


More information about the Kstars-devel mailing list