1 /***************************************************************************
2 kstarssplash.cpp - description
4 begin : Thu Jul 26 2001
5 copyright : (C) 2001 by Heiko Evermann
6 email : heiko@evermann.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
23 #include <kapplication.h>
25 #include "kstarssplash.h"
28 KStarsSplash::KStarsSplash( QWidget
*parent
, const char* name
)
29 : KDialogBase( KDialogBase::Plain
, i18n( "Loading KStars..." ),
30 0 /*no buttons*/, Ok
, parent
, name
, false /*not modal*/ ) {
32 //Set up widgets for splashscreen.
33 QFrame
*page
= plainPage();
34 page
->setBackgroundColor( QColor( "Black" ) );
35 setBackgroundColor( QColor( "Black" ) );
37 QVBoxLayout
*topLayout
= new QVBoxLayout( page
, 0, 0 );
38 topLayout
->setMargin( 0 );
40 //Load the KStars banner. Use an empty image if it can't be opened.
42 if ( KSUtils::openDataFile( imFile
, "kstars.png" ) ) {
43 imFile
.close(); //Just need the filename...
44 splashImage
= new QPixmap( imFile
.name() );
46 splashImage
= new QPixmap(); //null image
49 Banner
= new QWidget( page
);
50 Banner
->setFixedWidth( splashImage
->width() );
51 Banner
->setFixedHeight( splashImage
->height() );
52 topLayout
->addWidget( Banner
);
54 //initialize the "Welcome to KStars message label
55 label
= new QLabel( page
, "label1" );
56 QPalette
pal( label
->palette() );
57 pal
.setColor( QPalette::Normal
, QColorGroup::Background
, QColor( "Black" ) );
58 pal
.setColor( QPalette::Inactive
, QColorGroup::Background
, QColor( "Black" ) );
59 pal
.setColor( QPalette::Normal
, QColorGroup::Foreground
, QColor( "White" ) );
60 pal
.setColor( QPalette::Inactive
, QColorGroup::Foreground
, QColor( "White" ) );
61 label
->setPalette( pal
);
62 label
->setAlignment( AlignHCenter
);
63 label
->setText( i18n( "Welcome to KStars. Please stand by while loading..." ) );
64 topLayout
->addWidget( label
);
66 //initialize the progress message label
67 textCurrentStatus
= new QLabel( page
, "label2" );
68 textCurrentStatus
->setPalette( pal
);
69 textCurrentStatus
->setAlignment( AlignHCenter
);
70 topLayout
->addWidget( textCurrentStatus
);
72 topLayout
->activate();
74 setMessage(QString::null
); // force repaint of widget with no text
77 KStarsSplash::~KStarsSplash() {
81 void KStarsSplash::paintEvent( QPaintEvent
* ) {
82 bitBlt( Banner
, 0, 0, splashImage
, 0, 0, -1, -1 );
83 label
->repaint(); // standard text label
84 textCurrentStatus
->repaint(); // status text label
87 void KStarsSplash::closeEvent( QCloseEvent
*e
) {
92 void KStarsSplash::setMessage( QString s
) {
93 textCurrentStatus
->setText( s
);
94 repaint(); // repaint splash screen
96 *Flush all event data. This is needed because events will buffered and
97 *repaint call will queued in event buffer. With flush all X11 events of
98 *this application will flushed.
103 #include "kstarssplash.moc"