~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-12-17 13:42:07 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 dapper)
  • Revision ID: james.westby@ubuntu.com-20051217134207-mo1m08da6szv41u7
Tags: 1.0-1
New upstream release

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