summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/core/kmfapp.cpp
blob: f0349f65855f014ee2e28a80e18dda7bca431eb0 (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
/***************************************************************************
   begin                : Fri Feb 21 2003
   copyright            : (C) 2003 by Christian Hubinger
   email                : chubinger@irrsinnig.org
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/


// QT includes
#include <tqlabel.h>
#include <tqpainter.h>
#include <tqfont.h>
#include <tqwidget.h>

// KDE includes
#include <kstandarddirs.h>
#include <kdebug.h>
#include <tdeglobalsettings.h>
#include <kurl.h>
#include <tdefiledialog.h>
// Project includes
#include "kmfapp.h"
#include "../version.h"


namespace KMF {

KMFApp::KMFApp() {}
KMFApp::~KMFApp() {}

static TQLabel *splash = 0;

void set_splash_status( const TQString& msg ) {
	if ( !splash )
		return ;
	splash->repaint( FALSE );
	TQPainter p( splash );
	TQFont f( TDEGlobalSettings::generalFont().family(), 8, TQFont::Bold );
	p.setFont( f );
	p.setPen( TQt::white );
	p.drawText( splash->width() / 2 - splash->fontMetrics().width( msg ) / 2, 265, msg );
	TQApplication::flush();
}

void showSplash() {
	TQRect screen = TQApplication::desktop() ->screenGeometry();
	TQRect mainRect;
	screen = TQApplication::desktop() ->screenGeometry( TQApplication::desktop() ->screenNumber( mainRect.center() ) );

	bool show = true;
	if ( show ) {
		TDEStandardDirs std_dir;
		TQString dir = std_dir.findResource( "data", "kmyfirewall/pics/splash.png" );
		kdDebug() << "\nFound Splashscreen at: " << dir << endl;

		TQPixmap pic = TQPixmap::fromMimeSource( dir );
		TQFont f( TDEGlobalSettings::generalFont().family(), 8, TQFont::Bold );
		if ( pic.isNull() )
			return ;
		TQPainter p( &pic );
		p.setFont( f );
		p.setPen( TQt::white );
		p.drawText( 280, 93, TQString( "Version %1" ).arg( KMYFIREWALL_VERSION ) );
		splash = new TQLabel( 0, "splash", TQWidget::WDestructiveClose | TQWidget::WStyle_Customize | TQWidget::WStyle_NoBorder | TQWidget::WX11BypassWM | TQWidget::WStyle_StaysOnTop );
		splash->setFrameStyle( TQFrame::WinPanel | TQFrame::Raised );
		splash->setPixmap( pic );
		splash->adjustSize();
		splash->setFixedSize( splash->sizeHint() );
		splash->move( screen.center() - TQPoint( splash->width() / 2, splash->height() / 2 ) );
		splash->repaint( FALSE );
		splash->show();
		set_splash_status( "Initializing..." );
		TQApplication::flush();
	}
}

void closeSplash() {
	if ( splash ) {
		splash->close();
		splash = 0;
	}
}

}