1
//=============================================================================
3
// File : KviSplashScreen.cpp
4
// Creation date : Wed Aug 8 2001 17:46:10 CEST by Szymon Stefanek
6
// This file is part of the KVIrc irc client distribution
7
// Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net)
9
// This program is FREE software. You can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your opinion) any later version.
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.
17
// See the GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program. If not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
//=============================================================================
26
#include "KviCString.h"
27
#include "KviApplication.h"
28
#include "kvi_defaults.h"
29
#include "KviSplashScreen.h"
30
#include "KviLocale.h"
31
#include "KviFileUtils.h"
33
#include <QSplashScreen>
34
#include <QDesktopWidget>
42
KviSplashScreen::KviSplashScreen()
43
: QSplashScreen(QPixmap(1,1),Qt::FramelessWindowHint | Qt::Window | Qt::WindowStaysOnTopHint | Qt::SplashScreen)
48
// check for the current theme splash screen pointer
49
QString szPointerFile;
50
g_pApp->getLocalKvircDirectory(szPointerFile,KviApplication::Themes,"current-splash");
51
if(KviFileUtils::fileExists(szPointerFile))
54
KviFileUtils::readFile(szPointerFile,szBuf);
57
g_pApp->getLocalKvircDirectory(szPix,KviApplication::Themes,szBuf);
58
KviQString::ensureLastCharIs(szPix,KVI_PATH_SEPARATOR_CHAR);
59
szPix.append("kvi_splash.png");
60
pix = new QPixmap(szPix);
67
// else we might have a themed splash screen
68
// g_pApp->getLocalKvircDirectory(szPix,KviApplication::Themes,szBuf);
69
KviQString::ensureLastCharIs(szPix,KVI_PATH_SEPARATOR_CHAR);
70
szPix.append("kvi_splash_overlay.png");
71
m_pOverlay = new QPixmap(szPix);
72
if(m_pOverlay->isNull())
86
if(g_pApp->findImage(szPix,"kvi_splash.png"))
88
pix = new QPixmap(szPix);
91
pix = new QPixmap(300,200);
94
if(g_pApp->findImage(szPix,"kvi_splash_overlay.png"))
96
m_pOverlay = new QPixmap(szPix);
98
m_pOverlay = new QPixmap(300,20);
103
m_pTimer = new QTimer(this);
104
connect(m_pTimer,SIGNAL(timeout()),this,SLOT(suicide()));
110
m_pFadeTimer= new QTimer(this);
111
connect(m_pFadeTimer,SIGNAL(timeout()),this,SLOT(fadeTimerShot()));
112
m_pFadeTimer->start(6);
115
// We don't need messages on the splash: they just add work to the translators and nobody can read them anyway :D
116
//void KviSplashScreen::message(QString szMessage)
118
//QSplashScreen::message(szMessage, Qt::AlignRight | Qt::AlignBottom, Qt::white);
121
KviSplashScreen::~KviSplashScreen()
123
g_pSplashScreen = 0; // make sure it's true
128
void KviSplashScreen::showEvent(QShowEvent *)
130
QRect rect = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen());
131
move((rect.width() - width())/2,(rect.height() - height())/2);
133
m_creationTime = QTime::currentTime();
136
void KviSplashScreen::hideEvent(QHideEvent *)
141
void KviSplashScreen::setProgress(int iProgress)
143
QPixmap slowQt4Copy = pixmap();
144
QPainter painter(&slowQt4Copy);
145
QSize size = slowQt4Copy.size();
146
int iWidth = (m_pOverlay->width() * iProgress) / 100;
147
painter.drawPixmap(0,size.height() - m_pOverlay->height(),iWidth,m_pOverlay->height(),*m_pOverlay,0,0,iWidth,m_pOverlay->height());
149
setPixmap(slowQt4Copy);
153
g_pApp->processEvents(); //damn...
156
void KviSplashScreen::die()
158
m_bIncreasing = false;
159
m_pFadeTimer->start(6);
162
void KviSplashScreen::suicide()
165
return; // already in suicide ?
166
//g_pApp->collectGarbage(this);
172
void KviSplashScreen::fadeTimerShot()
176
m_rTransparency += 0.05;
177
setWindowOpacity(m_rTransparency);
178
if(m_rTransparency>=1)
180
m_pFadeTimer->stop();
181
m_bIncreasing = false;
184
m_rTransparency -= 0.02;
185
setWindowOpacity(m_rTransparency);
186
if(m_rTransparency<=0)
188
m_pFadeTimer->stop();
189
m_bIncreasing = true;
195
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
196
#include "KviSplashScreen.moc"
197
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES