summaryrefslogtreecommitdiff
path: root/noncore/net/wellenreiter/gui/configwindow.cpp
Unidiff
Diffstat (limited to 'noncore/net/wellenreiter/gui/configwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/configwindow.cpp103
1 files changed, 96 insertions, 7 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp
index f536f4e..1341d03 100644
--- a/noncore/net/wellenreiter/gui/configwindow.cpp
+++ b/noncore/net/wellenreiter/gui/configwindow.cpp
@@ -14,32 +14,33 @@
14**********************************************************************/ 14**********************************************************************/
15 15
16/* LOCAL */ 16/* LOCAL */
17#include "configwindow.h" 17#include "configwindow.h"
18#include "mainwindow.h" 18#include "mainwindow.h"
19 19
20/* OPIE */
21#include <opie2/onetwork.h>
22#ifdef QWS
23#include <opie2/oapplication.h>
24#include <opie2/oconfig.h>
25#endif
26
20/* QT */ 27/* QT */
21#include <qapplication.h> 28#include <qapplication.h>
22#include <qcheckbox.h> 29#include <qcheckbox.h>
23#include <qcombobox.h> 30#include <qcombobox.h>
24#include <qfile.h> 31#include <qfile.h>
25#include <qlineedit.h> 32#include <qlineedit.h>
26#include <qlayout.h> 33#include <qlayout.h>
27#include <qmap.h> 34#include <qmap.h>
28#include <qpushbutton.h> 35#include <qpushbutton.h>
36#include <qtabwidget.h>
29#include <qtoolbutton.h> 37#include <qtoolbutton.h>
30#include <qspinbox.h> 38#include <qspinbox.h>
31#include <qtextstream.h> 39#include <qtextstream.h>
32 40
33/* OPIE */
34#include <opie2/onetwork.h>
35
36#ifdef QWS
37#include <opie2/oapplication.h>
38#include <opie2/oconfig.h>
39#endif
40 41
41WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0; 42WellenreiterConfigWindow* WellenreiterConfigWindow::_instance = 0;
42 43
43WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f ) 44WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char * name, WFlags f )
44 :WellenreiterConfigBase( parent, name, true, f ) 45 :WellenreiterConfigBase( parent, name, true, f )
45{ 46{
@@ -69,18 +70,24 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char
69 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); 70 connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
70 #endif 71 #endif
71 72
72 WellenreiterConfigWindow::_instance = this; 73 WellenreiterConfigWindow::_instance = this;
73 74
74 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); 75 connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) );
76 connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) );
77 connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) );
78 connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) );
75 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); 79 connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) );
76 80
77 // make the checkbox 'channelAll' control all other channels 81 // make the checkbox 'channelAll' control all other channels
78 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); 82 connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) );
79 83
80 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); 84 connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) );
85
86 // hide tab4 (parse) until Wellenreiter 1.2
87 tab->removePage( tab_4 );
81}; 88};
82 89
83 90
84WellenreiterConfigWindow::~WellenreiterConfigWindow() 91WellenreiterConfigWindow::~WellenreiterConfigWindow()
85{ 92{
86 save(); 93 save();
@@ -182,12 +189,42 @@ void WellenreiterConfigWindow::changedDeviceType(int t)
182 deviceType->setCurrentItem( _guess ); 189 deviceType->setCurrentItem( _guess );
183 } 190 }
184 191
185} 192}
186 193
187 194
195void WellenreiterConfigWindow::synchronizeActionsAndScripts()
196{
197 if ( newNetworkAction->currentItem() == 4 ) newNetworkScript->show(); else newNetworkScript->hide();
198 if ( newClientAction->currentItem() == 4 ) newClientScript->show(); else newClientScript->hide();
199 if ( newStationAction->currentItem() == 4 ) newStationScript->show(); else newStationScript->hide();
200
201 //newNetworkScript->setEnabled( newNetworkAction->currentItem() == 4 );
202 //newClientScript->setEnabled( newClientAction->currentItem() == 4 );
203 //newStationScript->setEnabled( newStationAction->currentItem() == 4 );
204}
205
206
207void WellenreiterConfigWindow::changedNetworkAction(int t)
208{
209 synchronizeActionsAndScripts();
210}
211
212
213void WellenreiterConfigWindow::changedClientAction(int t)
214{
215 synchronizeActionsAndScripts();
216}
217
218
219void WellenreiterConfigWindow::changedStationAction(int t)
220{
221 synchronizeActionsAndScripts();
222}
223
224
188void WellenreiterConfigWindow::getCaptureFileNameClicked() 225void WellenreiterConfigWindow::getCaptureFileNameClicked()
189{ 226{
190 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true); 227 QString name = ( (WellenreiterMainWindow*) qApp->mainWidget() )->getFileName(true);
191 qDebug( "name = %s", (const char*) name ); 228 qDebug( "name = %s", (const char*) name );
192 if ( !name.isEmpty() ) 229 if ( !name.isEmpty() )
193 { 230 {
@@ -232,12 +269,51 @@ int WellenreiterConfigWindow::gpsPort() const
232{ 269{
233 bool ok; 270 bool ok;
234 return useGPS() ? gpsdPort->value() : -1; 271 return useGPS() ? gpsdPort->value() : -1;
235} 272}
236 273
237 274
275void WellenreiterConfigWindow::performAction( const QString& type )
276{
277 int action;
278 QString script;
279
280 if ( type == "network" )
281 {
282 action = newNetworkAction->currentItem();
283 script = newNetworkScript->text();
284 }
285 else if ( type == "managed" || type == "adhoc" )
286 {
287 action = newClientAction->currentItem();
288 script = newClientScript->text();
289 }
290 else if ( type == "station" )
291 {
292 action = newStationAction->currentItem();
293 script = newStationScript->text();
294 }
295 else
296 {
297 qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type );
298 return;
299 }
300
301 qDebug( "going to perform action %d (script='%s')", action, (const char*) script );
302
303 /*
304
305 if ( sound == "Ignore" ) return;
306 else if ( sound == "Touch" ) ODevice::inst()->touchSound();
307 else if ( sound == "Key" ) ODevice::inst()->keySound();
308 else if ( sound == "Alarm" ) ODevice::inst()->alarmSound();
309
310 */
311}
312
313
238void WellenreiterConfigWindow::load() 314void WellenreiterConfigWindow::load()
239{ 315{
240#ifdef Q_WS_X11 316#ifdef Q_WS_X11
241 #warning Persistent Configuration not yet implemented for standalone X11 build 317 #warning Persistent Configuration not yet implemented for standalone X11 build
242 performAutodetection(); 318 performAutodetection();
243#else 319#else
@@ -287,12 +363,19 @@ void WellenreiterConfigWindow::load()
287 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); 363 captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) );
288 364
289 c->setGroup( "UI" ); 365 c->setGroup( "UI" );
290 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); 366 lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) );
291 openTree->setChecked( c->readBoolEntry( "openTree", true ) ); 367 openTree->setChecked( c->readBoolEntry( "openTree", true ) );
292 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); 368 disablePM->setChecked( c->readBoolEntry( "disablePM", true ) );
369 newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 0 ) );
370 newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) );
371 newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 0 ) );
372 newClientScript->setText( c->readEntry( "newClientScript", "" ) );
373 newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 0 ) );
374 newStationScript->setText( c->readEntry( "newStationScript", "" ) );
375 synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand
293 376
294 c->setGroup( "GPS" ); 377 c->setGroup( "GPS" );
295 enableGPS->setChecked( c->readBoolEntry( "use", false ) ); 378 enableGPS->setChecked( c->readBoolEntry( "use", false ) );
296#if QT_VERSION < 300 379#if QT_VERSION < 300
297 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); 380 gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 );
298 gpsdHost->setCurrentItem( 0 ); 381 gpsdHost->setCurrentItem( 0 );
@@ -330,12 +413,18 @@ void WellenreiterConfigWindow::save()
330 c->writeEntry( "filename", captureFileName->text() ); 413 c->writeEntry( "filename", captureFileName->text() );
331 414
332 c->setGroup( "UI" ); 415 c->setGroup( "UI" );
333 c->writeEntry( "lookupVendor", lookupVendor->isChecked() ); 416 c->writeEntry( "lookupVendor", lookupVendor->isChecked() );
334 c->writeEntry( "openTree", openTree->isChecked() ); 417 c->writeEntry( "openTree", openTree->isChecked() );
335 c->writeEntry( "disablePM", disablePM->isChecked() ); 418 c->writeEntry( "disablePM", disablePM->isChecked() );
419 c->writeEntry( "newNetworkAction", newNetworkAction->currentItem() );
420 c->writeEntry( "newNetworkScript", newNetworkScript->text() );
421 c->writeEntry( "newClientAction", newClientAction->currentItem() );
422 c->writeEntry( "newClientScript", newClientScript->text() );
423 c->writeEntry( "newStationAction", newStationAction->currentItem() );
424 c->writeEntry( "newStationScript", newStationScript->text() );
336 425
337 c->setGroup( "GPS" ); 426 c->setGroup( "GPS" );
338 c->writeEntry( "use", enableGPS->isChecked() ); 427 c->writeEntry( "use", enableGPS->isChecked() );
339 c->writeEntry( "host", gpsdHost->currentText() ); 428 c->writeEntry( "host", gpsdHost->currentText() );
340 c->writeEntry( "port", gpsdPort->value() ); 429 c->writeEntry( "port", gpsdPort->value() );
341 c->writeEntry( "start", startGPS->isChecked() ); 430 c->writeEntry( "start", startGPS->isChecked() );