Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index ba1119e..4aca526 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp @@ -12,14 +12,16 @@ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ /* LOCAL */ #include "configwindow.h" +#include "mainwindow.h" /* QT */ +#include <qapplication.h> #include <qcombobox.h> #include <qfile.h> #include <qlayout.h> #include <qmap.h> #include <qpushbutton.h> #include <qspinbox.h> @@ -30,17 +32,18 @@ WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) :WellenreiterConfigBase( parent, name, true, f ) { - _devicetype[ "cisco" ] = 1; - _devicetype[ "wlan-ng" ] = 2; - _devicetype[ "hostap" ] = 3; - _devicetype[ "orinoco" ] = 4; - _devicetype[ "<manual>" ] = 5; + _devicetype[ "cisco" ] = DEVTYPE_CISCO; + _devicetype[ "wlan-ng" ] = DEVTYPE_WLAN_NG; + _devicetype[ "hostap" ] = DEVTYPE_HOSTAP; + _devicetype[ "orinoco" ] = DEVTYPE_ORINOCO; + _devicetype[ "<manual>" ] = DEVTYPE_MANUAL; + _devicetype[ "<file>" ] = DEVTYPE_FILE; // gather possible interface names from ONetwork ONetwork* net = ONetwork::instance(); ONetwork::InterfaceIterator it = net->iterator(); while ( it.current() ) { @@ -56,34 +59,38 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char int devicetype(0); QString line; QTextStream modules( &m ); while( !modules.atEnd() && !devicetype ) { modules >> line; - if ( line.contains( "cisco" ) ) devicetype = 1; - else if ( line.contains( "hostap" ) ) devicetype = 3; - else if ( line.contains( "prism" ) ) devicetype = 2; - else if ( line.contains( "orinoco" ) ) devicetype = 4; + if ( line.contains( "cisco" ) ) devicetype = DEVTYPE_CISCO; + else if ( line.contains( "hostap" ) ) devicetype = DEVTYPE_HOSTAP; + else if ( line.contains( "prism" ) ) devicetype = DEVTYPE_WLAN_NG; + else if ( line.contains( "orinoco" ) ) devicetype = DEVTYPE_ORINOCO; } if ( devicetype ) { deviceType->setCurrentItem( devicetype ); - qDebug( "Wellenreiter: guessed device type to be %d", devicetype ); + _guess = devicetype; + qDebug( "Wellenreiter: guessed device type to be #%d", devicetype ); } } #ifdef Q_WS_X11 // We're on X11: adding an Ok-Button for the Dialog here QPushButton* okButton = new QPushButton( "ok", this ); okButton->show(); Layout5_2->addWidget( okButton, 0, 3 ); //FIXME: rename this in configbase.ui connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); #endif WellenreiterConfigWindow::_instance = this; + + connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); }; + int WellenreiterConfigWindow::daemonDeviceType() { QString name = deviceType->currentText(); if ( _devicetype.contains( name ) ) { return _devicetype[name]; @@ -91,10 +98,29 @@ int WellenreiterConfigWindow::daemonDeviceType() else { return 0; } }; + int WellenreiterConfigWindow::daemonHopInterval() { return hopInterval->cleanText().toInt(); } + + +void WellenreiterConfigWindow::changedDeviceType(int t) +{ + if ( t != DEVTYPE_FILE ) return; + QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(false); + if ( !name.isNull() && QFile::exists( name ) ) + { + interfaceName->insertItem( name ); + interfaceName->setCurrentItem( interfaceName->count()-1 ); + } + else + { + deviceType->setCurrentItem( _guess ); + } + +} + |