moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / kstarssplash.cpp
blob463f38a3db25b9d88ac35d25bca6cf366b471ed3
1 /***************************************************************************
2 kstarssplash.cpp - description
3 -------------------
4 begin : Thu Jul 26 2001
5 copyright : (C) 2001 by Heiko Evermann
6 email : heiko@evermann.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
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. *
15 * *
16 ***************************************************************************/
18 #include <qfile.h>
19 #include <qlabel.h>
20 #include <qlayout.h>
21 #include <klocale.h>
23 #include <kapplication.h>
25 #include "kstarssplash.h"
26 #include "ksutils.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.
41 QFile imFile;
42 if ( KSUtils::openDataFile( imFile, "kstars.png" ) ) {
43 imFile.close(); //Just need the filename...
44 splashImage = new QPixmap( imFile.name() );
45 } else {
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();
73 disableResize();
74 setMessage(QString::null); // force repaint of widget with no text
77 KStarsSplash::~KStarsSplash() {
78 delete splashImage;
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 ) {
88 e->ignore();
89 emit closeWindow();
92 void KStarsSplash::setMessage( QString s ) {
93 textCurrentStatus->setText( s );
94 repaint(); // repaint splash screen
95 /**
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.
100 kapp->flush();
103 #include "kstarssplash.moc"