-rw-r--r-- | noncore/apps/opie-console/irdaconfigwidget.cpp | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/serialconfigwidget.cpp | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/noncore/apps/opie-console/irdaconfigwidget.cpp b/noncore/apps/opie-console/irdaconfigwidget.cpp index 1cc041b..2341fd4 100644 --- a/noncore/apps/opie-console/irdaconfigwidget.cpp +++ b/noncore/apps/opie-console/irdaconfigwidget.cpp | |||
@@ -1,141 +1,141 @@ | |||
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 | 4 | ||
5 | #include "iolayerbase.h" | 5 | #include "iolayerbase.h" |
6 | #include "irdaconfigwidget.h" | 6 | #include "irdaconfigwidget.h" |
7 | 7 | ||
8 | namespace { | 8 | namespace { |
9 | void setCurrent( const QString& str, QComboBox* bo ) { | 9 | void setCurrent( const QString& str, QComboBox* bo ) { |
10 | uint b = bo->count(); | 10 | uint b = bo->count(); |
11 | for (uint i = 0; i < bo->count(); i++ ) { | 11 | for (uint i = 0; i < bo->count(); i++ ) { |
12 | if ( bo->text(i) == str ) { | 12 | if ( bo->text(i) == str ) { |
13 | bo->setCurrentItem( i ); | 13 | bo->setCurrentItem( i ); |
14 | return; | 14 | return; |
15 | } | 15 | } |
16 | } | 16 | } |
17 | bo->insertItem( str ); | 17 | bo->insertItem( str ); |
18 | bo->setCurrentItem( b ); | 18 | bo->setCurrentItem( b ); |
19 | } | 19 | } |
20 | 20 | ||
21 | 21 | ||
22 | } | 22 | } |
23 | 23 | ||
24 | IrdaConfigWidget::IrdaConfigWidget( const QString& name, | 24 | IrdaConfigWidget::IrdaConfigWidget( const QString& name, |
25 | QWidget* parent, | 25 | QWidget* parent, |
26 | const char* na ) | 26 | const char* na ) |
27 | : ProfileDialogConnectionWidget( name, parent, na ) { | 27 | : ProfileDialogConnectionWidget( name, parent, na ) { |
28 | 28 | ||
29 | m_lay = new QVBoxLayout(this ); | 29 | m_lay = new QVBoxLayout(this ); |
30 | m_device = new QLabel(tr("Device"), this ); | 30 | m_device = new QLabel(tr("Device"), this ); |
31 | m_deviceCmb = new QComboBox(this ); | 31 | m_deviceCmb = new QComboBox(this ); |
32 | m_deviceCmb->setEditable( TRUE ); | 32 | m_deviceCmb->setEditable( TRUE ); |
33 | 33 | ||
34 | m_base = new IOLayerBase(this, "base"); | 34 | m_base = new IOLayerBase(this, "base"); |
35 | 35 | ||
36 | m_lay->addWidget( m_device ); | 36 | m_lay->addWidget( m_device ); |
37 | m_lay->addWidget( m_deviceCmb ); | 37 | m_lay->addWidget( m_deviceCmb ); |
38 | m_lay->addWidget( m_base ); | 38 | m_lay->addWidget( m_base ); |
39 | 39 | ||
40 | m_deviceCmb->insertItem( "/dev/ircomm0" ); | 40 | m_deviceCmb->insertItem( "/dev/ircomm0" ); |
41 | m_deviceCmb->insertItem( "/dev/ircomm1" ); | 41 | m_deviceCmb->insertItem( "/dev/ircomm1" ); |
42 | } | 42 | } |
43 | 43 | ||
44 | IrdaConfigWidget::~IrdaConfigWidget() { | 44 | IrdaConfigWidget::~IrdaConfigWidget() { |
45 | 45 | ||
46 | } | 46 | } |
47 | void IrdaConfigWidget::load( const Profile& prof ) { | 47 | void IrdaConfigWidget::load( const Profile& prof ) { |
48 | int rad_flow = prof.readNumEntry("Flow"); | 48 | int rad_flow = prof.readNumEntry("Flow"); |
49 | int rad_parity = prof.readNumEntry("Parity"); | 49 | int rad_parity = prof.readNumEntry("Parity"); |
50 | int speed = prof.readNumEntry("Speed"); | 50 | int speed = prof.readNumEntry("Speed"); |
51 | 51 | ||
52 | if (rad_flow == 1) { | 52 | if (rad_flow == 1) { |
53 | m_base->setFlow( IOLayerBase::Hardware ); | 53 | m_base->setFlow( IOLayerBase::Hardware ); |
54 | } else if (rad_flow == 2) { | 54 | } else if (rad_flow == 2) { |
55 | m_base->setFlow( IOLayerBase::Software ); | 55 | m_base->setFlow( IOLayerBase::Software ); |
56 | } else if (rad_flow == 0) { | 56 | } else { |
57 | m_base->setFlow( IOLayerBase::None ); | 57 | m_base->setFlow( IOLayerBase::None ); |
58 | } | 58 | } |
59 | 59 | ||
60 | if (rad_parity == 1) { | 60 | if (rad_parity == 1) { |
61 | m_base->setParity( IOLayerBase::Even ); | 61 | m_base->setParity( IOLayerBase::Even ); |
62 | } else { | 62 | } else { |
63 | m_base->setParity( IOLayerBase::Odd ); | 63 | m_base->setParity( IOLayerBase::Odd ); |
64 | } | 64 | } |
65 | 65 | ||
66 | switch( speed ) { | 66 | switch( speed ) { |
67 | case 115200: | 67 | case 115200: |
68 | m_base->setSpeed(IOLayerBase::Baud_115200 ); | 68 | m_base->setSpeed(IOLayerBase::Baud_115200 ); |
69 | break; | 69 | break; |
70 | case 57600: | 70 | case 57600: |
71 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | 71 | m_base->setSpeed( IOLayerBase::Baud_57600 ); |
72 | break; | 72 | break; |
73 | case 38400: | 73 | case 38400: |
74 | m_base->setSpeed(IOLayerBase::Baud_38400 ); | 74 | m_base->setSpeed(IOLayerBase::Baud_38400 ); |
75 | break; | 75 | break; |
76 | case 19200: | 76 | case 19200: |
77 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | 77 | m_base->setSpeed( IOLayerBase::Baud_19200 ); |
78 | break; | 78 | break; |
79 | case 9600: | 79 | case 9600: |
80 | default: | 80 | default: |
81 | m_base->setSpeed(IOLayerBase::Baud_9600 ); | 81 | m_base->setSpeed(IOLayerBase::Baud_9600 ); |
82 | break; | 82 | break; |
83 | } | 83 | } |
84 | 84 | ||
85 | if ( prof.readEntry("Device").isEmpty() ) return; | 85 | if ( prof.readEntry("Device").isEmpty() ) return; |
86 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); | 86 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); |
87 | 87 | ||
88 | } | 88 | } |
89 | /* | 89 | /* |
90 | * save speed, | 90 | * save speed, |
91 | * flow, | 91 | * flow, |
92 | * parity | 92 | * parity |
93 | */ | 93 | */ |
94 | void IrdaConfigWidget::save( Profile& prof ) { | 94 | void IrdaConfigWidget::save( Profile& prof ) { |
95 | int flow, parity, speed; | 95 | int flow, parity, speed; |
96 | prof.writeEntry("Device", m_deviceCmb->currentText() ); | 96 | prof.writeEntry("Device", m_deviceCmb->currentText() ); |
97 | 97 | ||
98 | switch( m_base->flow() ) { | 98 | switch( m_base->flow() ) { |
99 | case IOLayerBase::None: | 99 | case IOLayerBase::None: |
100 | flow = 0; | 100 | flow = 0; |
101 | break; | 101 | break; |
102 | case IOLayerBase::Software: | 102 | case IOLayerBase::Software: |
103 | flow = 2; | 103 | flow = 2; |
104 | break; | 104 | break; |
105 | case IOLayerBase::Hardware: | 105 | case IOLayerBase::Hardware: |
106 | flow = 1; | 106 | flow = 1; |
107 | break; | 107 | break; |
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | switch( m_base->parity() ) { | 111 | switch( m_base->parity() ) { |
112 | case IOLayerBase::Odd: | 112 | case IOLayerBase::Odd: |
113 | parity = 2; | 113 | parity = 2; |
114 | break; | 114 | break; |
115 | case IOLayerBase::Even: | 115 | case IOLayerBase::Even: |
116 | parity = 1; | 116 | parity = 1; |
117 | break; | 117 | break; |
118 | } | 118 | } |
119 | 119 | ||
120 | switch( m_base->speed() ) { | 120 | switch( m_base->speed() ) { |
121 | case IOLayerBase::Baud_115200: | 121 | case IOLayerBase::Baud_115200: |
122 | speed = 115200; | 122 | speed = 115200; |
123 | break; | 123 | break; |
124 | case IOLayerBase::Baud_57600: | 124 | case IOLayerBase::Baud_57600: |
125 | speed = 57600; | 125 | speed = 57600; |
126 | break; | 126 | break; |
127 | case IOLayerBase::Baud_38400: | 127 | case IOLayerBase::Baud_38400: |
128 | speed = 38400; | 128 | speed = 38400; |
129 | break; | 129 | break; |
130 | case IOLayerBase::Baud_19200: | 130 | case IOLayerBase::Baud_19200: |
131 | speed = 19200; | 131 | speed = 19200; |
132 | break; | 132 | break; |
133 | case IOLayerBase::Baud_9600: | 133 | case IOLayerBase::Baud_9600: |
134 | speed = 9600; | 134 | speed = 9600; |
135 | break; | 135 | break; |
136 | } | 136 | } |
137 | 137 | ||
138 | prof.writeEntry("Flow", flow); | 138 | prof.writeEntry("Flow", flow); |
139 | prof.writeEntry("Parity", parity); | 139 | prof.writeEntry("Parity", parity); |
140 | prof.writeEntry("Speed", speed); | 140 | prof.writeEntry("Speed", speed); |
141 | } | 141 | } |
diff --git a/noncore/apps/opie-console/serialconfigwidget.cpp b/noncore/apps/opie-console/serialconfigwidget.cpp index b1ec408..89acc98 100644 --- a/noncore/apps/opie-console/serialconfigwidget.cpp +++ b/noncore/apps/opie-console/serialconfigwidget.cpp | |||
@@ -1,141 +1,142 @@ | |||
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 | 4 | ||
5 | #include "iolayerbase.h" | 5 | #include "iolayerbase.h" |
6 | #include "serialconfigwidget.h" | 6 | #include "serialconfigwidget.h" |
7 | 7 | ||
8 | namespace { | 8 | namespace { |
9 | void setCurrent( const QString& str, QComboBox* bo ) { | 9 | void setCurrent( const QString& str, QComboBox* bo ) { |
10 | uint b = bo->count(); | 10 | uint b = bo->count(); |
11 | for (uint i = 0; i < bo->count(); i++ ) { | 11 | for (uint i = 0; i < bo->count(); i++ ) { |
12 | if ( bo->text(i) == str ) { | 12 | if ( bo->text(i) == str ) { |
13 | bo->setCurrentItem( i ); | 13 | bo->setCurrentItem( i ); |
14 | return; | 14 | return; |
15 | } | 15 | } |
16 | } | 16 | } |
17 | bo->insertItem( str ); | 17 | bo->insertItem( str ); |
18 | bo->setCurrentItem( b ); | 18 | bo->setCurrentItem( b ); |
19 | } | 19 | } |
20 | 20 | ||
21 | 21 | ||
22 | } | 22 | } |
23 | 23 | ||
24 | SerialConfigWidget::SerialConfigWidget( const QString& name, | 24 | SerialConfigWidget::SerialConfigWidget( const QString& name, |
25 | QWidget* parent, | 25 | QWidget* parent, |
26 | const char* na ) | 26 | const char* na ) |
27 | : ProfileDialogConnectionWidget( name, parent, na ) { | 27 | : ProfileDialogConnectionWidget( name, parent, na ) { |
28 | 28 | ||
29 | m_lay = new QVBoxLayout(this ); | 29 | m_lay = new QVBoxLayout(this ); |
30 | m_device = new QLabel(tr("Device"), this ); | 30 | m_device = new QLabel(tr("Device"), this ); |
31 | m_deviceCmb = new QComboBox(this ); | 31 | m_deviceCmb = new QComboBox(this ); |
32 | m_deviceCmb->setEditable( TRUE ); | 32 | m_deviceCmb->setEditable( TRUE ); |
33 | 33 | ||
34 | m_base = new IOLayerBase(this, "base"); | 34 | m_base = new IOLayerBase(this, "base"); |
35 | 35 | ||
36 | m_lay->addWidget( m_device ); | 36 | m_lay->addWidget( m_device ); |
37 | m_lay->addWidget( m_deviceCmb ); | 37 | m_lay->addWidget( m_deviceCmb ); |
38 | m_lay->addWidget( m_base ); | 38 | m_lay->addWidget( m_base ); |
39 | 39 | ||
40 | m_deviceCmb->insertItem( "/dev/ttyS0" ); | 40 | m_deviceCmb->insertItem( "/dev/ttyS0" ); |
41 | m_deviceCmb->insertItem( "/dev/ttyS1" ); | 41 | m_deviceCmb->insertItem( "/dev/ttyS1" ); |
42 | m_deviceCmb->insertItem( "/dev/ttySA0"); | 42 | m_deviceCmb->insertItem( "/dev/ttySA0"); |
43 | m_deviceCmb->insertItem( "/dev/ttySA1"); | 43 | m_deviceCmb->insertItem( "/dev/ttySA1"); |
44 | 44 | ||
45 | } | 45 | } |
46 | SerialConfigWidget::~SerialConfigWidget() { | 46 | SerialConfigWidget::~SerialConfigWidget() { |
47 | 47 | ||
48 | } | 48 | } |
49 | void SerialConfigWidget::load( const Profile& prof ) { | 49 | void SerialConfigWidget::load( const Profile& prof ) { |
50 | int rad_flow = prof.readNumEntry("Flow"); | 50 | int rad_flow = prof.readNumEntry("Flow"); |
51 | int rad_parity = prof.readNumEntry("Parity"); | 51 | int rad_parity = prof.readNumEntry("Parity"); |
52 | int speed = prof.readNumEntry("Speed"); | 52 | int speed = prof.readNumEntry("Speed"); |
53 | 53 | ||
54 | if (rad_flow == 1) { | 54 | if (rad_flow == 1) { |
55 | m_base->setFlow( IOLayerBase::Hardware ); | 55 | m_base->setFlow( IOLayerBase::Hardware ); |
56 | } else if (rad_flow == 2) { | 56 | } else if (rad_flow == 2) { |
57 | m_base->setFlow( IOLayerBase::Software ); | 57 | m_base->setFlow( IOLayerBase::Software ); |
58 | } else if (rad_flow == 0) { | 58 | } else { |
59 | m_base->setFlow( IOLayerBase::None ); | 59 | m_base->setFlow( IOLayerBase::None ); |
60 | } | 60 | } |
61 | 61 | ||
62 | if (rad_parity == 1) | 62 | if (rad_parity == 1) { |
63 | m_base->setParity( IOLayerBase::Even ); | 63 | m_base->setParity( IOLayerBase::Even ); |
64 | else | 64 | } else { |
65 | m_base->setParity( IOLayerBase::Odd ); | 65 | m_base->setParity( IOLayerBase::Odd ); |
66 | } | ||
66 | 67 | ||
67 | switch( speed ) { | 68 | switch( speed ) { |
68 | case 115200: | 69 | case 115200: |
69 | m_base->setSpeed(IOLayerBase::Baud_115200 ); | 70 | m_base->setSpeed(IOLayerBase::Baud_115200 ); |
70 | break; | 71 | break; |
71 | case 57600: | 72 | case 57600: |
72 | m_base->setSpeed( IOLayerBase::Baud_57600 ); | 73 | m_base->setSpeed( IOLayerBase::Baud_57600 ); |
73 | break; | 74 | break; |
74 | case 38400: | 75 | case 38400: |
75 | m_base->setSpeed(IOLayerBase::Baud_38400 ); | 76 | m_base->setSpeed(IOLayerBase::Baud_38400 ); |
76 | break; | 77 | break; |
77 | case 19200: | 78 | case 19200: |
78 | m_base->setSpeed( IOLayerBase::Baud_19200 ); | 79 | m_base->setSpeed( IOLayerBase::Baud_19200 ); |
79 | break; | 80 | break; |
80 | case 9600: | 81 | case 9600: |
81 | default: | 82 | default: |
82 | m_base->setSpeed(IOLayerBase::Baud_9600 ); | 83 | m_base->setSpeed(IOLayerBase::Baud_9600 ); |
83 | break; | 84 | break; |
84 | } | 85 | } |
85 | 86 | ||
86 | if ( prof.readEntry("Device").isEmpty() ) return; | 87 | if ( prof.readEntry("Device").isEmpty() ) return; |
87 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); | 88 | setCurrent( prof.readEntry("Device"), m_deviceCmb ); |
88 | 89 | ||
89 | } | 90 | } |
90 | /* | 91 | /* |
91 | * save speed, | 92 | * save speed, |
92 | * flow, | 93 | * flow, |
93 | * parity | 94 | * parity |
94 | */ | 95 | */ |
95 | void SerialConfigWidget::save( Profile& prof ) { | 96 | void SerialConfigWidget::save( Profile& prof ) { |
96 | int flow, parity, speed; | 97 | int flow, parity, speed; |
97 | prof.writeEntry("Device", m_deviceCmb->currentText() ); | 98 | prof.writeEntry("Device", m_deviceCmb->currentText() ); |
98 | 99 | ||
99 | switch( m_base->flow() ) { | 100 | switch( m_base->flow() ) { |
100 | case IOLayerBase::None: | 101 | case IOLayerBase::None: |
101 | flow = 0; | 102 | flow = 0; |
102 | break; | 103 | break; |
103 | case IOLayerBase::Software: | 104 | case IOLayerBase::Software: |
104 | flow = 2; | 105 | flow = 2; |
105 | break; | 106 | break; |
106 | case IOLayerBase::Hardware: | 107 | case IOLayerBase::Hardware: |
107 | flow = 1; | 108 | flow = 1; |
108 | break; | 109 | break; |
109 | } | 110 | } |
110 | 111 | ||
111 | switch( m_base->parity() ) { | 112 | switch( m_base->parity() ) { |
112 | case IOLayerBase::Odd: | 113 | case IOLayerBase::Odd: |
113 | parity = 2; | 114 | parity = 2; |
114 | break; | 115 | break; |
115 | case IOLayerBase::Even: | 116 | case IOLayerBase::Even: |
116 | parity = 1; | 117 | parity = 1; |
117 | break; | 118 | break; |
118 | } | 119 | } |
119 | 120 | ||
120 | switch( m_base->speed() ) { | 121 | switch( m_base->speed() ) { |
121 | case IOLayerBase::Baud_115200: | 122 | case IOLayerBase::Baud_115200: |
122 | speed = 115200; | 123 | speed = 115200; |
123 | break; | 124 | break; |
124 | case IOLayerBase::Baud_57600: | 125 | case IOLayerBase::Baud_57600: |
125 | speed = 57600; | 126 | speed = 57600; |
126 | break; | 127 | break; |
127 | case IOLayerBase::Baud_38400: | 128 | case IOLayerBase::Baud_38400: |
128 | speed = 38400; | 129 | speed = 38400; |
129 | break; | 130 | break; |
130 | case IOLayerBase::Baud_19200: | 131 | case IOLayerBase::Baud_19200: |
131 | speed = 19200; | 132 | speed = 19200; |
132 | break; | 133 | break; |
133 | case IOLayerBase::Baud_9600: | 134 | case IOLayerBase::Baud_9600: |
134 | speed = 9600; | 135 | speed = 9600; |
135 | break; | 136 | break; |
136 | } | 137 | } |
137 | 138 | ||
138 | prof.writeEntry("Flow", flow); | 139 | prof.writeEntry("Flow", flow); |
139 | prof.writeEntry("Parity", parity); | 140 | prof.writeEntry("Parity", parity); |
140 | prof.writeEntry("Speed", speed); | 141 | prof.writeEntry("Speed", speed); |
141 | } | 142 | } |