summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/btconfigwidget.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/btconfigwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/btconfigwidget.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp
index acc4811..eac6a79 100644
--- a/noncore/apps/opie-console/btconfigwidget.cpp
+++ b/noncore/apps/opie-console/btconfigwidget.cpp
@@ -1,73 +1,84 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qlineedit.h>
3#include <qcombobox.h> 4#include <qcombobox.h>
4 5
5#include "iolayerbase.h" 6#include "iolayerbase.h"
6#include "btconfigwidget.h" 7#include "btconfigwidget.h"
7 8
8namespace { 9namespace {
9 void setCurrent( const QString& str, QComboBox* bo ) { 10 void setCurrent( const QString& str, QComboBox* bo ) {
10 uint b = bo->count(); 11 uint b = bo->count();
11 for (uint i = 0; i < bo->count(); i++ ) { 12 for (uint i = 0; i < bo->count(); i++ ) {
12 if ( bo->text(i) == str ) { 13 if ( bo->text(i) == str ) {
13 bo->setCurrentItem( i ); 14 bo->setCurrentItem( i );
14 return; 15 return;
15 } 16 }
16 } 17 }
17 bo->insertItem( str ); 18 bo->insertItem( str );
18 bo->setCurrentItem( b ); 19 bo->setCurrentItem( b );
19 } 20 }
20} 21}
21 22
22BTConfigWidget::BTConfigWidget( const QString& name, 23BTConfigWidget::BTConfigWidget( const QString& name,
23 QWidget* parent, 24 QWidget* parent,
24 const char* na ) 25 const char* na )
25 : ProfileDialogConnectionWidget( name, parent, na ) { 26 : ProfileDialogConnectionWidget( name, parent, na ) {
26 27
27 m_lay = new QVBoxLayout(this ); 28 m_lay = new QVBoxLayout(this );
28 m_device = new QLabel(tr("Device"), this ); 29 m_device = new QLabel(tr("Device"), this );
29 m_deviceCmb = new QComboBox(this ); 30 m_deviceCmb = new QComboBox(this );
30 m_deviceCmb->setEditable( TRUE ); 31 m_deviceCmb->setEditable( TRUE );
31 32
33 QLabel *macLabel = new QLabel( this );
34 macLabel->setText( tr("Enter peer mac address here:") );
35 m_mac = new QLineEdit( this );
36
32 m_base = new IOLayerBase(this, "base"); 37 m_base = new IOLayerBase(this, "base");
33 38
34 m_lay->addWidget( m_device ); 39 m_lay->addWidget( m_device );
35 m_lay->addWidget( m_deviceCmb ); 40 m_lay->addWidget( m_deviceCmb );
41 m_lay->addWidget( macLabel );
42 m_lay->addWidget( m_mac );
36 m_lay->addWidget( m_base ); 43 m_lay->addWidget( m_base );
37 44
38 m_deviceCmb->insertItem( "/dev/ttyU0" ); 45 m_deviceCmb->insertItem( "/dev/ttyU0" );
39 m_deviceCmb->insertItem( "/dev/ttyU1" ); 46 m_deviceCmb->insertItem( "/dev/ttyU1" );
40} 47}
41 48
42BTConfigWidget::~BTConfigWidget() { 49BTConfigWidget::~BTConfigWidget() {
43 50
44} 51}
45void BTConfigWidget::load( const Profile& prof ) { 52void BTConfigWidget::load( const Profile& prof ) {
46 int rad_flow = prof.readNumEntry("Flow"); 53 int rad_flow = prof.readNumEntry("Flow");
47 int rad_parity = prof.readNumEntry("Parity"); 54 int rad_parity = prof.readNumEntry("Parity");
48 int speed = prof.readNumEntry("Speed"); 55 int speed = prof.readNumEntry("Speed");
56 QString mac = prof.readEntry("Mac");
49 57
58 if (!mac.isEmpty() ) {
59 m_mac->setText( mac );
60 }
50 61
51 if (rad_flow == 1) { 62 if (rad_flow == 1) {
52 m_base->setFlow( IOLayerBase::Hardware ); 63 m_base->setFlow( IOLayerBase::Hardware );
53 } else if (rad_flow == 2) { 64 } else if (rad_flow == 2) {
54 m_base->setFlow( IOLayerBase::Software ); 65 m_base->setFlow( IOLayerBase::Software );
55 } else if (rad_flow == 0) { 66 } else if (rad_flow == 0) {
56 m_base->setFlow( IOLayerBase::None ); 67 m_base->setFlow( IOLayerBase::None );
57 } 68 }
58 69
59 if (rad_parity == 1) { 70 if (rad_parity == 1) {
60 m_base->setParity( IOLayerBase::Even ); 71 m_base->setParity( IOLayerBase::Even );
61 } else { 72 } else {
62 m_base->setParity( IOLayerBase::Odd ); 73 m_base->setParity( IOLayerBase::Odd );
63 } 74 }
64 75
65 switch( speed ) { 76 switch( speed ) {
66 case 115200: 77 case 115200:
67 m_base->setSpeed(IOLayerBase::Baud_115200 ); 78 m_base->setSpeed(IOLayerBase::Baud_115200 );
68 break; 79 break;
69 case 57600: 80 case 57600:
70 m_base->setSpeed( IOLayerBase::Baud_57600 ); 81 m_base->setSpeed( IOLayerBase::Baud_57600 );
71 break; 82 break;
72 case 38400: 83 case 38400:
73 m_base->setSpeed(IOLayerBase::Baud_38400 ); 84 m_base->setSpeed(IOLayerBase::Baud_38400 );
@@ -116,25 +127,26 @@ void BTConfigWidget::save( Profile& prof ) {
116 break; 127 break;
117 } 128 }
118 129
119 switch( m_base->speed() ) { 130 switch( m_base->speed() ) {
120 case IOLayerBase::Baud_115200: 131 case IOLayerBase::Baud_115200:
121 speed = 115200; 132 speed = 115200;
122 break; 133 break;
123 case IOLayerBase::Baud_57600: 134 case IOLayerBase::Baud_57600:
124 speed = 57600; 135 speed = 57600;
125 break; 136 break;
126 case IOLayerBase::Baud_38400: 137 case IOLayerBase::Baud_38400:
127 speed = 38400; 138 speed = 38400;
128 break; 139 break;
129 case IOLayerBase::Baud_19200: 140 case IOLayerBase::Baud_19200:
130 speed = 19200; 141 speed = 19200;
131 break; 142 break;
132 case IOLayerBase::Baud_9600: 143 case IOLayerBase::Baud_9600:
133 speed = 9600; 144 speed = 9600;
134 break; 145 break;
135 } 146 }
136 147
137 prof.writeEntry("Flow", flow); 148 prof.writeEntry("Flow", flow);
138 prof.writeEntry("Parity", parity); 149 prof.writeEntry("Parity", parity);
139 prof.writeEntry("Speed", speed); 150 prof.writeEntry("Speed", speed);
151 prof.writeEntry("Mac", m_mac->text() );
140} 152}