~ubuntu-branches/ubuntu/breezy/kdemultimedia/breezy

« back to all changes in this revision

Viewing changes to juk/splashscreen.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-03-24 04:48:58 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050324044858-8ff88o9jxej6ii3d
Tags: 4:3.4.0-0ubuntu3
Add kubuntu_02_hide_arts_menu_entries.diff to hide artsbuilder and artscontrol k-menu entries

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    begin                : Sun Dec 8 2002
 
3
    copyright            : (C) 2002 - 2004 by Scott Wheeler
 
4
    email                : wheeler@kde.org
 
5
 ***************************************************************************/
 
6
 
 
7
/***************************************************************************
 
8
 *                                                                         *
 
9
 *   This program is free software; you can redistribute it and/or modify  *
 
10
 *   it under the terms of the GNU General Public License as published by  *
 
11
 *   the Free Software Foundation; either version 2 of the License, or     *
 
12
 *   (at your option) any later version.                                   *
 
13
 *                                                                         *
 
14
 ***************************************************************************/
 
15
 
 
16
#include <kapplication.h>
 
17
#include <kiconloader.h>
 
18
#include <klocale.h>
 
19
#include <kdebug.h>
 
20
 
 
21
#include <qlabel.h>
 
22
 
 
23
#include "splashscreen.h"
 
24
 
 
25
SplashScreen *SplashScreen::splash = 0;
 
26
bool SplashScreen::done = false;
 
27
int SplashScreen::count = 0;
 
28
 
 
29
////////////////////////////////////////////////////////////////////////////////
 
30
// pubic members
 
31
////////////////////////////////////////////////////////////////////////////////
 
32
 
 
33
SplashScreen *SplashScreen::instance()
 
34
{
 
35
    if(!splash && !done)
 
36
        splash = new SplashScreen();
 
37
    return splash;
 
38
}
 
39
 
 
40
void SplashScreen::finishedLoading()
 
41
{
 
42
    done = true;
 
43
    delete splash;
 
44
    splash = 0;
 
45
}
 
46
 
 
47
void SplashScreen::increment()
 
48
{
 
49
    if(splash) {
 
50
        count++;
 
51
        if(( count & 63 ) == 0)
 
52
            splash->processEvents();
 
53
    }
 
54
}
 
55
 
 
56
void SplashScreen::update()
 
57
{
 
58
    if(splash)
 
59
        splash->processEvents();
 
60
}
 
61
 
 
62
////////////////////////////////////////////////////////////////////////////////
 
63
// protected members
 
64
////////////////////////////////////////////////////////////////////////////////
 
65
 
 
66
SplashScreen::SplashScreen() : QHBox(0 , "splashScreen", Qt::WStyle_Splash)
 
67
{
 
68
    setMargin(10);
 
69
    setSpacing(5);
 
70
 
 
71
    setLineWidth(5);
 
72
    setFrameShape(Box);
 
73
    setFrameShadow(Plain);
 
74
 
 
75
    QFont font = QWidget::font();
 
76
 
 
77
    if(font.pixelSize() > 0)
 
78
        font.setPixelSize(font.pixelSize() * 2);
 
79
    else
 
80
        font.setPointSize(font.pointSize() * 2);
 
81
 
 
82
    QLabel *iconLabel = new QLabel(this);
 
83
    iconLabel->setPixmap(DesktopIcon("juk"));
 
84
 
 
85
    QLabel *textLabel = new QLabel(i18n("Items loaded:"), this);
 
86
    textLabel->setFont(font);
 
87
 
 
88
    m_countLabel = new QLabel(this);
 
89
    m_countLabel->setText(QString::number(count));
 
90
    m_countLabel->setFont(font);
 
91
    m_countLabel->setMinimumWidth(m_countLabel->fontMetrics().width("00000"));
 
92
 
 
93
    setMaximumWidth(iconLabel->width() + textLabel->width() + m_countLabel->width() + 10);
 
94
    setMaximumHeight(QMAX(iconLabel->height(), textLabel->height()));
 
95
 
 
96
    QDesktopWidget *desktop = KApplication::desktop();
 
97
    QRect r = desktop->screenGeometry(desktop->primaryScreen());
 
98
    setGeometry((r.width() / 2) - (width() / 2), (r.height() / 2) - (height() / 2), width(), height());
 
99
}
 
100
 
 
101
SplashScreen::~SplashScreen()
 
102
{
 
103
 
 
104
}
 
105
 
 
106
////////////////////////////////////////////////////////////////////////////////
 
107
// private methods
 
108
////////////////////////////////////////////////////////////////////////////////
 
109
 
 
110
void SplashScreen::processEvents()
 
111
{
 
112
    m_countLabel->setText(QString::number(count));
 
113
    kapp->processEvents();
 
114
}