1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/***************************************************************************
kstarssplash.cpp - description
-------------------
begin : Thu Jul 26 2001
copyright : (C) 2001 by Heiko Evermann
email : heiko@evermann.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <tqfile.h>
#include <tqlabel.h>
#include <tqlayout.h>
#include <klocale.h>
#include <kapplication.h>
#include "kstarssplash.h"
#include "ksutils.h"
KStarsSplash::KStarsSplash( TQWidget *parent, const char* name )
: KDialogBase( KDialogBase::Plain, i18n( "Loading KStars..." ),
0 /*no buttons*/, Ok, parent, name, false /*not modal*/ ) {
//Set up widgets for splashscreen.
TQFrame *page = plainPage();
page->setBackgroundColor( TQColor( "Black" ) );
setBackgroundColor( TQColor( "Black" ) );
TQVBoxLayout *topLayout = new TQVBoxLayout( page, 0, 0 );
topLayout->setMargin( 0 );
//Load the KStars banner. Use an empty image if it can't be opened.
TQFile imFile;
if ( KSUtils::openDataFile( imFile, "kstars.png" ) ) {
imFile.close(); //Just need the filename...
splashImage = new TQPixmap( imFile.name() );
} else {
splashImage = new TQPixmap(); //null image
}
Banner = new TQWidget( page );
Banner->setFixedWidth( splashImage->width() );
Banner->setFixedHeight( splashImage->height() );
topLayout->addWidget( Banner );
//initialize the "Welcome to KStars message label
label = new TQLabel( page, "label1" );
TQPalette pal( label->palette() );
pal.setColor( TQPalette::Normal, TQColorGroup::Background, TQColor( "Black" ) );
pal.setColor( TQPalette::Inactive, TQColorGroup::Background, TQColor( "Black" ) );
pal.setColor( TQPalette::Normal, TQColorGroup::Foreground, TQColor( "White" ) );
pal.setColor( TQPalette::Inactive, TQColorGroup::Foreground, TQColor( "White" ) );
label->setPalette( pal );
label->tqsetAlignment( AlignHCenter );
label->setText( i18n( "Welcome to KStars. Please stand by while loading..." ) );
topLayout->addWidget( label );
//initialize the progress message label
textCurrenttqStatus = new TQLabel( page, "label2" );
textCurrenttqStatus->setPalette( pal );
textCurrenttqStatus->tqsetAlignment( AlignHCenter );
topLayout->addWidget( textCurrenttqStatus );
topLayout->activate();
disableResize();
setMessage(TQString()); // force tqrepaint of widget with no text
}
KStarsSplash::~KStarsSplash() {
delete splashImage;
}
void KStarsSplash::paintEvent( TQPaintEvent* ) {
bitBlt( Banner, 0, 0, splashImage, 0, 0, -1, -1 );
label->tqrepaint(); // standard text label
textCurrenttqStatus->tqrepaint(); // status text label
}
void KStarsSplash::closeEvent( TQCloseEvent *e ) {
e->ignore();
emit closeWindow();
}
void KStarsSplash::setMessage( TQString s ) {
textCurrenttqStatus->setText( s );
tqrepaint(); // tqrepaint splash screen
/**
*Flush all event data. This is needed because events will buffered and
*tqrepaint call will queued in event buffer. With flush all X11 events of
*this application will flushed.
*/
kapp->flush();
}
#include "kstarssplash.moc"
|