summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-18 17:14:27 (UTC)
committer josef <josef>2002-10-18 17:14:27 (UTC)
commit0f230c7120d49a1718fe3e442e1559968a21f00d (patch) (unidiff)
treeb27ddd04c385d6c0eef4a91f010017fb9cfa6598
parent12851a09a2761ca6e189f080e9ca69bf4974302f (diff)
downloadopie-0f230c7120d49a1718fe3e442e1559968a21f00d.zip
opie-0f230c7120d49a1718fe3e442e1559968a21f00d.tar.gz
opie-0f230c7120d49a1718fe3e442e1559968a21f00d.tar.bz2
- save at modem configuration when closing dialog
This is not ideal yet, but better than nothing. We might actually use the configured values rather than hardcoded defaults now :)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/modemconfigwidget.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/noncore/apps/opie-console/modemconfigwidget.cpp b/noncore/apps/opie-console/modemconfigwidget.cpp
index 878b0cf..c0ab0fc 100644
--- a/noncore/apps/opie-console/modemconfigwidget.cpp
+++ b/noncore/apps/opie-console/modemconfigwidget.cpp
@@ -1,197 +1,200 @@
1#include <qlabel.h> 1#include <qlabel.h>
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#include <qregexp.h> 7#include <qregexp.h>
8 8
9#include "modemconfigwidget.h" 9#include "modemconfigwidget.h"
10#include "dialdialog.h" 10#include "dialdialog.h"
11 11
12namespace { 12namespace {
13 void setCurrent( const QString& str, QComboBox* bo ) { 13 void setCurrent( const QString& str, QComboBox* bo ) {
14 uint b = bo->count(); 14 uint b = bo->count();
15 for (uint i = 0; i < bo->count(); i++ ) { 15 for (uint i = 0; i < bo->count(); i++ ) {
16 if ( bo->text(i) == str ) { 16 if ( bo->text(i) == str ) {
17 bo->setCurrentItem( i ); 17 bo->setCurrentItem( i );
18 return; 18 return;
19 } 19 }
20 } 20 }
21 bo->insertItem( str ); 21 bo->insertItem( str );
22 bo->setCurrentItem( b ); 22 bo->setCurrentItem( b );
23 } 23 }
24} 24}
25 25
26ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent, 26ModemConfigWidget::ModemConfigWidget( const QString& name, QWidget* parent,
27 const char* na ) 27 const char* na )
28 : ProfileDialogConnectionWidget( name, parent, na ) { 28 : ProfileDialogConnectionWidget( name, parent, na ) {
29 29
30 m_lay = new QVBoxLayout( this ); 30 m_lay = new QVBoxLayout( this );
31 m_device = new QLabel(tr( "Modem is attached to:" ), this ); 31 m_device = new QLabel(tr( "Modem is attached to:" ), this );
32 m_deviceCmb = new QComboBox(this ); 32 m_deviceCmb = new QComboBox(this );
33 m_deviceCmb->setEditable( TRUE ); 33 m_deviceCmb->setEditable( TRUE );
34 34
35 QLabel* telLabel = new QLabel( this ); 35 QLabel* telLabel = new QLabel( this );
36 telLabel->setText( tr( "Enter telefon number here:" ) ); 36 telLabel->setText( tr( "Enter telefon number here:" ) );
37 m_telNumber = new QLineEdit( this ); 37 m_telNumber = new QLineEdit( this );
38 QHBox *buttonBox = new QHBox( this ); 38 QHBox *buttonBox = new QHBox( this );
39 QPushButton *atButton = new QPushButton( buttonBox ); 39 QPushButton *atButton = new QPushButton( buttonBox );
40 atButton->setText( tr( "AT commands" ) ); 40 atButton->setText( tr( "AT commands" ) );
41 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) ); 41 connect( atButton, SIGNAL( clicked() ), this, SLOT( slotAT() ) );
42 42
43 QPushButton *dialButton = new QPushButton( buttonBox ); 43 QPushButton *dialButton = new QPushButton( buttonBox );
44 dialButton->setText( tr( "Enter number" ) ); 44 dialButton->setText( tr( "Enter number" ) );
45 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) ); 45 connect( dialButton, SIGNAL( clicked() ), this, SLOT( slotDial() ) );
46 46
47 47
48 m_base = new IOLayerBase( this, "base" ); 48 m_base = new IOLayerBase( this, "base" );
49 49
50 m_lay->addWidget( m_device ); 50 m_lay->addWidget( m_device );
51 m_lay->addWidget( m_deviceCmb ); 51 m_lay->addWidget( m_deviceCmb );
52 m_lay->addWidget( telLabel ); 52 m_lay->addWidget( telLabel );
53 m_lay->addWidget( m_telNumber ); 53 m_lay->addWidget( m_telNumber );
54 m_lay->addWidget( buttonBox ); 54 m_lay->addWidget( buttonBox );
55 m_lay->addWidget( m_base ); 55 m_lay->addWidget( m_base );
56 56
57 m_deviceCmb->insertItem( "/dev/ttyS0" ); 57 m_deviceCmb->insertItem( "/dev/ttyS0" );
58 m_deviceCmb->insertItem( "/dev/ttyS1" ); 58 m_deviceCmb->insertItem( "/dev/ttyS1" );
59 m_deviceCmb->insertItem( "/dev/ttyS2" ); 59 m_deviceCmb->insertItem( "/dev/ttyS2" );
60 60
61 atConf = new ATConfigDialog( this, "ATConfig", true ); 61 atConf = new ATConfigDialog( this, "ATConfig", true );
62} 62}
63 63
64ModemConfigWidget::~ModemConfigWidget() { 64ModemConfigWidget::~ModemConfigWidget() {
65 65
66} 66}
67void ModemConfigWidget::load( const Profile& prof ) { 67void ModemConfigWidget::load( const Profile& prof ) {
68 68
69 int rad_flow = prof.readNumEntry( "Flow" ); 69 int rad_flow = prof.readNumEntry( "Flow" );
70 int rad_parity = prof.readNumEntry( "Parity" ); 70 int rad_parity = prof.readNumEntry( "Parity" );
71 int speed = prof.readNumEntry( "Speed" ); 71 int speed = prof.readNumEntry( "Speed" );
72 QString number = prof.readEntry( "Number" ); 72 QString number = prof.readEntry( "Number" );
73 73
74 if ( !number.isEmpty() ) { 74 if ( !number.isEmpty() ) {
75 m_telNumber->setText( number ); 75 m_telNumber->setText( number );
76 } 76 }
77 77
78 if ( rad_flow == 1 ) { 78 if ( rad_flow == 1 ) {
79 m_base->setFlow( IOLayerBase::Hardware ); 79 m_base->setFlow( IOLayerBase::Hardware );
80 } else if (rad_flow == 2) { 80 } else if (rad_flow == 2) {
81 m_base->setFlow( IOLayerBase::Software ); 81 m_base->setFlow( IOLayerBase::Software );
82 } else if (rad_flow == 0) { 82 } else if (rad_flow == 0) {
83 m_base->setFlow( IOLayerBase::None ); 83 m_base->setFlow( IOLayerBase::None );
84 } 84 }
85 85
86 86
87 if ( rad_parity == 1 ) { 87 if ( rad_parity == 1 ) {
88 m_base->setParity( IOLayerBase::Even ); 88 m_base->setParity( IOLayerBase::Even );
89 } else if ( rad_parity == 2 ){ 89 } else if ( rad_parity == 2 ){
90 m_base->setParity( IOLayerBase::Odd ); 90 m_base->setParity( IOLayerBase::Odd );
91 } else { 91 } else {
92 m_base->setParity( IOLayerBase::NonePar ); 92 m_base->setParity( IOLayerBase::NonePar );
93 } 93 }
94 94
95 switch( speed ) { 95 switch( speed ) {
96 case 115200: 96 case 115200:
97 m_base->setSpeed( IOLayerBase::Baud_115200 ); 97 m_base->setSpeed( IOLayerBase::Baud_115200 );
98 break; 98 break;
99 case 57600: 99 case 57600:
100 m_base->setSpeed( IOLayerBase::Baud_57600 ); 100 m_base->setSpeed( IOLayerBase::Baud_57600 );
101 break; 101 break;
102 case 38400: 102 case 38400:
103 m_base->setSpeed( IOLayerBase::Baud_38400 ); 103 m_base->setSpeed( IOLayerBase::Baud_38400 );
104 break; 104 break;
105 case 19200: 105 case 19200:
106 m_base->setSpeed( IOLayerBase::Baud_19200 ); 106 m_base->setSpeed( IOLayerBase::Baud_19200 );
107 break; 107 break;
108 case 9600: 108 case 9600:
109 default: 109 default:
110 m_base->setSpeed( IOLayerBase::Baud_9600 ); 110 m_base->setSpeed( IOLayerBase::Baud_9600 );
111 break; 111 break;
112 } 112 }
113 113
114 if ( prof.readEntry( "Device" ).isEmpty() ) { 114 if ( prof.readEntry( "Device" ).isEmpty() ) {
115 return; 115 return;
116 } 116 }
117 setCurrent( prof.readEntry( "Device" ), m_deviceCmb ); 117 setCurrent( prof.readEntry( "Device" ), m_deviceCmb );
118 118
119 atConf->readConfig( prof ); 119 atConf->readConfig( prof );
120} 120}
121 121
122/* 122/*
123 * save speed, 123 * save speed,
124 * flow, 124 * flow,
125 * parity 125 * parity
126 */ 126 */
127void ModemConfigWidget::save( Profile& prof ) { 127void ModemConfigWidget::save( Profile& prof ) {
128 int flow, parity, speed; 128 int flow, parity, speed;
129 prof.writeEntry( "Device", m_deviceCmb->currentText() ); 129 prof.writeEntry( "Device", m_deviceCmb->currentText() );
130 130
131 131
132 switch( m_base->flow() ) { 132 switch( m_base->flow() ) {
133 case IOLayerBase::None: 133 case IOLayerBase::None:
134 flow = 0; 134 flow = 0;
135 break; 135 break;
136 case IOLayerBase::Software: 136 case IOLayerBase::Software:
137 flow = 2; 137 flow = 2;
138 break; 138 break;
139 case IOLayerBase::Hardware: 139 case IOLayerBase::Hardware:
140 flow = 1; 140 flow = 1;
141 break; 141 break;
142 } 142 }
143 143
144 switch( m_base->parity() ) { 144 switch( m_base->parity() ) {
145 case IOLayerBase::Odd: 145 case IOLayerBase::Odd:
146 parity = 2; 146 parity = 2;
147 break; 147 break;
148 case IOLayerBase::Even: 148 case IOLayerBase::Even:
149 parity = 1; 149 parity = 1;
150 break; 150 break;
151 case IOLayerBase::NonePar: 151 case IOLayerBase::NonePar:
152 parity = 0; 152 parity = 0;
153 break; 153 break;
154 } 154 }
155 155
156 switch( m_base->speed() ) { 156 switch( m_base->speed() ) {
157 case IOLayerBase::Baud_115200: 157 case IOLayerBase::Baud_115200:
158 speed = 115200; 158 speed = 115200;
159 break; 159 break;
160 case IOLayerBase::Baud_57600: 160 case IOLayerBase::Baud_57600:
161 speed = 57600; 161 speed = 57600;
162 break; 162 break;
163 case IOLayerBase::Baud_38400: 163 case IOLayerBase::Baud_38400:
164 speed = 38400; 164 speed = 38400;
165 break; 165 break;
166 case IOLayerBase::Baud_19200: 166 case IOLayerBase::Baud_19200:
167 speed = 19200; 167 speed = 19200;
168 break; 168 break;
169 case IOLayerBase::Baud_9600: 169 case IOLayerBase::Baud_9600:
170 speed = 9600; 170 speed = 9600;
171 break; 171 break;
172 } 172 }
173 173
174 prof.writeEntry( "Flow", flow ); 174 prof.writeEntry( "Flow", flow );
175 prof.writeEntry( "Parity", parity ); 175 prof.writeEntry( "Parity", parity );
176 prof.writeEntry( "Speed", speed ); 176 prof.writeEntry( "Speed", speed );
177 prof.writeEntry( "Number", m_telNumber->text() ); 177 prof.writeEntry( "Number", m_telNumber->text() );
178
179
180 atConf->writeConfig(prof);
178} 181}
179 182
180void ModemConfigWidget::slotAT() { 183void ModemConfigWidget::slotAT() {
181 // ATConfigDialog conf( this, "ATConfig", true ); 184 // ATConfigDialog conf( this, "ATConfig", true );
182 atConf->showMaximized(); 185 atConf->showMaximized();
183 if ( atConf->exec() == QDialog::Accepted ) { 186 if ( atConf->exec() != QDialog::Accepted ) {
184 // atConf->writeConfig(); 187 // reload old settings
185 } 188 }
186} 189}
187 190
188void ModemConfigWidget::slotDial() { 191void ModemConfigWidget::slotDial() {
189 DialDialog dial( this, "DialConfig", true ); 192 DialDialog dial( this, "DialConfig", true );
190 if(!m_telNumber->text().isEmpty()) { 193 if(!m_telNumber->text().isEmpty()) {
191 dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ ]"), "").toInt()); 194 dial.setNumber(m_telNumber->text().replace(QRegExp("[\\-\\/\\ ]"), "").toInt());
192 } 195 }
193 dial.showMaximized(); 196 dial.showMaximized();
194 if ( dial.exec() == QDialog::Accepted ) { 197 if ( dial.exec() == QDialog::Accepted ) {
195 m_telNumber->setText( dial.number() ); 198 m_telNumber->setText( dial.number() );
196 } 199 }
197} 200}