summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/modemconfigwidget.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/modemconfigwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp71
1 files changed, 36 insertions, 35 deletions
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp
index 0968f62..ac62e45 100644
--- a/noncore/apps/opie-console/modemconfigwidget.cpp
+++ b/noncore/apps/opie-console/modemconfigwidget.cpp
@@ -2,15 +2,14 @@
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qcombobox.h> 3#include <qcombobox.h>
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qhbox.h> 6#include <qhbox.h>
7 7
8#include "iolayerbase.h" 8
9#include "modemconfigwidget.h" 9#include "modemconfigwidget.h"
10#include "atconfigdialog.h"
11#include "dialdialog.h" 10#include "dialdialog.h"
12 11
13namespace { 12namespace {
14 void setCurrent( const QString& str, QComboBox* bo ) { 13 void setCurrent( const QString& str, QComboBox* bo ) {
15 uint b = bo->count(); 14 uint b = bo->count();
16 for (uint i = 0; i < bo->count(); i++ ) { 15 for (uint i = 0; i < bo->count(); i++ ) {
@@ -21,110 +20,113 @@ namespace {
21 } 20 }
22 bo->insertItem( str ); 21 bo->insertItem( str );
23 bo->setCurrentItem( b ); 22 bo->setCurrentItem( b );
24 } 23 }
25} 24}
26 25
27ModemConfigWidget::ModemConfigWidget( const QString& name, 26ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent,
28 QWidget* parent,
29 const char* na ) 27 const char* na )
30 : ProfileDialogConnectionWidget( name, parent, na ) { 28 : ProfileDialogConnectionWidget( name, parent, na ) {
31 29
32 m_lay = new QVBoxLayout(this ); 30 m_lay = new QVBoxLayout( this );
33 m_device = new QLabel(tr("Modem is attached to:"), this ); 31 m_device = new QLabel(tr( "Modem is attached to:" ), this );
34 m_deviceCmb = new QComboBox(this ); 32 m_deviceCmb = new QComboBox(this );
35 m_deviceCmb->setEditable( TRUE ); 33 m_deviceCmb->setEditable( TRUE );
36 34
37 QLabel* telLabel = new QLabel( this ); 35 QLabel* telLabel = new QLabel( this );
38 telLabel->setText( tr("Enter telefon number here:") ); 36 telLabel->setText( tr( "Enter telefon number here:" ) );
39 m_telNumber = new QLineEdit( this ); 37 m_telNumber = new QLineEdit( this );
40 QHBox *buttonBox = new QHBox( this ); 38 QHBox *buttonBox = new QHBox( this );
41 QPushButton *atButton = new QPushButton( buttonBox ); 39 QPushButton *atButton = new QPushButton( buttonBox );
42 atButton->setText( tr("AT commands") ); 40 atButton->setText( tr( "AT commands" ) );
43 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); 41 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) );
44 42
45 QPushButton *dialButton = new QPushButton( buttonBox ); 43 QPushButton *dialButton = new QPushButton( buttonBox );
46 dialButton->setText( tr("Enter number") ); 44 dialButton->setText( tr( "Enter number" ) );
47 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); 45 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) );
48 46
49 47
50 m_base = new IOLayerBase(this, "base"); 48 m_base = new IOLayerBase( this, "base" );
51 49
52 m_lay->addWidget( m_device ); 50 m_lay->addWidget( m_device );
53 m_lay->addWidget( m_deviceCmb ); 51 m_lay->addWidget( m_deviceCmb );
54 m_lay->addWidget( telLabel ); 52 m_lay->addWidget( telLabel );
55 m_lay->addWidget( m_telNumber ); 53 m_lay->addWidget( m_telNumber );
56 m_lay->addWidget( buttonBox ); 54 m_lay->addWidget( buttonBox );
57 m_lay->addWidget( m_base ); 55 m_lay->addWidget( m_base );
58 56
59 m_deviceCmb->insertItem( "/dev/ttyS0" ); 57 m_deviceCmb->insertItem( "/dev/ttyS0" );
60 m_deviceCmb->insertItem( "/dev/ttyS1" ); 58 m_deviceCmb->insertItem( "/dev/ttyS1" );
61 m_deviceCmb->insertItem( "/dev/ttyS2" ); 59 m_deviceCmb->insertItem( "/dev/ttyS2" );
62 60
63 61 atConf = new ATConfigDialog( this, "ATConfig", true );
64} 62}
65 63
66ModemConfigWidget::~ModemConfigWidget() { 64ModemConfigWidget::~ModemConfigWidget() {
67 65
68} 66}
69void ModemConfigWidget::load( const Profile& prof ) { 67void ModemConfigWidget::load( const Profile& prof ) {
70 68
71 int rad_flow = prof.readNumEntry("Flow"); 69 int rad_flow = prof.readNumEntry( "Flow" );
72 int rad_parity = prof.readNumEntry("Parity"); 70 int rad_parity = prof.readNumEntry( "Parity" );
73 int speed = prof.readNumEntry("Speed"); 71 int speed = prof.readNumEntry( "Speed" );
74 QString number = prof.readEntry("Number"); 72 QString number = prof.readEntry( "Number" );
75 73
76 if (!number.isEmpty() ) { 74 if ( !number.isEmpty() ) {
77 m_telNumber->setText( number ); 75 m_telNumber->setText( number );
78 } 76 }
79 77
80 if (rad_flow == 1) { 78 if ( rad_flow == 1 ) {
81 m_base->setFlow( IOLayerBase::Hardware ); 79 m_base->setFlow( IOLayerBase::Hardware );
82 } else if (rad_flow == 2) { 80 } else if (rad_flow == 2) {
83 m_base->setFlow( IOLayerBase::Software ); 81 m_base->setFlow( IOLayerBase::Software );
84 } else if (rad_flow == 0) { 82 } else if (rad_flow == 0) {
85 m_base->setFlow( IOLayerBase::None ); 83 m_base->setFlow( IOLayerBase::None );
86 } 84 }
87 85
88 if (rad_parity == 1) { 86 if ( rad_parity == 1 ) {
89 m_base->setParity( IOLayerBase::Even ); 87 m_base->setParity( IOLayerBase::Even );
90 } else { 88 } else {
91 m_base->setParity( IOLayerBase::Odd ); 89 m_base->setParity( IOLayerBase::Odd );
92 } 90 }
93 91
94 switch( speed ) { 92 switch( speed ) {
95 case 115200: 93 case 115200:
96 m_base->setSpeed(IOLayerBase::Baud_115200 ); 94 m_base->setSpeed( IOLayerBase::Baud_115200 );
97 break; 95 break;
98 case 57600: 96 case 57600:
99 m_base->setSpeed( IOLayerBase::Baud_57600 ); 97 m_base->setSpeed( IOLayerBase::Baud_57600 );
100 break; 98 break;
101 case 38400: 99 case 38400:
102 m_base->setSpeed(IOLayerBase::Baud_38400 ); 100 m_base->setSpeed( IOLayerBase::Baud_38400 );
103 break; 101 break;
104 case 19200: 102 case 19200:
105 m_base->setSpeed( IOLayerBase::Baud_19200 ); 103 m_base->setSpeed( IOLayerBase::Baud_19200 );
106 break; 104 break;
107 case 9600: 105 case 9600:
108 default: 106 default:
109 m_base->setSpeed(IOLayerBase::Baud_9600 ); 107 m_base->setSpeed( IOLayerBase::Baud_9600 );
110 break; 108 break;
111 } 109 }
112 110
113 if ( prof.readEntry("Device").isEmpty() ) return; 111 if ( prof.readEntry( "Device" ).isEmpty() ) {
114 setCurrent( prof.readEntry("Device"), m_deviceCmb ); 112 return;
113 }
114 setCurrent( prof.readEntry( "Device" ), m_deviceCmb );
115 115
116 atConf->readConfig( prof );
116} 117}
118
117/* 119/*
118 * save speed, 120 * save speed,
119 * flow, 121 * flow,
120 * parity 122 * parity
121 */ 123 */
122void ModemConfigWidget::save( Profile& prof ) { 124void ModemConfigWidget::save( Profile& prof ) {
123 int flow, parity, speed; 125 int flow, parity, speed;
124 prof.writeEntry("Device", m_deviceCmb->currentText() ); 126 prof.writeEntry( "Device", m_deviceCmb->currentText() );
125 127
126 128
127 switch( m_base->flow() ) { 129 switch( m_base->flow() ) {
128 case IOLayerBase::None: 130 case IOLayerBase::None:
129 flow = 0; 131 flow = 0;
130 break; 132 break;
@@ -160,24 +162,23 @@ void ModemConfigWidget::save( Profile& prof ) {
160 break; 162 break;
161 case IOLayerBase::Baud_9600: 163 case IOLayerBase::Baud_9600:
162 speed = 9600; 164 speed = 9600;
163 break; 165 break;
164 } 166 }
165 167
166 prof.writeEntry("Flow", flow); 168 prof.writeEntry( "Flow", flow );
167 prof.writeEntry("Parity", parity); 169 prof.writeEntry( "Parity", parity );
168 prof.writeEntry("Speed", speed); 170 prof.writeEntry( "Speed", speed );
169 prof.writeEntry("Number", m_telNumber->text() ); 171 prof.writeEntry( "Number", m_telNumber->text() );
170} 172}
171 173
172void ModemConfigWidget::slotAT() { 174void ModemConfigWidget::slotAT() {
173 ATConfigDialog conf( this, "ATConfig", true ); 175 // ATConfigDialog conf( this, "ATConfig", true );
174 conf.readConfig(); 176 atConf->showMaximized();
175 conf.showMaximized(); 177 if ( atConf->exec() == QDialog::Accepted ) {
176 if ( conf.exec() == QDialog::Accepted ) { 178 // atConf->writeConfig();
177 conf.writeConfig();
178 } 179 }
179} 180}
180 181
181void ModemConfigWidget::slotDial() { 182void ModemConfigWidget::slotDial() {
182 DialDialog dial( this, "DialConfig", true ); 183 DialDialog dial( this, "DialConfig", true );
183 dial.showMaximized(); 184 dial.showMaximized();