summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/kmfwidgets/kmfselectinterface.cpp
blob: 4de51cf359db89148276caae3f6a32b3cb02cfad (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
108
109
110
111
112
113
114
115
116
117
//
// C++ Implementation: %{MODULE}
//
// Description:
//
//
// Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR}
//
// Copyright: See COPYING file that comes with this distribution
//
//

#include "kmfselectinterface.h"

//  QT includes
#include <tqlabel.h>
#include <tqcheckbox.h>
#include <tqcolor.h>

// KDE includes
#include <kdebug.h>
#include <kcombobox.h>
#include <kpushbutton.h>
#include <tdeapplication.h>
#include <tdelocale.h>
#include <kstandarddirs.h>
#include <tdeglobal.h>
#include <tdeapplication.h>

// Project Includes
#include "../core/kmfconfig.h"
namespace KMF {
KMFSelectInterface::KMFSelectInterface( TQWidget *parent, const char *name, bool modal, WFlags fl )
		: KMyFirewallSelectInterface( parent, name, modal, fl ) {
	m_cob_interface->setBackgroundMode( PaletteBase, PaletteBase );
//	m_opt_showOnStartup->setBackgroundMode( PaletteButton );
	m_cob_interface->setBackgroundColor( TQColor( 204, 0, 49 ) );
	m_descs << i18n("<qt><p>The generic interface provides an easy-to-use tool for setting up common personal firewalls or simple network routers.</p></qt>");
	m_cob_interface->insertItem( i18n("Generic Interface") );
	m_lbl_descripton->setText( *m_descs.at( 0 ) );
	
	m_descs << i18n("<qt><p>The IPTable interface is meant to be used by advanced users who like to have full control over the rules generated; as such, the IPTables interface provides an almost 1-1 view on your iptables configuration.</p></qt>");
	m_cob_interface->insertItem( i18n("IPTables Interface") );
	TDEStandardDirs dir;
	TQString filename = dir.findResource( "data", "kmyfirewall/pics/kmf_snapshot_generic_interface.png" );
	TQPixmap *p = new TQPixmap( filename );
	m_pic_screenshot->setPixmap( *p );
		
		
		
		
		
		
	connect( m_cob_interface, TQT_SIGNAL( activated( int ) ), this, TQT_SLOT( slotInterfaceChanged( int ) ) );
	connect( m_cmd_ok, TQT_SIGNAL( clicked() ) , this, TQT_SLOT( accept() ) );	
	connect( m_cmd_help, TQT_SIGNAL( clicked() ) , this, TQT_SLOT( help() ) );
	connect( b_close, TQT_SIGNAL( clicked() ) , this, TQT_SLOT( reject() ) );
	
	adjustSize();
}

KMFSelectInterface::~KMFSelectInterface() {}

/*$SPECIALIZATION$*/
void KMFSelectInterface::slotInterfaceChanged( int index ) {
	kdDebug() << "KMFSelectInterface::slotInterfaceChanged( int index )" << endl;
	m_lbl_descripton->setText( *m_descs.at( index ) );
	
	TDEStandardDirs dir;
	TQString filename = "";
	switch ( index ) {
		case 0:
			filename = dir.findResource( "data", "kmyfirewall/pics/kmf_snapshot_generic_interface.png" );
			break;
		case 1:
			filename = dir.findResource( "data", "kmyfirewall/pics/kmf_snapshot_iptables_interface.png" );
			break;
	}
	TQPixmap *p = new TQPixmap( filename );
	m_pic_screenshot->setPixmap( *p );
}

void KMFSelectInterface::accept() {
	kdDebug() << "KMFSelectInterface::accept()" << endl;
	kdDebug() << "Found item: " << m_cob_interface->currentItem() << endl;
	switch ( m_cob_interface->currentItem() ) {
		case 0:
			KMFConfig::setUseGenericInterface( true );
// 			Config().m_useGenericInterface = true;
			break;
		case 1:
			KMFConfig::setUseGenericInterface( false );
// 			Config().m_useGenericInterface = false;
			break;
		default:
			KMFConfig::setUseGenericInterface( true );
// 			Config().m_useGenericInterface = true;	
	}
	KMFConfig::setShowSelInterface( ! m_opt_showOnStartup->isChecked() );
// 	Config().m_show_selInterface = ! m_opt_showOnStartup->isChecked();
// 	Config().write();
	KMFConfig::self()->writeConfig();
	TQDialog::accept();
}

void KMFSelectInterface::help() {
	kapp->invokeHelp( "gui_interfaces" );
}

void KMFSelectInterface::reject(){
	TQDialog::reject();
}

}

#include "kmfselectinterface.moc"