author | mickeyl <mickeyl> | 2004-01-09 20:01:42 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-09 20:01:42 (UTC) |
commit | 88af644c534f19e391ebbe8ea0babf3ccf459eb1 (patch) (unidiff) | |
tree | f49e88a6dfc58d3f196e6918bb402a14ee9f0ad0 | |
parent | 56bb9961db1158250bbfe971f4556b56c0bd6581 (diff) | |
download | opie-88af644c534f19e391ebbe8ea0babf3ccf459eb1.zip opie-88af644c534f19e391ebbe8ea0babf3ccf459eb1.tar.gz opie-88af644c534f19e391ebbe8ea0babf3ccf459eb1.tar.bz2 |
save configuration settings in accept(), not in the ~
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.cpp | 16 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/configwindow.h | 3 | ||||
-rw-r--r-- | noncore/net/wellenreiter/gui/scanlist.cpp | 3 |
3 files changed, 16 insertions, 6 deletions
diff --git a/noncore/net/wellenreiter/gui/configwindow.cpp b/noncore/net/wellenreiter/gui/configwindow.cpp index 7f39230..9358866 100644 --- a/noncore/net/wellenreiter/gui/configwindow.cpp +++ b/noncore/net/wellenreiter/gui/configwindow.cpp | |||
@@ -79,35 +79,41 @@ WellenreiterConfigWindow::WellenreiterConfigWindow( QWidget * parent, const char | |||
79 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); | 79 | connect( deviceType, SIGNAL( activated(int) ), this, SLOT( changedDeviceType(int) ) ); |
80 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); | 80 | connect( newNetworkAction, SIGNAL( activated(int) ), this, SLOT( changedNetworkAction(int) ) ); |
81 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); | 81 | connect( newClientAction, SIGNAL( activated(int) ), this, SLOT( changedClientAction(int) ) ); |
82 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); | 82 | connect( newStationAction, SIGNAL( activated(int) ), this, SLOT( changedStationAction(int) ) ); |
83 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); | 83 | connect( getCaptureFileName, SIGNAL( clicked() ), this, SLOT( getCaptureFileNameClicked() ) ); |
84 | 84 | ||
85 | // make the checkbox 'channelAll' control all other channels | 85 | // make the checkbox 'channelAll' control all other channels |
86 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); | 86 | connect( channelAll, SIGNAL( stateChanged(int) ), this, SLOT( channelAllClicked(int) ) ); |
87 | 87 | ||
88 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); | 88 | connect( autodetect, SIGNAL( clicked() ), this, SLOT( performAutodetection() ) ); |
89 | 89 | ||
90 | // hide tab4 (parse) until Wellenreiter 1.2 | 90 | // hide tab4 (parse) until Wellenreiter 1.2 |
91 | tab->removePage( tab_4 ); | 91 | tab->removePage( tab_4 ); |
92 | }; | 92 | }; |
93 | 93 | ||
94 | 94 | ||
95 | WellenreiterConfigWindow::~WellenreiterConfigWindow() | 95 | void WellenreiterConfigWindow::accept() |
96 | { | 96 | { |
97 | save(); | 97 | save(); |
98 | QDialog::accept(); | ||
99 | } | ||
100 | |||
101 | |||
102 | WellenreiterConfigWindow::~WellenreiterConfigWindow() | ||
103 | { | ||
98 | } | 104 | } |
99 | 105 | ||
100 | 106 | ||
101 | void WellenreiterConfigWindow::performAutodetection() | 107 | void WellenreiterConfigWindow::performAutodetection() |
102 | { | 108 | { |
103 | //TODO: insert modal splash screen here | 109 | //TODO: insert modal splash screen here |
104 | // and sleep a second, so that it looks | 110 | // and sleep a second, so that it looks |
105 | // like we're actually doing something fancy... ;-) | 111 | // like we're actually doing something fancy... ;-) |
106 | 112 | ||
107 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); | 113 | qDebug( "WellenreiterConfigWindow::performAutodetection()" ); |
108 | 114 | ||
109 | // try to guess device type | 115 | // try to guess device type |
110 | QFile m( "/proc/modules" ); | 116 | QFile m( "/proc/modules" ); |
111 | if ( m.open( IO_ReadOnly ) ) | 117 | if ( m.open( IO_ReadOnly ) ) |
112 | { | 118 | { |
113 | int devicetype(0); | 119 | int devicetype(0); |
@@ -295,33 +301,33 @@ void WellenreiterConfigWindow::performAction( const QString& type, | |||
295 | else if ( type == "managed" || type == "adhoc" ) | 301 | else if ( type == "managed" || type == "adhoc" ) |
296 | { | 302 | { |
297 | action = newClientAction->currentItem(); | 303 | action = newClientAction->currentItem(); |
298 | script = newClientScript->text(); | 304 | script = newClientScript->text(); |
299 | } | 305 | } |
300 | else if ( type == "station" ) | 306 | else if ( type == "station" ) |
301 | { | 307 | { |
302 | action = newStationAction->currentItem(); | 308 | action = newStationAction->currentItem(); |
303 | script = newStationScript->text(); | 309 | script = newStationScript->text(); |
304 | } | 310 | } |
305 | else | 311 | else |
306 | { | 312 | { |
307 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); | 313 | qWarning( "WellenreiterConfigWindow::performAction(): unknown type '%s'", (const char*) type ); |
308 | return; | 314 | return; |
309 | } | 315 | } |
310 | 316 | ||
311 | qDebug( "going to perform action %d (script='%s')", action, (const char*) script ); | 317 | qDebug( "for event '%s' I'm going to perform action %d (script='%s')", (const char*) type, action, (const char*) script ); |
312 | 318 | ||
313 | switch( action ) | 319 | switch( action ) |
314 | { | 320 | { |
315 | case 0: /* Ignore */ return; | 321 | case 0: /* Ignore */ return; |
316 | case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; | 322 | case 1: /* Play Alarm */ ODevice::inst()->alarmSound(); return; |
317 | case 2: /* Play Click */ ODevice::inst()->touchSound(); return; | 323 | case 2: /* Play Click */ ODevice::inst()->touchSound(); return; |
318 | case 3: /* Blink LED */ break; //FIXME: Implement this | 324 | case 3: /* Blink LED */ break; //FIXME: Implement this |
319 | case 4: /* Run Script */ | 325 | case 4: /* Run Script */ |
320 | { | 326 | { |
321 | /** | 327 | /** |
322 | * | 328 | * |
323 | * Script Substitution Information: | 329 | * Script Substitution Information: |
324 | * | 330 | * |
325 | * $SSID = SSID | 331 | * $SSID = SSID |
326 | * $MAC = MAC | 332 | * $MAC = MAC |
327 | * $WEP = Wep | 333 | * $WEP = Wep |
@@ -385,37 +391,37 @@ void WellenreiterConfigWindow::load() | |||
385 | { | 391 | { |
386 | performAutodetection(); | 392 | performAutodetection(); |
387 | } | 393 | } |
388 | 394 | ||
389 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); | 395 | prismHeader->setChecked( c->readBoolEntry( "prism", false ) ); |
390 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); | 396 | hopChannels->setChecked( c->readBoolEntry( "hop", true ) ); |
391 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); | 397 | hopInterval->setValue( c->readNumEntry( "interval", 250 ) ); |
392 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); | 398 | adaptiveHopping->setChecked( c->readBoolEntry( "adaptive", true ) ); |
393 | 399 | ||
394 | c->setGroup( "Capture" ); | 400 | c->setGroup( "Capture" ); |
395 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); | 401 | captureFileName->setText( c->readEntry( "filename", "/tmp/capture" ) ); |
396 | 402 | ||
397 | c->setGroup( "UI" ); | 403 | c->setGroup( "UI" ); |
398 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); | 404 | lookupVendor->setChecked( c->readBoolEntry( "lookupVendor", true ) ); |
399 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); | 405 | openTree->setChecked( c->readBoolEntry( "openTree", true ) ); |
400 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); | 406 | disablePM->setChecked( c->readBoolEntry( "disablePM", true ) ); |
401 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 0 ) ); | 407 | newNetworkAction->setCurrentItem( c->readNumEntry( "newNetworkAction", 1 ) ); // Default: Play Alarm |
402 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); | 408 | newNetworkScript->setText( c->readEntry( "newNetworkScript", "" ) ); |
403 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 0 ) ); | 409 | newClientAction->setCurrentItem( c->readNumEntry( "newClientAction", 2 ) ); // Default: Play Click |
404 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); | 410 | newClientScript->setText( c->readEntry( "newClientScript", "" ) ); |
405 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 0 ) ); | 411 | newStationAction->setCurrentItem( c->readNumEntry( "newStationAction", 2 ) ); // Default: Play Click |
406 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); | 412 | newStationScript->setText( c->readEntry( "newStationScript", "" ) ); |
407 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand | 413 | synchronizeActionsAndScripts(); // needed for showing/hiding the script QLineEdit on demand |
408 | 414 | ||
409 | c->setGroup( "GPS" ); | 415 | c->setGroup( "GPS" ); |
410 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); | 416 | enableGPS->setChecked( c->readBoolEntry( "use", false ) ); |
411 | #if QT_VERSION < 300 | 417 | #if QT_VERSION < 300 |
412 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); | 418 | gpsdHost->insertItem( c->readEntry( "host", "localhost" ), 0 ); |
413 | gpsdHost->setCurrentItem( 0 ); | 419 | gpsdHost->setCurrentItem( 0 ); |
414 | #else | 420 | #else |
415 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); | 421 | gpsdHost->setCurrentText( c->readEntry( "host", "localhost" ) ); |
416 | #endif | 422 | #endif |
417 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); | 423 | gpsdPort->setValue( c->readNumEntry( "port", 2947 ) ); |
418 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); | 424 | startGPS->setChecked( c->readBoolEntry( "start", false ) ); |
419 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); | 425 | commandGPS->setText( c->readEntry( "command", "gpsd -p /dev/ttyS3 -s 57600" ) ); |
420 | 426 | ||
421 | #endif | 427 | #endif |
diff --git a/noncore/net/wellenreiter/gui/configwindow.h b/noncore/net/wellenreiter/gui/configwindow.h index 5c998cb..d31d1e8 100644 --- a/noncore/net/wellenreiter/gui/configwindow.h +++ b/noncore/net/wellenreiter/gui/configwindow.h | |||
@@ -55,27 +55,28 @@ class WellenreiterConfigWindow : public WellenreiterConfigBase | |||
55 | const QString gpsHost() const; | 55 | const QString gpsHost() const; |
56 | int gpsPort() const; | 56 | int gpsPort() const; |
57 | 57 | ||
58 | void save(); | 58 | void save(); |
59 | void load(); | 59 | void load(); |
60 | 60 | ||
61 | public slots: | 61 | public slots: |
62 | void changedDeviceType(int); | 62 | void changedDeviceType(int); |
63 | void changedNetworkAction(int t); | 63 | void changedNetworkAction(int t); |
64 | void changedClientAction(int t); | 64 | void changedClientAction(int t); |
65 | void changedStationAction(int t); | 65 | void changedStationAction(int t); |
66 | void getCaptureFileNameClicked(); | 66 | void getCaptureFileNameClicked(); |
67 | void performAutodetection(); | 67 | void performAutodetection(); |
68 | void channelAllClicked(int); | 68 | void channelAllClicked(int); |
69 | void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ ); | 69 | void performAction( const QString&, const QString&, const QString&, bool, int, int /* , const GpsLocation& */ ); |
70 | 70 | ||
71 | protected: | 71 | protected slots: |
72 | void synchronizeActionsAndScripts(); | 72 | void synchronizeActionsAndScripts(); |
73 | virtual void accept(); | ||
73 | 74 | ||
74 | protected: | 75 | protected: |
75 | QMap<QString, int> _devicetype; | 76 | QMap<QString, int> _devicetype; |
76 | static WellenreiterConfigWindow* _instance; | 77 | static WellenreiterConfigWindow* _instance; |
77 | int _guess; | 78 | int _guess; |
78 | 79 | ||
79 | }; | 80 | }; |
80 | 81 | ||
81 | #endif | 82 | #endif |
diff --git a/noncore/net/wellenreiter/gui/scanlist.cpp b/noncore/net/wellenreiter/gui/scanlist.cpp index fd88b63..10ead53 100644 --- a/noncore/net/wellenreiter/gui/scanlist.cpp +++ b/noncore/net/wellenreiter/gui/scanlist.cpp | |||
@@ -419,32 +419,35 @@ MScanListItem::MScanListItem( QListView* parent, const QString& type, const QStr | |||
419 | qDebug( "creating scanlist item" ); | 419 | qDebug( "creating scanlist item" ); |
420 | #endif | 420 | #endif |
421 | 421 | ||
422 | if ( WellenreiterConfigWindow::instance() ) | 422 | if ( WellenreiterConfigWindow::instance() ) |
423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | 423 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here |
424 | 424 | ||
425 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); | 425 | decorateItem( type, essid, macaddr, wep, channel, signal, probed ); |
426 | } | 426 | } |
427 | 427 | ||
428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, | 428 | MScanListItem::MScanListItem( QListViewItem* parent, const QString& type, const QString& essid, const QString& macaddr, |
429 | bool wep, int channel, int signal ) | 429 | bool wep, int channel, int signal ) |
430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) | 430 | :OListViewItem( parent, essid, QString::null, macaddr, QString::null, QString::null ) |
431 | { | 431 | { |
432 | #ifdef DEBUG | 432 | #ifdef DEBUG |
433 | qDebug( "creating scanlist item" ); | 433 | qDebug( "creating scanlist item" ); |
434 | #endif | 434 | #endif |
435 | if ( WellenreiterConfigWindow::instance() ) | ||
436 | WellenreiterConfigWindow::instance()->performAction( type, essid, macaddr, wep, channel, signal ); // better use signal/slot combination here | ||
437 | |||
435 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); | 438 | decorateItem( type, essid, macaddr, wep, channel, signal, false ); |
436 | } | 439 | } |
437 | 440 | ||
438 | const QString& MScanListItem::essid() const | 441 | const QString& MScanListItem::essid() const |
439 | { | 442 | { |
440 | if ( type == "network" ) | 443 | if ( type == "network" ) |
441 | return _essid; | 444 | return _essid; |
442 | else | 445 | else |
443 | return ( (MScanListItem*) parent() )->essid(); | 446 | return ( (MScanListItem*) parent() )->essid(); |
444 | } | 447 | } |
445 | 448 | ||
446 | OListViewItem* MScanListItem::childFactory() | 449 | OListViewItem* MScanListItem::childFactory() |
447 | { | 450 | { |
448 | return new MScanListItem( this ); | 451 | return new MScanListItem( this ); |
449 | } | 452 | } |
450 | 453 | ||