author | zecke <zecke> | 2004-10-14 00:39:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-10-14 00:39:47 (UTC) |
commit | b17b6c77af35b610d236321279d3f18eb3060c90 (patch) (side-by-side diff) | |
tree | 4ff66b2060c91373f86f3fd14890dcb8e98babb6 | |
parent | 9cc9ed1e746477c59b1fd3d572cdce052f0ccf85 (diff) | |
download | opie-b17b6c77af35b610d236321279d3f18eb3060c90.zip opie-b17b6c77af35b610d236321279d3f18eb3060c90.tar.gz opie-b17b6c77af35b610d236321279d3f18eb3060c90.tar.bz2 |
-Make ModemQuery to use the 'current' configuration
-Todo make FlowControl, LineTermination lwork across locales
for safe and restore
-rw-r--r-- | noncore/settings/networksettings/ppp/devices.cpp | 7 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/general.cpp | 34 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/general.h | 17 |
3 files changed, 55 insertions, 3 deletions
diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp index e2c67d8..c658227 100644 --- a/noncore/settings/networksettings/ppp/devices.cpp +++ b/noncore/settings/networksettings/ppp/devices.cpp @@ -166,54 +166,59 @@ void DevicesWidget::remove() { slotListBoxSelect(listListbox->currentItem()); } int DevicesWidget::doTab(){ QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp ); QVBoxLayout *layout = new QVBoxLayout( dlg ); layout->setSpacing( 0 ); layout->setMargin( 1 ); QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); layout->addWidget( tabWindow ); bool isnew; if(_pppdata->devname().isEmpty()) { dlg->setCaption(tr("New Device")); isnew = true; } else { QString tit = tr("Edit Device: "); tit += _pppdata->devname(); dlg->setCaption(tit); isnew = false; } modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" ); tabWindow->addTab( modem1, tr("&Device") ); modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" ); tabWindow->addTab( modem2, tr("&Modem") ); + connect(modem2, SIGNAL(sig_beforeQueryModem()), + modem1, SLOT(slotBeforeModemQuery())); + connect(modem2, SIGNAL(sig_afterQueryModem()), + modem1, SLOT(slotAfterModemQuery())); + int result = 0; bool ok = false; while (!ok){ result = QPEApplication::execDialog( dlg ); ok = true; if(result == QDialog::Accepted) { if (!modem1->save()){ - QMessageBox::critical(this, "error", tr( "You must enter a unique device name")); + QMessageBox::critical(this, tr("Error"), tr( "You must enter a unique device name")); ok = false; }else{ modem2->save(); } } } delete dlg; return result; } diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index 40ba19b..5e2a04f 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp @@ -257,127 +257,153 @@ ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) if(_pppdata->flowcontrol() == flowcontrol->text(i)) flowcontrol->setCurrentItem(i); } //set the modem speed for(int i=0; i < baud_c->count(); i++) if(baud_c->text(i) == _pppdata->speed()) baud_c->setCurrentItem(i); tl->setRowStretch(1, 1); } ModemWidget::~ModemWidget() { QStringList devs; for (int i=0;i<modemdevice->count();i++) { QString s = modemdevice->text(i); s.simplifyWhiteSpace(); if (! s.isEmpty() ) devs << s; } QString edited = modemdevice->currentText(); if ( !( edited ).isEmpty() ) { edited.simplifyWhiteSpace(); if ( devs.contains( edited ) == 0 ) { devs << edited; } - _pppdata->setModemDevice( edited ); } Config cfg("NetworkSetupPPP"); cfg.setGroup("Devices_General"); cfg.writeEntry("devices",devs,','); } // void ModemWidget::speed_selection(int) { // _pppdata->setSpeed(baud_c->text(baud_c->currentItem())); // } // void ModemWidget::setenter(int ) { // _pppdata->setEnter(enter->text(enter->currentItem())); // } // void ModemWidget::setmodemdc(int i) { // _pppdata->setModemDevice(modemdevice->text(i)); // } // void ModemWidget::setmodemdc( const QString &string ) { // _pppdata->setModemDevice( string ); // } // void ModemWidget::setflowcontrol(int i) { // _pppdata->setFlowcontrol(flowcontrol->text(i)); // } // void ModemWidget::modemlockfilechanged(bool set) { // _pppdata->setModemLockFile(set); // } // void ModemWidget::modemtimeoutchanged(int n) { // _pppdata->setModemTimeout(n); // } bool ModemWidget::save() { //first check to make sure that the device name is unique! if(modemname->text().isEmpty() || !_pppdata->isUniqueDevname(modemname->text())) return false; - odebug << "ModemWidget::save saving modem1 data" << oendl; _pppdata->setDevname( modemname->text() ); _pppdata->setModemDevice( modemdevice->currentText() ); _pppdata->setFlowcontrol(flowcontrol->currentText()); _pppdata->setFlowcontrol(flowcontrol->currentText()); _pppdata->setSpeed(baud_c->currentText()); _pppdata->setModemLockFile( modemlockfile->isChecked()); _pppdata->setModemTimeout( modemtimeout->value() ); return true; } +void ModemWidget::slotBeforeModemQuery() +{ + m_oldModemDev = _pppdata->modemDevice(); + m_oldFlowControl = _pppdata->flowcontrol(); + m_oldSpeed = _pppdata->speed(); + m_oldModemLock = _pppdata->modemLockFile(); + m_oldModemTimeout = _pppdata->modemTimeout(); + + + _pppdata->setModemDevice( modemdevice->currentText() ); + _pppdata->setFlowcontrol(flowcontrol->currentText()); + _pppdata->setFlowcontrol(flowcontrol->currentText()); + _pppdata->setSpeed(baud_c->currentText()); + _pppdata->setModemLockFile( modemlockfile->isChecked()); + _pppdata->setModemTimeout( modemtimeout->value() ); +} + + +void ModemWidget::slotAfterModemQuery() +{ + _pppdata->setModemDevice( m_oldModemDev ); + _pppdata->setFlowcontrol( m_oldFlowControl ); + _pppdata->setSpeed( m_oldSpeed ); + _pppdata->setModemLockFile( m_oldModemLock ); + _pppdata->setModemTimeout( m_oldModemTimeout ); +} + + ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, const char *name) : QWidget(parent, name), _pppdata(pd), _ifaceppp(ip) { QVBoxLayout *l1 = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); waitfordt = new QCheckBox(tr("&Wait for dial tone before dialing"), this); waitfordt->setChecked(_pppdata->waitForDialTone()); // connect(waitfordt, SIGNAL(toggled(bool)), SLOT(waitfordtchanged(bool))); l1->addWidget(waitfordt); QWhatsThis::add(waitfordt, tr("<p>Normally the modem waits for a dial tone\n" "from your phone line, indicating that it can\n" "start to dial a number. If your modem does not\n" "recognize this sound, or your local phone system\n" "does not emit such a tone, uncheck this option\n" "\n" "<b>Default:</b>: On")); QHBoxLayout *waitLayout = new QHBoxLayout( this ); QLabel *waitLabel = new QLabel( tr("Busy wait:"), this, "busyWait" ); busywait = new QSpinBox( 0, 300, 5, this, "busyWait" ); // busywait = new KIntNumInput(_pppdata->busyWait(), this); // busywait->setLabel(tr("B&usy wait:")); // busywait->setRange(0, 300, 5, true); busywait->setSuffix(tr(" sec")); // connect(busywait, SIGNAL(valueChanged(int)), SLOT(busywaitchanged(int))); waitLayout->addWidget(waitLabel); waitLayout->addWidget(busywait); l1->addLayout( waitLayout ); @@ -459,66 +485,70 @@ ModemWidget2::ModemWidget2( PPPData *pd, InterfacePPP *ip, QWidget *parent, QHBoxLayout *hbox = new QHBoxLayout(); l1->addLayout(hbox); hbox->addStretch(1); QVBoxLayout *vbox = new QVBoxLayout(); hbox->addLayout(vbox); vbox->addWidget(modemcmds); vbox->addWidget(modeminfo_button); // vbox->addWidget(terminal_button); hbox->addStretch(1); l1->addStretch(1); connect(modemcmds, SIGNAL(clicked()), SLOT(modemcmdsbutton())); connect(modeminfo_button, SIGNAL(clicked()), SLOT(query_modem())); // connect(terminal_button, SIGNAL(clicked()), // SLOT(terminal())); } void ModemWidget2::modemcmdsbutton() { ModemCommands mc(_ifaceppp->data(), this, "commands" , true, Qt::WStyle_ContextHelp); QPEApplication::execDialog( &mc ); } void ModemWidget2::query_modem() { + emit sig_beforeQueryModem(); + ModemTransfer mt(_ifaceppp->modem(), this); mt.exec(); + + emit sig_afterQueryModem(); } // void ModemWidget2::terminal() { // MiniTerm terminal(NULL,NULL); // terminal.exec(); // } // #if 0 // void ModemWidget2::use_cdline_toggled(bool on) { // _pppdata->setUseCDLine(on); // } // #endif // void ModemWidget2::waitfordtchanged(bool b) { // _pppdata->setWaitForDialTone((int)b); // } // void ModemWidget2::busywaitchanged(int n) { // _pppdata->setbusyWait(n); // } // void ModemWidget2::volumeChanged(int v) { // _pppdata->setVolume(v); // } bool ModemWidget2::save() { _pppdata->setWaitForDialTone(waitfordt->isChecked()); _pppdata->setbusyWait(busywait->value()); diff --git a/noncore/settings/networksettings/ppp/general.h b/noncore/settings/networksettings/ppp/general.h index f43f241..a4dece4 100644 --- a/noncore/settings/networksettings/ppp/general.h +++ b/noncore/settings/networksettings/ppp/general.h @@ -17,92 +17,109 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _GENERAL_H_ #define _GENERAL_H_ #include <qwidget.h> class QSlider; class QSpinBox; class QCombobox; class QLabel; class QCheckBox; class QComboBox; class PPPData; class InterfacePPP; class QLineEdit; class ModemWidget : public QWidget { Q_OBJECT public: ModemWidget(PPPData*, QWidget *parent=0, const char *name=0 ); ~ModemWidget(); bool save(); +private slots: + /* + * temporarily commit configuration so queryModem + * will use 'current' settings + */ + void slotBeforeModemQuery(); + void slotAfterModemQuery(); + /* private slots: */ /* void setmodemdc(int); */ /* void setmodemdc(const QString &); */ /* void setflowcontrol(int); */ /* void modemtimeoutchanged(int); */ /* void modemlockfilechanged(bool); */ /* void setenter(int); */ /* void speed_selection(int); */ private: QComboBox *enter; /* QLabel *label1; */ /* QLabel *label2; */ /* QLabel *labeltmp; */ /* QLabel *labelenter; */ QLineEdit *modemname; QComboBox *modemdevice; QComboBox *flowcontrol; QComboBox *baud_c; QLabel *baud_label; QSpinBox *modemtimeout; QCheckBox *modemlockfile; PPPData *_pppdata; + +private: + QString m_oldModemDev, m_oldFlowControl, m_oldSpeed; + bool m_oldModemLock; + int m_oldModemTimeout; }; class ModemWidget2 : public QWidget { Q_OBJECT public: ModemWidget2( PPPData*, InterfacePPP*, QWidget *parent=0, const char *name=0 ); bool save(); +signals: + void sig_beforeQueryModem(); + void sig_afterQueryModem(); + private slots: /* void waitfordtchanged(bool); */ /* void busywaitchanged(int); */ // void use_cdline_toggled(bool); void modemcmdsbutton(); // void terminal(); void query_modem(); // void volumeChanged(int); private: QLabel *labeltmp; QPushButton *modemcmds; QPushButton *modeminfo_button; // QPushButton *terminal_button; // QFrame *fline; QCheckBox *waitfordt; QSpinBox *busywait; QCheckBox *chkbox1; QSlider *volume; PPPData *_pppdata; InterfacePPP *_ifaceppp; }; #endif |