00001 #include "atconfigdialog.h"
00002 #include "io_modem.h"
00003
00004
00005 #include <qlineedit.h>
00006 #include <qspinbox.h>
00007 #include <qlayout.h>
00008 #include <qcombobox.h>
00009 #include <qtabwidget.h>
00010 #include <qlabel.h>
00011 #include <qscrollview.h>
00012
00013 ATConfigDialog::ATConfigDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
00014 : QDialog( parent, name, modal, fl ) {
00015
00016
00017 setCaption( tr( "Dialing parameter setup" ) );
00018
00019 QVBoxLayout *layout = new QVBoxLayout( this );
00020 QTabWidget *tabWidget = new QTabWidget( this );
00021
00022 tabWidget->addTab( tab0( this ), tr("Settings1") );
00023 tabWidget->addTab( tab1( this ), tr("Settings2") );
00024
00025 layout->addWidget( tabWidget );
00026
00027 }
00028
00029 QWidget* ATConfigDialog::tab0( QWidget* parent) {
00030
00031
00032 QScrollView* sv = new QScrollView( parent );
00033
00034 QWidget *returnWidget = new QWidget( sv->viewport() );
00035 sv->setResizePolicy( QScrollView::AutoOneFit );
00036
00037
00038
00039
00040
00041
00042 QGridLayout *layout = new QGridLayout( returnWidget, 10, 2 );
00043
00044 QLabel *initStringLabel = new QLabel( tr("Init string "), returnWidget );
00045 initStringLine = new QLineEdit( returnWidget );
00046 layout->addWidget( initStringLabel, 0, 0 );
00047 layout->addWidget( initStringLine, 0, 1 );
00048
00049 QLabel *resetStringLabel = new QLabel( tr("Reset string "), returnWidget );
00050 resetStringLine = new QLineEdit( returnWidget );
00051 layout->addWidget( resetStringLabel, 1, 0 );
00052 layout->addWidget( resetStringLine, 1, 1 );
00053
00054 QLabel *dialPref1Label = new QLabel( tr("Dialing prefix #1 " ), returnWidget );
00055 dialPref1Line = new QLineEdit( returnWidget );
00056 layout->addWidget( dialPref1Label, 2, 0 );
00057 layout->addWidget( dialPref1Line, 2, 1 );
00058
00059 QLabel *dialSuf1Label = new QLabel( tr("Dialing suffix #1 " ), returnWidget );
00060 dialSuf1Line = new QLineEdit( returnWidget );
00061 layout->addWidget( dialSuf1Label, 3, 0 );
00062 layout->addWidget( dialSuf1Line, 3, 1 );
00063
00064 QLabel *dialPref2Label = new QLabel( tr("Dialing prefix #2 " ), returnWidget );
00065 dialPref2Line = new QLineEdit( returnWidget );
00066 layout->addWidget( dialPref2Label, 4, 0 );
00067 layout->addWidget( dialPref2Line, 4, 1 );
00068
00069 QLabel *dialSuf2Label = new QLabel( tr("Dialing suffix #2 " ), returnWidget );
00070 dialSuf2Line = new QLineEdit( returnWidget );
00071 layout->addWidget( dialSuf2Label, 5, 0 );
00072 layout->addWidget( dialSuf2Line, 5, 1 );
00073
00074 QLabel *dialPref3Label = new QLabel( tr("Dialing prefix #3 " ), returnWidget );
00075 dialPref3Line = new QLineEdit( returnWidget );
00076 layout->addWidget( dialPref3Label, 6, 0 );
00077 layout->addWidget( dialPref3Line, 6, 1 );
00078
00079 QLabel *dialSuf3Label = new QLabel( tr("Dialing suffix #3 " ), returnWidget );
00080 dialSuf3Line = new QLineEdit( returnWidget );
00081 layout->addWidget( dialSuf3Label, 7, 0 );
00082 layout->addWidget( dialSuf3Line, 7, 1 );
00083
00084 QLabel *connectLabel = new QLabel( tr("Connect string " ), returnWidget );
00085 connectLine = new QLineEdit( returnWidget );
00086 layout->addWidget( connectLabel, 8, 0 );
00087 layout->addWidget( connectLine, 8, 1 );
00088
00089 QLabel *hangupLabel = new QLabel( tr("Hang-up string " ), returnWidget );
00090 hangupLine = new QLineEdit( returnWidget );
00091 layout->addWidget( hangupLabel, 9, 0 );
00092 layout->addWidget( hangupLine, 9, 1 );
00093
00094 sv->addChild( returnWidget );
00095
00096 return sv;
00097
00098 }
00099
00100 QWidget* ATConfigDialog::tab1( QWidget* parent ) {
00101
00102
00103 QWidget *returnWidget = new QWidget( parent );
00104
00105 QGridLayout *layout = new QGridLayout( returnWidget, 8, 2 );
00106
00107 QLabel *dialTimeLabel = new QLabel( tr("Dial time " ), returnWidget );
00108 dialTimeSpin = new QSpinBox( returnWidget );
00109 layout->addWidget( dialTimeLabel, 0, 0 );
00110 layout->addWidget( dialTimeSpin, 0, 1 );
00111
00112 QLabel *delayRedialLabel = new QLabel( tr("Delay before redial " ), returnWidget );
00113 delayRedialSpin = new QSpinBox( returnWidget );
00114 layout->addWidget( delayRedialLabel, 1, 0 );
00115 layout->addWidget( delayRedialSpin, 1, 1 );
00116
00117 QLabel *numberTriesLabel = new QLabel( tr("Number of tries " ), returnWidget );
00118 numberTriesSpin = new QSpinBox( returnWidget );
00119 layout->addWidget( numberTriesLabel, 2, 0 );
00120 layout->addWidget( numberTriesSpin, 2, 1 );
00121
00122 QLabel *dtrDropTimeLabel = new QLabel( tr("DTR drop time (0=no) " ), returnWidget );
00123 dtrDropTimeSpin = new QSpinBox( returnWidget );
00124 layout->addWidget( dtrDropTimeLabel, 3, 0 );
00125 layout->addWidget( dtrDropTimeSpin, 3, 1 );
00126
00127 QLabel *bpsDetectLabel = new QLabel( tr("Auto bps detect " ), returnWidget );
00128 bpsDetectBox = new QComboBox( returnWidget );
00129 layout->addWidget( bpsDetectLabel, 4, 0 );
00130 layout->addWidget( bpsDetectBox, 4, 1 );
00131 bpsDetectBox->insertItem( tr("No") );
00132 bpsDetectBox->insertItem( tr("Yes") );
00133
00134 QLabel *dcdLinesLabel = new QLabel( tr("Modem has DCD line " ), returnWidget );
00135 dcdLinesBox = new QComboBox( returnWidget );
00136 layout->addWidget( dcdLinesLabel, 5, 0 );
00137 layout->addWidget( dcdLinesBox, 5, 1 );
00138 dcdLinesBox->insertItem( tr("No") );
00139 dcdLinesBox->insertItem( tr("Yes") );
00140
00141 QLabel *multiLineUntagLabel = new QLabel( tr("Multi-line untag " ), returnWidget );
00142 multiLineUntagBox = new QComboBox( returnWidget );
00143 layout->addWidget( multiLineUntagLabel, 6, 0 );
00144 layout->addWidget( multiLineUntagBox, 6, 1 );
00145 multiLineUntagBox->insertItem( tr("No") );
00146 multiLineUntagBox->insertItem( tr("Yes") );
00147
00148 return returnWidget;
00149
00150 }
00151
00152
00153 void ATConfigDialog::readConfig( const Profile& config ) {
00154 initStringLine->setText( config.readEntry("InitString", MODEM_DEFAULT_INIT_STRING ) );
00155 resetStringLine->setText( config.readEntry("ResetString", MODEM_DEFAULT_RESET_STRING ) );
00156 dialPref1Line->setText( config.readEntry("DialPrefix1", MODEM_DEFAULT_DIAL_PREFIX1 ) );
00157 dialSuf1Line->setText( config.readEntry("DialSuffix1", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
00158 dialPref2Line->setText( config.readEntry("DialPrefix2", MODEM_DEFAULT_DIAL_PREFIX1 ) );
00159 dialSuf2Line->setText( config.readEntry("DialSuffix2", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
00160 dialPref3Line->setText( config.readEntry("DialPrefix3", MODEM_DEFAULT_DIAL_PREFIX1 ) );
00161 dialSuf3Line->setText( config.readEntry("DialSuffix3", MODEM_DEFAULT_DIAL_SUFFIX1 ) );
00162 connectLine->setText( config.readEntry("DefaultConnect", MODEM_DEFAULT_CONNECT_STRING ) );
00163 hangupLine->setText( config.readEntry("HangupString", MODEM_DEFAULT_HANGUP_STRING ) );
00164 dialTimeSpin->setValue( config.readNumEntry("DialTime", MODEM_DEFAULT_DIAL_TIME ) );
00165 delayRedialSpin->setValue( config.readNumEntry("DelayRedial", MODEM_DEFAULT_DELAY_REDIAL ) );
00166 numberTriesSpin->setValue( config.readNumEntry("NumberTries", MODEM_DEFAULT_NUMBER_TRIES ) );
00167 dtrDropTimeSpin->setValue( config.readNumEntry("DTRDRopTime", MODEM_DEFAULT_DTR_DROP_TIME ) );
00168 bpsDetectBox->setCurrentItem( config.readBoolEntry("BPSDetect", MODEM_DEFAULT_BPS_DETECT ) );
00169 dcdLinesBox->setCurrentItem( config.readBoolEntry("DCDLines", MODEM_DEFAULT_DCD_LINES ) );
00170 multiLineUntagBox->setCurrentItem( config.readBoolEntry("MultiLineUntag", MODEM_DEFAULT_MULTI_LINE_UNTAG ) );
00171
00172
00173 resetStringLine->setEnabled(false);
00174 dialSuf1Line->setEnabled(false);
00175 dialPref2Line->setEnabled(false);
00176 dialSuf2Line->setEnabled(false);
00177 dialPref3Line->setEnabled(false);
00178 dialSuf3Line->setEnabled(false);
00179 dialTimeSpin->setEnabled(false);
00180 delayRedialSpin->setEnabled(false);
00181 numberTriesSpin->setEnabled(false);
00182 dtrDropTimeSpin->setEnabled(false);
00183 bpsDetectBox->setEnabled(false);
00184 dcdLinesBox->setEnabled(false);
00185 multiLineUntagBox->setEnabled(false);
00186 }
00187
00188 void ATConfigDialog::writeConfig( Profile& config ) {
00189
00190 config.writeEntry( "InitString", initStringLine->text() );
00191 config.writeEntry( "ResetString", resetStringLine->text() );
00192 config.writeEntry( "DialPrefix1", dialPref1Line->text() );
00193 config.writeEntry( "DialSuffix1", dialSuf1Line->text() );
00194 config.writeEntry( "DialPrefix2", dialPref2Line->text() );
00195 config.writeEntry( "DialSuffix2", dialSuf2Line->text() );
00196 config.writeEntry( "DialPrefix3", dialPref3Line->text() );
00197 config.writeEntry( "DialSuffix3", dialSuf3Line->text() );
00198 config.writeEntry( "DefaultConnect", connectLine->text() );
00199 config.writeEntry( "HangupString", hangupLine->text() );
00200 config.writeEntry( "DialTime", dialTimeSpin->value() );
00201 config.writeEntry( "DelayRedial", delayRedialSpin->value() );
00202 config.writeEntry( "NumberTries", numberTriesSpin->value() );
00203 config.writeEntry( "DTRDRopTime", dtrDropTimeSpin->value() );
00204 config.writeEntry( "BPSDetect", bpsDetectBox->currentItem() );
00205 config.writeEntry( "DCDLines", dcdLinesBox->currentItem() );
00206 config.writeEntry( "MultiLineUntag", multiLineUntagBox->currentItem() );
00207
00208 }
00209
00210
00211 ATConfigDialog::~ATConfigDialog() {
00212 }