blob: 5f91a070ada7ae77fd9f53d502bec3893153db2d (
plain)
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
104
|
/***************************************************************************
begin : Sun Dec 8 2002
copyright : (C) 2002 - 2004 by Scott Wheeler
email : wheeler@kde.org
***************************************************************************/
/***************************************************************************
* *
* 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 <kapplication.h>
#include <kiconloader.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include <qpainter.h>
#include "splashscreen.h"
SplashScreen *SplashScreen::splash = 0;
bool SplashScreen::done = false;
int SplashScreen::count = 0;
static QString loadedText(int i)
{
static QString loading = i18n("Loading").upper();
return loading + ": " + QString::number(i);;
}
////////////////////////////////////////////////////////////////////////////////
// pubic members
////////////////////////////////////////////////////////////////////////////////
SplashScreen *SplashScreen::instance()
{
if(!splash && !done)
splash = new SplashScreen();
return splash;
}
void SplashScreen::finishedLoading()
{
done = true;
delete splash;
splash = 0;
}
void SplashScreen::increment()
{
if(splash) {
count++;
if(( count & 63 ) == 0)
splash->processEvents();
}
}
void SplashScreen::update()
{
if(splash)
splash->processEvents();
}
////////////////////////////////////////////////////////////////////////////////
// protected members
////////////////////////////////////////////////////////////////////////////////
SplashScreen::SplashScreen() : QLabel(0 , "splashScreen", Qt::WStyle_Splash)
{
QPixmap background = UserIcon("splash");
resize(background.size());
setPaletteBackgroundPixmap(background);
setMargin(7);
setAlignment(AlignLeft | AlignBottom);
setPaletteForegroundColor(QColor(107, 158, 194));
QFont f = font();
f.setPixelSize(10);
setFont(f);
setText(loadedText(0));
}
SplashScreen::~SplashScreen()
{
}
////////////////////////////////////////////////////////////////////////////////
// private methods
////////////////////////////////////////////////////////////////////////////////
void SplashScreen::processEvents()
{
setText(loadedText(count));
kapp->processEvents();
}
|