summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/btconfigwidget.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp
index 7f82e06..232e497 100644
--- a/noncore/apps/opie-console/btconfigwidget.cpp
+++ b/noncore/apps/opie-console/btconfigwidget.cpp
@@ -1,208 +1,208 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qlineedit.h> 3#include <qlineedit.h>
4#include <qcombobox.h> 4#include <qcombobox.h>
5#include <qhbox.h> 5#include <qhbox.h>
6#include <qradiobutton.h> 6#include <qradiobutton.h>
7 7
8#include "iolayerbase.h" 8#include "iolayerbase.h"
9#include "btconfigwidget.h" 9#include "btconfigwidget.h"
10 10
11namespace { 11namespace {
12 void setCurrent( const QString& str, QComboBox* bo ) { 12 void setCurrent( const QString& str, QComboBox* bo ) {
13 uint b = bo->count(); 13 uint b = bo->count();
14 for (int i = 0; i < bo->count(); i++ ) { 14 for (int i = 0; i < bo->count(); i++ ) {
15 if ( bo->text(i) == str ) { 15 if ( bo->text(i) == str ) {
16 bo->setCurrentItem( i ); 16 bo->setCurrentItem( i );
17 return; 17 return;
18 } 18 }
19 } 19 }
20 bo->insertItem( str ); 20 bo->insertItem( str );
21 bo->setCurrentItem( b ); 21 bo->setCurrentItem( b );
22 } 22 }
23} 23}
24 24
25BTConfigWidget::BTConfigWidget( const QString& name, 25BTConfigWidget::BTConfigWidget( const QString& name,
26 QWidget* parent, 26 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 31
32 m_device = new QLabel( tr( "Device" ), this ); 32 m_device = new QLabel( tr( "Device" ), this );
33 QHBox *deviceBox = new QHBox( this ); 33 QHBox *deviceBox = new QHBox( this );
34 m_devRadio = new QRadioButton( deviceBox ); 34 m_devRadio = new QRadioButton( deviceBox );
35 connect( m_devRadio, SIGNAL( toggled(bool) ), this, SLOT( slotDevRadio(bool) ) ); 35 connect( m_devRadio, SIGNAL( toggled(bool) ), this, SLOT( slotDevRadio(bool) ) );
36 m_deviceCmb = new QComboBox( deviceBox ); 36 m_deviceCmb = new QComboBox( deviceBox );
37 m_deviceCmb->setEditable( TRUE ); 37 m_deviceCmb->setEditable( TRUE );
38 38
39 QLabel *macLabel = new QLabel( this ); 39 QLabel *macLabel = new QLabel( this );
40 macLabel->setText( tr( "Or peer mac address" ) ); 40 macLabel->setText( tr( "Or peer mac address" ) );
41 QHBox *macBox = new QHBox( this ); 41 QHBox *macBox = new QHBox( this );
42 m_macRadio = new QRadioButton( macBox ); 42 m_macRadio = new QRadioButton( macBox );
43 connect( m_macRadio, SIGNAL( toggled(bool) ), this, SLOT( slotMacRadio(bool) ) ); 43 connect( m_macRadio, SIGNAL( toggled(bool) ), this, SLOT( slotMacRadio(bool) ) );
44 m_mac = new QLineEdit( macBox ); 44 m_mac = new QLineEdit( macBox );
45 45
46 m_base = new IOLayerBase(this, "base"); 46 m_base = new IOLayerBase(this, "base");
47 47
48 m_lay->addWidget( m_device ); 48 m_lay->addWidget( m_device );
49 m_lay->addWidget( deviceBox ); 49 m_lay->addWidget( deviceBox );
50 m_lay->addWidget( macLabel ); 50 m_lay->addWidget( macLabel );
51 m_lay->addWidget( macBox ); 51 m_lay->addWidget( macBox );
52 m_lay->addWidget( m_base ); 52 m_lay->addWidget( m_base );
53 53
54 m_deviceCmb->insertItem( "/dev/ttyU0" ); 54 m_deviceCmb->insertItem( "/dev/ttyU0" );
55 m_deviceCmb->insertItem( "/dev/ttyU1" ); 55 m_deviceCmb->insertItem( "/dev/ttyU1" );
56} 56}
57 57
58BTConfigWidget::~BTConfigWidget() { 58BTConfigWidget::~BTConfigWidget() {
59 59
60} 60}
61void BTConfigWidget::load( const Profile& prof ) { 61void BTConfigWidget::load( const Profile& prof ) {
62 int rad_flow = prof.readNumEntry("Flow"); 62 int rad_flow = prof.readNumEntry("Flow");
63 int rad_parity = prof.readNumEntry("Parity"); 63 int rad_parity = prof.readNumEntry("Parity");
64 int speed = prof.readNumEntry("Speed"); 64 int speed = prof.readNumEntry("Speed");
65 QString mac = prof.readEntry("Mac"); 65 QString mac = prof.readEntry("Mac");
66 66
67 if (!mac.isEmpty() ) { 67 if (!mac.isEmpty() ) {
68 m_mac->setText( mac ); 68 m_mac->setText( mac );
69 } else { 69 } else {
70 m_devRadio->setChecked( true ); 70 m_devRadio->setChecked( true );
71 } 71 }
72 72
73 if (rad_flow == 1) { 73 if (rad_flow == 1) {
74 m_base->setFlow( IOLayerBase::Hardware ); 74 m_base->setFlow( IOLayerBase::Hardware );
75 } else if (rad_flow == 2) { 75 } else if (rad_flow == 2) {
76 m_base->setFlow( IOLayerBase::Software ); 76 m_base->setFlow( IOLayerBase::Software );
77 } else if (rad_flow == 0) { 77 } else if (rad_flow == 0) {
78 m_base->setFlow( IOLayerBase::None ); 78 m_base->setFlow( IOLayerBase::None );
79 } 79 }
80 80
81 if (rad_parity == 1) { 81 if (rad_parity == 1) {
82 m_base->setParity( IOLayerBase::Even ); 82 m_base->setParity( IOLayerBase::Even );
83 } else if ( rad_parity == 2 ) { 83 } else if ( rad_parity == 2 ) {
84 m_base->setParity( IOLayerBase::Odd ); 84 m_base->setParity( IOLayerBase::Odd );
85 } else { 85 } else {
86 m_base->setParity( IOLayerBase::NonePar ); 86 m_base->setParity( IOLayerBase::NonePar );
87 } 87 }
88 88
89 switch( speed ) { 89 switch( speed ) {
90 case 115200: 90 case 115200:
91 m_base->setSpeed(IOLayerBase::Baud_115200 ); 91 m_base->setSpeed(IOLayerBase::Baud_115200 );
92 break; 92 break;
93 case 57600: 93 case 57600:
94 m_base->setSpeed( IOLayerBase::Baud_57600 ); 94 m_base->setSpeed( IOLayerBase::Baud_57600 );
95 break; 95 break;
96 case 38400: 96 case 38400:
97 m_base->setSpeed(IOLayerBase::Baud_38400 ); 97 m_base->setSpeed(IOLayerBase::Baud_38400 );
98 break; 98 break;
99 case 19200: 99 case 19200:
100 m_base->setSpeed( IOLayerBase::Baud_19200 ); 100 m_base->setSpeed( IOLayerBase::Baud_19200 );
101 break; 101 break;
102 case 4800: 102 case 4800:
103 m_base->setSpeed( IOLayerBase::Baud_4800 ); 103 m_base->setSpeed( IOLayerBase::Baud_4800 );
104 break; 104 break;
105 case 2400: 105 case 2400:
106 m_base->setSpeed( IOLayerBase::Baud_2400 ); 106 m_base->setSpeed( IOLayerBase::Baud_2400 );
107 break; 107 break;
108 case 1200: 108 case 1200:
109 m_base->setSpeed( IOLayerBase::Baud_1200 ); 109 m_base->setSpeed( IOLayerBase::Baud_1200 );
110 break; 110 break;
111 case 9600: 111 case 9600:
112 default: 112 default:
113 m_base->setSpeed(IOLayerBase::Baud_9600 ); 113 m_base->setSpeed(IOLayerBase::Baud_9600 );
114 break; 114 break;
115 } 115 }
116 116
117 if ( prof.readEntry("Device").isEmpty() ) return; 117 if ( prof.readEntry("Device").isEmpty() ) return;
118 setCurrent( prof.readEntry("Device"), m_deviceCmb ); 118 setCurrent( prof.readEntry("Device"), m_deviceCmb );
119 119
120} 120}
121/* 121/*
122 * save speed, 122 * save speed,
123 * flow, 123 * flow,
124 * parity 124 * parity
125 */ 125 */
126void BTConfigWidget::save( Profile& prof ) { 126void BTConfigWidget::save( Profile& prof ) {
127 int flow, parity, speed; 127 int flow, parity, speed;
128 flow = parity = speed = 0; 128 flow = parity = speed = 0;
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_4800: 169 case IOLayerBase::Baud_4800:
170 speed = 4800; 170 speed = 4800;
171 break; 171 break;
172 case IOLayerBase::Baud_2400: 172 case IOLayerBase::Baud_2400:
173 speed = 2400; 173 speed = 2400;
174 break; 174 break;
175 case IOLayerBase::Baud_1200; 175 case IOLayerBase::Baud_1200:
176 speed = 1200; 176 speed = 1200;
177 break; 177 break;
178 default: 178 default:
179 case IOLayerBase::Baud_9600: 179 case IOLayerBase::Baud_9600:
180 speed = 9600; 180 speed = 9600;
181 break; 181 break;
182 } 182 }
183 183
184 prof.writeEntry("Flow", flow); 184 prof.writeEntry("Flow", flow);
185 prof.writeEntry("Parity", parity); 185 prof.writeEntry("Parity", parity);
186 prof.writeEntry("Speed", speed); 186 prof.writeEntry("Speed", speed);
187 prof.writeEntry("Mac", m_mac->text() ); 187 prof.writeEntry("Mac", m_mac->text() );
188} 188}
189 189
190void BTConfigWidget::slotMacRadio( bool on ) { 190void BTConfigWidget::slotMacRadio( bool on ) {
191 if ( on ) { 191 if ( on ) {
192 m_devRadio->setChecked( false ); 192 m_devRadio->setChecked( false );
193 m_deviceCmb->setEnabled( false ); 193 m_deviceCmb->setEnabled( false );
194 m_mac->setEnabled( true ); 194 m_mac->setEnabled( true );
195 } else { 195 } else {
196 m_devRadio->setChecked( true ); 196 m_devRadio->setChecked( true );
197 } 197 }
198} 198}
199 199
200void BTConfigWidget::slotDevRadio( bool on ) { 200void BTConfigWidget::slotDevRadio( bool on ) {
201 if ( on ) { 201 if ( on ) {
202 m_macRadio->setChecked( false ); 202 m_macRadio->setChecked( false );
203 m_deviceCmb->setEnabled( true ); 203 m_deviceCmb->setEnabled( true );
204 m_mac->setEnabled( false ); 204 m_mac->setEnabled( false );
205 } else { 205 } else {
206 m_macRadio->setChecked( true ); 206 m_macRadio->setChecked( true );
207 } 207 }
208} 208}