summaryrefslogtreecommitdiffstats
path: root/ksquirrel/sq_splashscreen.cpp
blob: 9b9b0b09229689cbb25f7b02b12efc29364922f2 (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
105
106
107
/*
 *  (C) 2006 Baryshev Dmitry, KSquirrel project.
 *  Originally based on kstartuplogo.cpp from KDEvelop project
 */

/***************************************************************************
                           kstartuplogo.cpp  -  description
                             -------------------
    artwork              : KDevelop Project / Ralf Nolden <nolden@kde.org>
    begin                : Mon Oct 1 2001
    copyright            : (C) 2001 by Kai Heitkamp
    email                : koncd@kai-heitkamp.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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful, but   *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      *
 *   General Public License for more details.                              *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the Free Software           *
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301   *
 *   USA.                                                                  *
 *                                                                         *
 *   For license exceptions see LICENSE.EXC file, attached with the source *
 *   code.                                                                 *
 *                                                                         *
 ***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <kglobalsettings.h>
#include <kstandarddirs.h>
#include <kprogress.h>
#include <kdebug.h>

#include "sq_splashscreen.h"
#include "sq_progress.h"

SQ_SplashScreen * SQ_SplashScreen::m_inst = 0;

SQ_SplashScreen::SQ_SplashScreen(TQWidget * parent, const char *name) 
    : TQWidget(parent, name,
                        TQt::WStyle_Customize |
                        TQt::WStyle_NoBorder |
                        TQt::WStyle_StaysOnTop |
                        TQt::WDestructiveClose |
                        TQt::WX11BypassWM)
{
    kdDebug() << "+SQ_SplashScreen" << endl;

    m_inst = this;

    TQPixmap pix = TQPixmap(locate("data", "images/splash.png"));

    setPaletteBackgroundPixmap(pix);

    TQRect rc = KGlobalSettings::splashScreenDesktopGeometry();

    move(rc.center().x() - pix.width()/2, rc.center().y() - pix.height()/2);
    setFixedWidth(pix.width());
    setFixedHeight(pix.height());

    pr = new SQ_Progress(this);
    pr->setGeometry(201, 255, 162, 14);
    pr->setShowText(false);
    pr->setColor(TQColor(170,100,110));
    pr->setTotalSteps(10);
}

SQ_SplashScreen::~SQ_SplashScreen()
{
    kdDebug() << "-SQ_SplashScreen" << endl;

    m_inst = 0;
}

void SQ_SplashScreen::finish()
{
    if(SQ_SplashScreen::instance())
    {
        SQ_SplashScreen::instance()->progress()->flush();
        SQ_SplashScreen::instance()->close();
    }
}

void SQ_SplashScreen::mousePressEvent(TQMouseEvent *e)
{
    e->accept();

    hide();
}

void SQ_SplashScreen::advance()
{
    if(SQ_SplashScreen::instance())
        SQ_SplashScreen::instance()->progress()->advance();
}