Diffstat (limited to 'noncore/net/wellenreiter/gui/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/mainwindow.cpp | 99 |
1 files changed, 58 insertions, 41 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 | |||
@@ -61,28 +61,24 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
61 | infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); | 61 | infoIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/InfoIcon" ) ); |
62 | settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); | 62 | settingsIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SettingsIcon" ) ); |
63 | #ifdef QWS | 63 | startIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); |
64 | searchIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/SearchIcon" ) ); | 64 | stopIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); |
65 | cancelIconSet = new QIconSet( Resource::loadPixmap( "wellenreiter/CancelIcon" ) ); | ||
66 | #else | ||
67 | startStopIconSet = new QIconSet(); | ||
68 | startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/SearchIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::Off ); | ||
69 | startStopIconSet->setPixmap( Resource::loadPixmap( "wellenreiter/CancelIcon" ), QIconSet::Automatic, QIconSet::Normal, QIconSet::On ); | ||
70 | #endif | ||
71 | 65 | ||
72 | // setup tool buttons | 66 | // setup tool buttons |
73 | 67 | ||
74 | startStopButton = new QToolButton( 0 ); | 68 | startButton = new QToolButton( 0 ); |
75 | #ifdef QWS | 69 | #ifdef QWS |
76 | startStopButton->setAutoRaise( true ); | 70 | startButton->setAutoRaise( true ); |
77 | #endif | 71 | #endif |
72 | startButton->setIconSet( *startIconSet ); | ||
73 | startButton->setEnabled( false ); | ||
74 | connect( startButton, SIGNAL( clicked() ), mw, SLOT( startClicked() ) ); | ||
75 | |||
76 | stopButton = new QToolButton( 0 ); | ||
78 | #ifdef QWS | 77 | #ifdef QWS |
79 | startStopButton->setOnIconSet( *cancelIconSet ); | 78 | stopButton->setAutoRaise( true ); |
80 | startStopButton->setOffIconSet( *searchIconSet ); | ||
81 | #else | ||
82 | startStopButton->setIconSet( *startStopIconSet ); | ||
83 | #endif | 79 | #endif |
84 | startStopButton->setToggleButton( true ); | 80 | stopButton->setIconSet( *stopIconSet ); |
85 | connect( startStopButton, SIGNAL( clicked() ), mw, SLOT( startStopClicked() ) ); | 81 | stopButton->setEnabled( false ); |
86 | startStopButton->setEnabled( false ); | 82 | connect( stopButton, SIGNAL( clicked() ), mw, SLOT( stopClicked() ) ); |
87 | 83 | ||
88 | QToolButton* c = new QToolButton( 0 ); | 84 | QToolButton* c = new QToolButton( 0 ); |
@@ -126,6 +122,10 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
126 | 122 | ||
127 | QPopupMenu* sniffer = new QPopupMenu( mb ); | 123 | QPopupMenu* sniffer = new QPopupMenu( mb ); |
128 | sniffer->insertItem( "&Configure..." ); | 124 | sniffer->insertItem( "&Configure...", this, SLOT( showConfigure() ) ); |
129 | sniffer->insertSeparator(); | 125 | sniffer->insertSeparator(); |
126 | startID = sniffer->insertItem( "&Start", mw, SLOT( startClicked() ) ); | ||
127 | sniffer->setItemEnabled( startID, false ); | ||
128 | stopID = sniffer->insertItem( "Sto&p", mw, SLOT( stopClicked() ) ); | ||
129 | sniffer->setItemEnabled( stopID, false ); | ||
130 | 130 | ||
131 | QPopupMenu* demo = new QPopupMenu( mb ); | 131 | QPopupMenu* demo = new QPopupMenu( mb ); |
@@ -136,10 +136,10 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
136 | mb->setItemEnabled( id, false ); | 136 | mb->setItemEnabled( id, false ); |
137 | id = mb->insertItem( "&Sniffer", sniffer ); | 137 | id = mb->insertItem( "&Sniffer", sniffer ); |
138 | mb->setItemEnabled( id, false ); | ||
139 | id = mb->insertItem( "&Demo", demo ); | 138 | id = mb->insertItem( "&Demo", demo ); |
140 | mb->setItemEnabled( id, true ); | 139 | mb->setItemEnabled( id, true ); |
141 | 140 | ||
142 | #ifdef QWS | 141 | #ifdef QWS |
143 | mb->insertItem( startStopButton ); | 142 | mb->insertItem( startButton ); |
143 | mb->insertItem( stopButton ); | ||
144 | mb->insertItem( c ); | 144 | mb->insertItem( c ); |
145 | mb->insertItem( d ); | 145 | mb->insertItem( d ); |
@@ -147,7 +147,10 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
147 | mb->insertItem( d ); | 147 | mb->insertItem( d ); |
148 | mb->insertItem( c ); | 148 | mb->insertItem( c ); |
149 | mb->insertItem( startStopButton ); | 149 | mb->insertItem( stopButton ); |
150 | mb->insertItem( startButton ); | ||
150 | #endif | 151 | #endif |
151 | 152 | ||
153 | updateToolButtonState(); | ||
154 | |||
152 | // setup status bar (for now only on X11) | 155 | // setup status bar (for now only on X11) |
153 | 156 | ||
@@ -156,6 +159,10 @@ WellenreiterMainWindow::WellenreiterMainWindow( QWidget * parent, const char * n | |||
156 | #endif | 159 | #endif |
157 | 160 | ||
161 | connect( mw, SIGNAL( startedSniffing() ), this, SLOT( changedSniffingState() ) ); | ||
162 | connect( mw, SIGNAL( stoppedSniffing() ), this, SLOT( changedSniffingState() ) ); | ||
158 | }; | 163 | }; |
159 | 164 | ||
165 | |||
166 | |||
160 | void WellenreiterMainWindow::showConfigure() | 167 | void WellenreiterMainWindow::showConfigure() |
161 | { | 168 | { |
@@ -167,33 +174,43 @@ void WellenreiterMainWindow::showConfigure() | |||
167 | int result = cw->exec(); | 174 | int result = cw->exec(); |
168 | 175 | ||
169 | if ( result ) | 176 | if ( result ) updateToolButtonState(); |
170 | { | 177 | } |
171 | // check configuration from config window | ||
172 | 178 | ||
173 | const QString& interface = cw->interfaceName->currentText(); | ||
174 | const int cardtype = cw->daemonDeviceType(); | ||
175 | const int interval = cw->daemonHopInterval(); | ||
176 | 179 | ||
177 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | 180 | |
178 | startStopButton->setEnabled( true ); | 181 | void WellenreiterMainWindow::updateToolButtonState() |
179 | //TODO ... | 182 | { |
180 | else | 183 | const QString& interface = cw->interfaceName->currentText(); |
181 | startStopButton->setEnabled( false ); | 184 | const int cardtype = cw->daemonDeviceType(); |
182 | //TODO ... | 185 | const int interval = cw->daemonHopInterval(); |
186 | |||
187 | if ( ( interface != "<select>" ) && ( cardtype != 0 ) ) | ||
188 | { | ||
189 | startButton->setEnabled( true ); | ||
190 | menuBar()->setItemEnabled( startID, true ); | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | startButton->setEnabled( false ); | ||
195 | menuBar()->setItemEnabled( startID, false ); | ||
183 | } | 196 | } |
184 | } | 197 | } |
185 | 198 | ||
186 | WellenreiterMainWindow::~WellenreiterMainWindow() | 199 | |
200 | void WellenreiterMainWindow::changedSniffingState() | ||
187 | { | 201 | { |
202 | startButton->setEnabled( !mw->sniffing ); | ||
203 | menuBar()->setItemEnabled( startID, !mw->sniffing ); | ||
204 | stopButton->setEnabled( mw->sniffing ); | ||
205 | menuBar()->setItemEnabled( stopID, mw->sniffing ); | ||
206 | } | ||
188 | 207 | ||
208 | |||
209 | WellenreiterMainWindow::~WellenreiterMainWindow() | ||
210 | { | ||
189 | delete infoIconSet; | 211 | delete infoIconSet; |
190 | delete settingsIconSet; | 212 | delete settingsIconSet; |
191 | #ifdef QWS | 213 | delete startIconSet; |
192 | delete searchIconSet; | 214 | delete stopIconSet; |
193 | delete cancelIconSet; | ||
194 | #else | ||
195 | delete startStopIconSet; | ||
196 | #endif | ||
197 | |||
198 | }; | 215 | }; |
199 | 216 | ||