1
/* ============================================================
2
* Author: Renchi Raju <renchi@pooh.tam.uiuc.edu>
6
* Copyright 2003 by Renchi Raju
8
* This program is free software; you can redistribute it
9
* and/or modify it under the terms of the GNU General
10
* Public License as published by the Free Software Foundation;
11
* either version 2, or (at your option)
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* ============================================================ */
23
#include <qapplication.h>
28
#include <kstandarddirs.h>
29
#include <kglobalsettings.h>
31
#include "splashscreen.h"
34
SplashScreen::SplashScreen()
35
: QWidget(0, 0, WStyle_Customize|WStyle_Splash)
40
QString file = locate( "appdata", "digikam-splash.png" );
42
pix_ = new QPixmap(file);
44
setErasePixmap( *pix_ );
45
resize( pix_->size() );
46
QRect scr = QApplication::desktop()->screenGeometry();
47
move( scr.center() - rect().center() );
54
connect(timer_, SIGNAL(timeout()),
55
this, SLOT(slotClose()));
56
timer_->start(1000, true);
59
SplashScreen::~SplashScreen()
66
void qt_wait_for_window_manager( QWidget *widget );
69
void SplashScreen::finish( QWidget *mainWin )
72
qt_wait_for_window_manager( mainWin );
78
void SplashScreen::repaint()
82
QApplication::flush();
85
void SplashScreen::mousePressEvent( QMouseEvent * )
90
void SplashScreen::slotClose()
93
timer_->start(500, true);
97
if (timer_->isActive()) return;
101
void SplashScreen::message(const QString &message, int alignment,
102
const QColor &color )
104
currStatus_ = message;
105
currAlign_ = alignment;
111
void SplashScreen::animate()
113
currState_ = ((currState_ + 1) % (2*progressBarSize_-1));
117
void SplashScreen::drawContents()
119
QPixmap textPix = *pix_;
120
QPainter painter(&textPix, this);
121
drawContents(&painter);
122
setErasePixmap(textPix);
125
void SplashScreen::drawContents( QPainter *painter )
128
QColor basecolor (155, 192, 231);
130
// Draw background circles
131
painter->setPen(NoPen);
132
painter->setBrush(QColor(225,234,231));
133
painter->drawEllipse(21,7,9,9);
134
painter->drawEllipse(32,7,9,9);
135
painter->drawEllipse(43,7,9,9);
137
// Draw animated circles, increments are chosen
138
// to get close to background's color
139
// (didn't work well with QColor::light function)
140
for (int i=0; i < progressBarSize_; i++)
142
position = (currState_+i)%(2*progressBarSize_-1);
145
painter->setBrush(QColor(basecolor.red()-18*i,
146
basecolor.green()-28*i,
147
basecolor.blue()-10*i));
148
painter->drawEllipse(21+position*11,7,9,9);
153
painter->setPen(currColor_);
155
QFont fnt(KGlobalSettings::generalFont());
156
int fntSize = fnt.pointSize();
159
fnt.setPointSize(fntSize-2);
163
fntSize = fnt.pixelSize();
164
fnt.setPixelSize(fntSize-2);
166
painter->setFont(fnt);
169
r.setRect( r.x() + 59, r.y() + 5, r.width() - 10, r.height() - 10 );
170
painter->drawText(r, currAlign_, currStatus_);
173
#include "splashscreen.moc"