~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/kvirc/ui/KviSplashScreen.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//=============================================================================
 
2
//
 
3
//   File : KviSplashScreen.cpp
 
4
//   Creation date : Wed Aug 8 2001 17:46:10 CEST by Szymon Stefanek
 
5
//
 
6
//   This file is part of the KVIrc irc client distribution
 
7
//   Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net)
 
8
//
 
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.
 
13
//
 
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.
 
18
//
 
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.
 
22
//
 
23
//=============================================================================
 
24
 
 
25
 
 
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"
 
32
 
 
33
#include <QSplashScreen>
 
34
#include <QDesktopWidget>
 
35
#include <QPixmap>
 
36
#include <QPainter>
 
37
#include <QLayout>
 
38
 
 
39
#include <stdio.h>
 
40
 
 
41
 
 
42
KviSplashScreen::KviSplashScreen()
 
43
: QSplashScreen(QPixmap(1,1),Qt::FramelessWindowHint | Qt::Window | Qt::WindowStaysOnTopHint | Qt::SplashScreen)
 
44
{
 
45
        QString szPix;
 
46
        QPixmap * pix = 0;
 
47
 
 
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))
 
52
        {
 
53
                QString szBuf;
 
54
                KviFileUtils::readFile(szPointerFile,szBuf);
 
55
                if(!szBuf.isEmpty())
 
56
                {
 
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);
 
61
                        if(pix->isNull())
 
62
                        {
 
63
                                // no way..
 
64
                                delete pix;
 
65
                                pix = 0;
 
66
                        } else {
 
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())
 
73
                                {
 
74
                                        // no way..
 
75
                                        delete pix;
 
76
                                        pix = 0;
 
77
                                        delete m_pOverlay;
 
78
                                        m_pOverlay = 0;
 
79
                                }
 
80
                        }
 
81
                }
 
82
        }
 
83
 
 
84
        if(!pix)
 
85
        {
 
86
                if(g_pApp->findImage(szPix,"kvi_splash.png"))
 
87
                {
 
88
                        pix = new QPixmap(szPix);
 
89
                } else {
 
90
                        // dummy image
 
91
                        pix = new QPixmap(300,200);
 
92
                }
 
93
 
 
94
                if(g_pApp->findImage(szPix,"kvi_splash_overlay.png"))
 
95
                {
 
96
                        m_pOverlay = new QPixmap(szPix);
 
97
                } else {
 
98
                        m_pOverlay = new QPixmap(300,20);
 
99
                }
 
100
        }
 
101
 
 
102
        setPixmap(*pix);
 
103
        m_pTimer = new QTimer(this);
 
104
        connect(m_pTimer,SIGNAL(timeout()),this,SLOT(suicide()));
 
105
        delete pix;
 
106
 
 
107
        setWindowOpacity(0);
 
108
        m_bIncreasing=true;
 
109
        m_rTransparency=0;
 
110
        m_pFadeTimer= new QTimer(this);
 
111
        connect(m_pFadeTimer,SIGNAL(timeout()),this,SLOT(fadeTimerShot()));
 
112
        m_pFadeTimer->start(6);
 
113
}
 
114
 
 
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)
 
117
//{
 
118
        //QSplashScreen::message(szMessage, Qt::AlignRight | Qt::AlignBottom, Qt::white);
 
119
//}
 
120
 
 
121
KviSplashScreen::~KviSplashScreen()
 
122
{
 
123
        g_pSplashScreen = 0; // make sure it's true
 
124
        delete m_pTimer;
 
125
        delete m_pOverlay;
 
126
}
 
127
 
 
128
void KviSplashScreen::showEvent(QShowEvent *)
 
129
{
 
130
        QRect rect = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen());
 
131
        move((rect.width() - width())/2,(rect.height() - height())/2);
 
132
 
 
133
        m_creationTime = QTime::currentTime();
 
134
}
 
135
 
 
136
void KviSplashScreen::hideEvent(QHideEvent *)
 
137
{
 
138
        suicide();
 
139
}
 
140
 
 
141
void KviSplashScreen::setProgress(int iProgress)
 
142
{
 
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());
 
148
        painter.end();
 
149
        setPixmap(slowQt4Copy);
 
150
 
 
151
        //raise();
 
152
        repaint();
 
153
        g_pApp->processEvents(); //damn...
 
154
}
 
155
 
 
156
void KviSplashScreen::die()
 
157
{
 
158
        m_bIncreasing = false;
 
159
        m_pFadeTimer->start(6);
 
160
}
 
161
 
 
162
void KviSplashScreen::suicide()
 
163
{
 
164
        if(!g_pSplashScreen)
 
165
                return; // already in suicide ?
 
166
        //g_pApp->collectGarbage(this);
 
167
        g_pSplashScreen = 0;
 
168
        deleteLater();
 
169
        //delete this;
 
170
}
 
171
 
 
172
void KviSplashScreen::fadeTimerShot()
 
173
{
 
174
        if(m_bIncreasing)
 
175
        {
 
176
                m_rTransparency += 0.05;
 
177
                setWindowOpacity(m_rTransparency);
 
178
                if(m_rTransparency>=1)
 
179
                {
 
180
                        m_pFadeTimer->stop();
 
181
                        m_bIncreasing = false;
 
182
                }
 
183
        } else {
 
184
                m_rTransparency -= 0.02;
 
185
                setWindowOpacity(m_rTransparency);
 
186
                if(m_rTransparency<=0)
 
187
                {
 
188
                        m_pFadeTimer->stop();
 
189
                        m_bIncreasing = true;
 
190
                        suicide();
 
191
                }
 
192
        }
 
193
}
 
194
 
 
195
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
 
196
#include "KviSplashScreen.moc"
 
197
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES