Diffstat (limited to 'noncore/net/wellenreiter/gui/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 89 |
1 files changed, 53 insertions, 36 deletions
diff --git a/noncore/net/wellenreiter/gui/mainwindow.cpp b/noncore/net/wellenreiter/gui/mainwindow.cpp index 69d2b3a..94e3f28 100644 --- a/noncore/net/wellenreiter/gui/mainwindow.cpp +++ b/noncore/net/wellenreiter/gui/mainwindow.cpp @@ -62,10 +62,4 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); - #ifdef QWS - searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); - cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); - #else - startStopIconSet = new QIconSet(); - startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); - startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); - #endif + startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); + stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); @@ -73,15 +67,17 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n - startStopButton = new QToolButton( 0 ); + startButton = new QToolButton( 0 ); #ifdef QWS - startStopButton->setAutoRaise( true ); + startButton->setAutoRaise( true ); #endif + startButton->setIconSet( *startIconSet ); + startButton->setEnabled( false ); + connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); + + stopButton = new QToolButton( 0 ); #ifdef QWS - startStopButton->setOnIconSet( *cancelIconSet ); - startStopButton->setOffIconSet( *searchIconSet ); - #else - startStopButton->setIconSet( *startStopIconSet ); + stopButton->setAutoRaise( true ); #endif - startStopButton->setToggleButton( true ); - connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); - startStopButton->setEnabled( false ); + stopButton->setIconSet( *stopIconSet ); + stopButton->setEnabled( false ); + connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); @@ -127,4 +123,8 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n QPopupMenu* sniffer = new QPopupMenu( mb ); - sniffer->insertItem( "&Configure..." ); + sniffer->insertItem( "&Configure...", this, SLOT( showConfigure() ) ); sniffer->insertSeparator(); + startID = sniffer->insertItem( "&Start", mw, SLOT( startClicked() ) ); + sniffer->setItemEnabled( startID, false ); + stopID = sniffer->insertItem( "Sto&p", mw, SLOT( stopClicked() ) ); + sniffer->setItemEnabled( stopID, false ); @@ -137,3 +137,2 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n id = mb->insertItem( "&Sniffer", sniffer ); - mb->setItemEnabled( id, false ); id = mb->insertItem( "&Demo", demo ); @@ -142,3 +141,4 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n #ifdef QWS - mb->insertItem( startStopButton ); + mb->insertItem( startButton ); + mb->insertItem( stopButton ); mb->insertItem( c ); @@ -148,5 +148,8 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n mb->insertItem( c ); - mb->insertItem( startStopButton ); + mb->insertItem( stopButton ); + mb->insertItem( startButton ); #endif + updateToolButtonState(); + // setup status bar (for now only on X11) @@ -157,4 +160,8 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n + connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); + connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); }; + + void WellenreiterMainWindow::showConfigure() @@ -168,6 +175,9 @@ void WellenreiterMainWindow::showConfigure() - if ( result ) - { - // check configuration from config window + if ( result ) updateToolButtonState(); +} + + +void WellenreiterMainWindow::updateToolButtonState() +{ const QString& interface = cw->interfaceName->currentText(); @@ -177,7 +187,10 @@ void WellenreiterMainWindow::showConfigure() if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) - startStopButton->setEnabled( true ); - //TODO ... + { + startButton->setEnabled( true ); + menuBar()->setItemEnabled( startID, true ); + } else - startStopButton->setEnabled( false ); - //TODO ... + { + startButton->setEnabled( false ); + menuBar()->setItemEnabled( startID, false ); } @@ -185,14 +198,18 @@ void WellenreiterMainWindow::showConfigure() -WellenreiterMainWindow::~WellenreiterMainWindow() + +void WellenreiterMainWindow::changedSniffingState() { + startButton->setEnabled( !mw->sniffing ); + menuBar()->setItemEnabled( startID, !mw->sniffing ); + stopButton->setEnabled( mw->sniffing ); + menuBar()->setItemEnabled( stopID, mw->sniffing ); +} + +WellenreiterMainWindow::~WellenreiterMainWindow() +{ delete infoIconSet; delete settingsIconSet; - #ifdef QWS - delete searchIconSet; - delete cancelIconSet; - #else - delete startStopIconSet; - #endif - + delete startIconSet; + delete stopIconSet; }; |