Diffstat (limited to 'noncore/apps/opie-console/profileeditorplugins.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/profileeditorplugins.cpp | 303 |
1 files changed, 303 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/profileeditorplugins.cpp b/noncore/apps/opie-console/profileeditorplugins.cpp index a11d6b0..32e8235 100644 --- a/noncore/apps/opie-console/profileeditorplugins.cpp +++ b/noncore/apps/opie-console/profileeditorplugins.cpp | |||
@@ -8,2 +8,10 @@ | |||
8 | #include "qlayout.h" | 8 | #include "qlayout.h" |
9 | #include "qcombobox.h" | ||
10 | #include "qradiobutton.h" | ||
11 | #include "qcheckbox.h" | ||
12 | #include "qbuttongroup.h" | ||
13 | |||
14 | #include "io_serial.h" | ||
15 | |||
16 | // Base class | ||
9 | 17 | ||
@@ -21,2 +29,287 @@ ProfileEditorPlugin::~ProfileEditorPlugin() | |||
21 | 29 | ||
30 | QWidget *ProfileEditorPlugin::connection_widget() | ||
31 | { | ||
32 | QWidget *root; | ||
33 | QVBoxLayout *lroot; | ||
34 | |||
35 | root = new QWidget(); | ||
36 | |||
37 | // Build GUI | ||
38 | |||
39 | QComboBox *speed_box = new QComboBox(root); | ||
40 | speed_box->insertItem("115200 baud", id_baud_115200); | ||
41 | speed_box->insertItem("57600 baud", id_baud_57600); | ||
42 | speed_box->insertItem("38400 baud", id_baud_38400); | ||
43 | speed_box->insertItem("19200 baud", id_baud_19200); | ||
44 | speed_box->insertItem("9600 baud", id_baud_9600); | ||
45 | |||
46 | QLabel *speedlabel = new QLabel(QObject::tr("Speed"), root); | ||
47 | QLabel *flow = new QLabel(QObject::tr("Flow control"), root); | ||
48 | QLabel *parity = new QLabel(QObject::tr("Parity"), root); | ||
49 | |||
50 | QButtonGroup *group_flow = new QButtonGroup(root); | ||
51 | group_flow->hide(); | ||
52 | QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), root); | ||
53 | QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), root); | ||
54 | group_flow->insert(flow_hw, id_flow_hw); | ||
55 | group_flow->insert(flow_sw, id_flow_sw); | ||
56 | |||
57 | QButtonGroup *group_parity = new QButtonGroup(root); | ||
58 | group_parity->hide(); | ||
59 | QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), root); | ||
60 | QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), root); | ||
61 | group_parity->insert(parity_odd, id_parity_odd); | ||
62 | group_parity->insert(parity_even, id_parity_even); | ||
63 | |||
64 | // Build Layout | ||
65 | |||
66 | lroot = new QVBoxLayout(root); | ||
67 | lroot->add(speedlabel); | ||
68 | lroot->add(speed_box); | ||
69 | lroot->add(flow); | ||
70 | QHBoxLayout *hbox = new QHBoxLayout(lroot, 2); | ||
71 | hbox->add(flow_hw); | ||
72 | hbox->add(flow_sw); | ||
73 | lroot->add(parity); | ||
74 | QHBoxLayout *hbox2 = new QHBoxLayout(lroot, 2); | ||
75 | hbox2->add(parity_odd); | ||
76 | hbox2->add(parity_even); | ||
77 | |||
78 | // Apply profile settings | ||
79 | int rad_flow = m_profile.readNumEntry("Flow"); | ||
80 | int rad_parity = m_profile.readNumEntry("Parity"); | ||
81 | int speed = m_profile.readNumEntry("Speed"); | ||
82 | |||
83 | if(rad_flow == IOSerial::FlowHW) flow_hw->setChecked(true); | ||
84 | else flow_sw->setChecked(true); | ||
85 | if(rad_parity == IOSerial::ParityEven) parity_even->setChecked(true); | ||
86 | else parity_odd->setChecked(true); | ||
87 | if(speed == 115200) speed_box->setCurrentItem(id_baud_115200); | ||
88 | if(speed == 57600) speed_box->setCurrentItem(id_baud_57600); | ||
89 | if(speed == 38400) speed_box->setCurrentItem(id_baud_38400); | ||
90 | if(speed == 19200) speed_box->setCurrentItem(id_baud_19200); | ||
91 | if(speed == 9600) speed_box->setCurrentItem(id_baud_9600); | ||
92 | |||
93 | // Signals | ||
94 | |||
95 | connect(group_flow, SIGNAL(clicked(int)), SLOT(slotConnFlow(int))); | ||
96 | connect(group_parity, SIGNAL(clicked(int)), SLOT(slotConnParity(int))); | ||
97 | connect(speed_box, SIGNAL(activated(int)), SLOT(slotConnSpeed(int))); | ||
98 | |||
99 | return root; | ||
100 | } | ||
101 | |||
102 | QWidget *ProfileEditorPlugin::terminal_widget() | ||
103 | { | ||
104 | QWidget *root; | ||
105 | QVBoxLayout *lroot; | ||
106 | |||
107 | root = new QWidget(); | ||
108 | |||
109 | // Build GUI | ||
110 | |||
111 | QComboBox *terminal_box = new QComboBox(root); | ||
112 | terminal_box->insertItem("VT 100", id_term_vt100); | ||
113 | terminal_box->insertItem("VT 220", id_term_vt220); | ||
114 | terminal_box->insertItem("ANSI", id_term_ansi); | ||
115 | |||
116 | QLabel *terminal = new QLabel(QObject::tr("Terminal type"), root); | ||
117 | QLabel *colourlabel = new QLabel(QObject::tr("Colour scheme"), root); | ||
118 | QLabel *sizelabel = new QLabel(QObject::tr("Font size"), root); | ||
119 | QLabel *options = new QLabel(QObject::tr("Options"), root); | ||
120 | QLabel *conversions = new QLabel(QObject::tr("Line-break conversions"), root); | ||
121 | |||
122 | QComboBox *colour_box = new QComboBox(root); | ||
123 | colour_box->insertItem(QObject::tr("black on white"), id_term_black); | ||
124 | colour_box->insertItem(QObject::tr("white on black"), id_term_white); | ||
125 | |||
126 | QButtonGroup *group_size = new QButtonGroup(root); | ||
127 | group_size->hide(); | ||
128 | QRadioButton *size_small = new QRadioButton(QObject::tr("small"), root); | ||
129 | QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), root); | ||
130 | QRadioButton *size_large = new QRadioButton(QObject::tr("large"), root); | ||
131 | group_size->insert(size_small); | ||
132 | group_size->insert(size_medium); | ||
133 | group_size->insert(size_large); | ||
134 | |||
135 | QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), root); | ||
136 | QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), root); | ||
137 | |||
138 | QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), root); | ||
139 | QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), root); | ||
140 | |||
141 | // Build Layout | ||
142 | |||
143 | lroot = new QVBoxLayout(root, 2); | ||
144 | lroot->add(terminal); | ||
145 | lroot->add(terminal_box); | ||
146 | lroot->add(sizelabel); | ||
147 | QHBoxLayout *hbox = new QHBoxLayout(lroot, 2); | ||
148 | hbox->add(size_small); | ||
149 | hbox->add(size_medium); | ||
150 | hbox->add(size_large); | ||
151 | lroot->add(colourlabel); | ||
152 | lroot->add(colour_box); | ||
153 | lroot->add(conversions); | ||
154 | QHBoxLayout *hbox2 = new QHBoxLayout(lroot, 2); | ||
155 | hbox2->add(conv_inbound); | ||
156 | hbox2->add(conv_outbound); | ||
157 | lroot->add(options); | ||
158 | QHBoxLayout *hbox3 = new QHBoxLayout(lroot, 2); | ||
159 | hbox3->add(option_wrap); | ||
160 | hbox3->add(option_echo); | ||
161 | |||
162 | // Apply profile settings | ||
163 | int term = m_profile.readNumEntry("Terminal"); | ||
164 | int colour = m_profile.readNumEntry("Colour"); | ||
165 | int fontsize = m_profile.readNumEntry("Font"); | ||
166 | int opt_echo = m_profile.readNumEntry("Echo"); | ||
167 | int opt_wrap = m_profile.readNumEntry("Wrap"); | ||
168 | int opt_inbound = m_profile.readNumEntry("Inbound"); | ||
169 | int opt_outbound = m_profile.readNumEntry("Outbound"); | ||
170 | |||
171 | if(term == Profile::VT102) terminal_box->setCurrentItem(id_term_vt100); | ||
172 | |||
173 | if(colour == Profile::Black) colour_box->setCurrentItem(id_term_black); | ||
174 | if(colour == Profile::White) colour_box->setCurrentItem(id_term_white); | ||
175 | |||
176 | if(fontsize == Profile::Micro) size_small->setChecked(true); | ||
177 | if(fontsize == Profile::Small) size_medium->setChecked(true); | ||
178 | if(fontsize == Profile::Medium) size_large->setChecked(true); | ||
179 | |||
180 | if(opt_echo) option_echo->setChecked(true); | ||
181 | if(opt_wrap) option_wrap->setChecked(true); | ||
182 | if(opt_inbound) conv_inbound->setChecked(true); | ||
183 | if(opt_outbound) conv_outbound->setChecked(true); | ||
184 | |||
185 | // Signals | ||
186 | |||
187 | connect(terminal_box, SIGNAL(activated(int)), SLOT(slotTermTerm(int))); | ||
188 | connect(colour_box, SIGNAL(activated(int)), SLOT(slotTermColour(int))); | ||
189 | connect(group_size, SIGNAL(clicked(int)), SLOT(slotTermFont(int))); | ||
190 | |||
191 | connect(option_echo, SIGNAL(toggled(bool)), SLOT(slotTermEcho(bool))); | ||
192 | connect(option_wrap, SIGNAL(toggled(bool)), SLOT(slotTermWrap(bool))); | ||
193 | connect(conv_inbound, SIGNAL(toggled(bool)), SLOT(slotTermInbound(bool))); | ||
194 | connect(conv_outbound, SIGNAL(toggled(bool)), SLOT(slotTermOutbound(bool))); | ||
195 | |||
196 | return root; | ||
197 | } | ||
198 | |||
199 | void ProfileEditorPlugin::slotConnFlow(int id) | ||
200 | { | ||
201 | switch(id) | ||
202 | { | ||
203 | case id_flow_hw: | ||
204 | m_profile.writeEntry("Flow", IOSerial::FlowHW); | ||
205 | break; | ||
206 | case id_flow_sw: | ||
207 | m_profile.writeEntry("Flow", IOSerial::FlowSW); | ||
208 | break; | ||
209 | } | ||
210 | } | ||
211 | |||
212 | void ProfileEditorPlugin::slotConnParity(int id) | ||
213 | { | ||
214 | switch(id) | ||
215 | { | ||
216 | case id_parity_odd: | ||
217 | m_profile.writeEntry("Parity", IOSerial::ParityEven); | ||
218 | break; | ||
219 | case id_parity_even: | ||
220 | m_profile.writeEntry("Parity", IOSerial::ParityOdd); | ||
221 | break; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | void ProfileEditorPlugin::slotConnSpeed(int id) | ||
226 | { | ||
227 | switch(id) | ||
228 | { | ||
229 | |||
230 | case id_baud_115200: | ||
231 | m_profile.writeEntry("Speed", 115200); | ||
232 | break; | ||
233 | case id_baud_57600: | ||
234 | m_profile.writeEntry("Speed", 57600); | ||
235 | break; | ||
236 | case id_baud_38400: | ||
237 | m_profile.writeEntry("Speed", 38400); | ||
238 | break; | ||
239 | case id_baud_19200: | ||
240 | m_profile.writeEntry("Speed", 19200); | ||
241 | break; | ||
242 | case id_baud_9600: | ||
243 | m_profile.writeEntry("Speed", 9600); | ||
244 | break; | ||
245 | } | ||
246 | } | ||
247 | |||
248 | void ProfileEditorPlugin::slotTermTerm(int id) | ||
249 | { | ||
250 | switch(id) | ||
251 | { | ||
252 | case id_term_vt100: | ||
253 | m_profile.writeEntry("Terminal", Profile::VT102); | ||
254 | break; | ||
255 | case id_term_vt220: | ||
256 | m_profile.writeEntry("Terminal", Profile::VT102); | ||
257 | break; | ||
258 | case id_term_ansi: | ||
259 | m_profile.writeEntry("Terminal", Profile::VT102); | ||
260 | break; | ||
261 | } | ||
262 | } | ||
263 | |||
264 | void ProfileEditorPlugin::slotTermColour(int id) | ||
265 | { | ||
266 | switch(id) | ||
267 | { | ||
268 | case id_term_black: | ||
269 | m_profile.writeEntry("Colour", Profile::Black); | ||
270 | break; | ||
271 | case id_term_white: | ||
272 | m_profile.writeEntry("Colour", Profile::White); | ||
273 | break; | ||
274 | } | ||
275 | } | ||
276 | |||
277 | void ProfileEditorPlugin::slotTermFont(int id) | ||
278 | { | ||
279 | switch(id) | ||
280 | { | ||
281 | case id_size_small: | ||
282 | m_profile.writeEntry("Font", Profile::Micro); | ||
283 | break; | ||
284 | case id_size_medium: | ||
285 | m_profile.writeEntry("Font", Profile::Small); | ||
286 | break; | ||
287 | case id_size_large: | ||
288 | m_profile.writeEntry("Font", Profile::Medium); | ||
289 | break; | ||
290 | } | ||
291 | } | ||
292 | |||
293 | void ProfileEditorPlugin::slotTermEcho(bool on) | ||
294 | { | ||
295 | m_profile.writeEntry("Echo", on ? 1 : 0); | ||
296 | } | ||
297 | |||
298 | void ProfileEditorPlugin::slotTermWrap(bool on) | ||
299 | { | ||
300 | m_profile.writeEntry("Wrap", on ? 1 : 0); | ||
301 | } | ||
302 | |||
303 | void ProfileEditorPlugin::slotTermInbound(bool on) | ||
304 | { | ||
305 | m_profile.writeEntry("Inbound", on ? 1 : 0); | ||
306 | } | ||
307 | |||
308 | void ProfileEditorPlugin::slotTermOutbound(bool on) | ||
309 | { | ||
310 | m_profile.writeEntry("Outbound", on ? 1 : 0); | ||
311 | } | ||
312 | |||
313 | // Inherited classes | ||
314 | |||
22 | class ProfileEditorPluginSerial : public ProfileEditorPlugin | 315 | class ProfileEditorPluginSerial : public ProfileEditorPlugin |
@@ -50,2 +343,5 @@ class ProfileEditorPluginSerial : public ProfileEditorPlugin | |||
50 | m_widget = device_frame; | 343 | m_widget = device_frame; |
344 | |||
345 | // Load special settings | ||
346 | device_line->setText(m_profile.readEntry("Device")); | ||
51 | } | 347 | } |
@@ -95,2 +391,5 @@ class ProfileEditorPluginIrda : public ProfileEditorPlugin | |||
95 | m_widget = device_frame; | 391 | m_widget = device_frame; |
392 | |||
393 | // Load special settings | ||
394 | device_line->setText(m_profile.readEntry("Device")); | ||
96 | } | 395 | } |
@@ -144,2 +443,6 @@ class ProfileEditorPluginModem : public ProfileEditorPlugin | |||
144 | m_widget = device_frame; | 443 | m_widget = device_frame; |
444 | |||
445 | // Load special settings | ||
446 | device_line->setText(m_profile.readEntry("Device")); | ||
447 | number_line->setText(m_profile.readEntry("Number")); | ||
145 | } | 448 | } |