~ubuntu-branches/ubuntu/karmic/kmyfirewall/karmic

« back to all changes in this revision

Viewing changes to kmyfirewall/kmfapp.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Gonzalez Iniesta
  • Date: 2005-01-04 20:17:02 UTC
  • Revision ID: james.westby@ubuntu.com-20050104201702-s1vo6slsg4f3jb11
Tags: upstream-0.9.6.2
ImportĀ upstreamĀ versionĀ 0.9.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                          kmfapp.cpp  -  description
 
3
                             -------------------
 
4
    begin                : Fri Feb 21 2003
 
5
    copyright            : (C) 2003 by animal
 
6
    email                : animal@shit
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
11
 *   This program is free software; you can redistribute it and/or modify  *
 
12
 *   it under the terms of the GNU General Public License as published by  *
 
13
 *   the Free Software Foundation; either version 2 of the License, or     *
 
14
 *   (at your option) any later version.                                   *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
 
 
18
#include "kmfapp.h"
 
19
#include "version.h"
 
20
#include "kstandarddirs.h"
 
21
#include "kdebug.h"
 
22
#include <kglobalsettings.h>
 
23
 
 
24
#include <qlabel.h>
 
25
#include <qpainter.h>
 
26
#include <qfont.h>
 
27
#include <qwidget.h>
 
28
 
 
29
 
 
30
KMFApp::KMFApp(){
 
31
}
 
32
KMFApp::~KMFApp(){
 
33
}
 
34
 
 
35
static QLabel *splash = 0;
 
36
 
 
37
void set_splash_status( const QString& msg ) {
 
38
        if ( !splash )
 
39
                return;
 
40
        splash->repaint( FALSE );
 
41
        QPainter p( splash );
 
42
  QFont f( KGlobalSettings::generalFont().family(), 8, QFont::Bold );
 
43
  p.setFont( f );
 
44
  p.setPen( Qt::white );
 
45
        p.drawText( splash->width()/2 - splash->fontMetrics().width( msg )/2, 265, msg );
 
46
        QApplication::flush();
 
47
}
 
48
 
 
49
void showSplash() {
 
50
        QRect screen = QApplication::desktop()->screenGeometry();
 
51
        QRect mainRect;
 
52
        screen = QApplication::desktop()->screenGeometry( QApplication::desktop()->screenNumber( mainRect.center() ) );
 
53
 
 
54
        bool show = true;
 
55
        if ( show ) {
 
56
    // FIXME: need to get real path from system !!!
 
57
    KStandardDirs std_dir;
 
58
    QString dir = std_dir.findResource("data","kmyfirewall/pics/splash.png");
 
59
    kdDebug() << "\nFound Splashscreen at: " << dir << endl;
 
60
 
 
61
    QPixmap pic = QPixmap::fromMimeSource( dir );
 
62
    QFont f( KGlobalSettings::generalFont().family(), 8, QFont::Bold );
 
63
    if ( pic.isNull() )
 
64
                        return;
 
65
                QPainter p( &pic );
 
66
                p.setFont( f );
 
67
                p.setPen( Qt::white );
 
68
                p.drawText( 280, 93, QString("Version %1").arg(KMYFIREWALL_VERSION) );
 
69
                splash = new QLabel( 0, "splash", QWidget::WDestructiveClose | QWidget::WStyle_Customize | QWidget::WStyle_NoBorder | QWidget::WX11BypassWM | QWidget::WStyle_StaysOnTop );
 
70
                splash->setFrameStyle( QFrame::WinPanel | QFrame::Raised );
 
71
                splash->setPixmap( pic );
 
72
                splash->adjustSize();
 
73
                splash->setFixedSize(splash->sizeHint());
 
74
                splash->move( screen.center() - QPoint( splash->width() / 2, splash->height() / 2 ) );
 
75
                splash->repaint( FALSE );
 
76
                splash->show();
 
77
                set_splash_status( "Initializing..." );
 
78
                QApplication::flush();
 
79
        }
 
80
}
 
81
 
 
82
void closeSplash() {
 
83
  if ( splash ) {
 
84
                splash->close();
 
85
                splash = 0;
 
86
        }
 
87
}
 
88
 
 
89
 
 
90