Diffstat (limited to 'noncore/apps/opie-console/profileeditorplugins.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/profileeditorplugins.cpp | 477 |
1 files changed, 0 insertions, 477 deletions
diff --git a/noncore/apps/opie-console/profileeditorplugins.cpp b/noncore/apps/opie-console/profileeditorplugins.cpp deleted file mode 100644 index 45b2148..0000000 --- a/noncore/apps/opie-console/profileeditorplugins.cpp +++ b/dev/null | |||
@@ -1,477 +0,0 @@ | |||
1 | |||
2 | #include <qframe.h> | ||
3 | #include <qlabel.h> | ||
4 | #include <qlineedit.h> | ||
5 | #include <qlayout.h> | ||
6 | #include <qcombobox.h> | ||
7 | #include <qradiobutton.h> | ||
8 | #include <qcheckbox.h> | ||
9 | #include <qbuttongroup.h> | ||
10 | #include <qhgroupbox.h> | ||
11 | #include <qvbox.h> | ||
12 | |||
13 | #include "io_serial.h" | ||
14 | #include "profile.h" | ||
15 | #include "profileeditorplugins.h" | ||
16 | |||
17 | // Base class | ||
18 | |||
19 | ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile *p) | ||
20 | : QObject() | ||
21 | { | ||
22 | m_parent = parent; | ||
23 | m_profile = p; | ||
24 | m_widget = NULL; | ||
25 | } | ||
26 | |||
27 | ProfileEditorPlugin::~ProfileEditorPlugin() | ||
28 | { | ||
29 | if(m_widget) delete m_widget; | ||
30 | } | ||
31 | |||
32 | QWidget *ProfileEditorPlugin::connection_widget() | ||
33 | { | ||
34 | QWidget *root; | ||
35 | QVBoxLayout *lroot; | ||
36 | |||
37 | root = new QWidget(); | ||
38 | |||
39 | // Build GUI | ||
40 | QLabel *speedlabel = new QLabel(QObject::tr("Speed"), root); | ||
41 | |||
42 | QComboBox *speed_box = new QComboBox(root); | ||
43 | speed_box->insertItem("115200 baud", id_baud_115200); | ||
44 | speed_box->insertItem("57600 baud", id_baud_57600); | ||
45 | speed_box->insertItem("38400 baud", id_baud_38400); | ||
46 | speed_box->insertItem("19200 baud", id_baud_19200); | ||
47 | speed_box->insertItem("9600 baud", id_baud_9600); | ||
48 | |||
49 | QButtonGroup *group_flow = new QButtonGroup(QObject::tr("Flow control"), root); | ||
50 | |||
51 | QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), group_flow); | ||
52 | QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), group_flow); | ||
53 | |||
54 | QButtonGroup *group_parity = new QButtonGroup(QObject::tr("Parity"), root); | ||
55 | QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), group_parity); | ||
56 | QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), group_parity); | ||
57 | |||
58 | // Build Layout | ||
59 | lroot = new QVBoxLayout(root); | ||
60 | lroot->add(speedlabel); | ||
61 | lroot->add(speed_box); | ||
62 | lroot->setStretchFactor(speedlabel, 1); | ||
63 | lroot->setStretchFactor(speed_box, 1); | ||
64 | |||
65 | QHBoxLayout *hbox = new QHBoxLayout(group_flow, 2); | ||
66 | hbox->add(flow_hw); | ||
67 | hbox->add(flow_sw); | ||
68 | lroot->add(group_flow); | ||
69 | lroot->setStretchFactor(group_flow, 2); | ||
70 | |||
71 | QHBoxLayout *hboxPar = new QHBoxLayout( group_parity, 2); | ||
72 | hboxPar->add(parity_odd); | ||
73 | hboxPar->add(parity_even); | ||
74 | lroot->add(group_parity); | ||
75 | lroot->setStretchFactor(group_parity, 2); | ||
76 | // Apply profile settings | ||
77 | |||
78 | int rad_flow = m_profile->readNumEntry("Flow"); | ||
79 | int rad_parity = m_profile->readNumEntry("Parity"); | ||
80 | int speed = m_profile->readNumEntry("Speed"); | ||
81 | |||
82 | if(rad_flow == IOSerial::FlowHW) flow_hw->setChecked(true); | ||
83 | else flow_sw->setChecked(true); | ||
84 | if(rad_parity == IOSerial::ParityEven) parity_even->setChecked(true); | ||
85 | else parity_odd->setChecked(true); | ||
86 | if(speed == 115200) speed_box->setCurrentItem(id_baud_115200); | ||
87 | if(speed == 57600) speed_box->setCurrentItem(id_baud_57600); | ||
88 | if(speed == 38400) speed_box->setCurrentItem(id_baud_38400); | ||
89 | if(speed == 19200) speed_box->setCurrentItem(id_baud_19200); | ||
90 | if(speed == 9600) speed_box->setCurrentItem(id_baud_9600); | ||
91 | |||
92 | // Signals | ||
93 | |||
94 | connect(group_flow, SIGNAL(clicked(int)), SLOT(slotConnFlow(int))); | ||
95 | connect(group_parity, SIGNAL(clicked(int)), SLOT(slotConnParity(int))); | ||
96 | connect(speed_box, SIGNAL(activated(int)), SLOT(slotConnSpeed(int))); | ||
97 | |||
98 | return root; | ||
99 | } | ||
100 | |||
101 | QWidget *ProfileEditorPlugin::terminal_widget() | ||
102 | { | ||
103 | QWidget *root; | ||
104 | QVBoxLayout *lroot; | ||
105 | |||
106 | root = new QWidget(); | ||
107 | |||
108 | // Build GUI | ||
109 | |||
110 | |||
111 | QLabel *terminal = new QLabel(QObject::tr("Terminal type"), root); | ||
112 | |||
113 | QComboBox *terminal_box = new QComboBox(root); | ||
114 | terminal_box->insertItem("VT 100", id_term_vt100); | ||
115 | terminal_box->insertItem("VT 220", id_term_vt220); | ||
116 | terminal_box->insertItem("ANSI", id_term_ansi); | ||
117 | |||
118 | QLabel *colourlabel = new QLabel(QObject::tr("Colour scheme"), root); | ||
119 | QComboBox *colour_box = new QComboBox(root); | ||
120 | colour_box->insertItem(QObject::tr("black on white"), id_term_black); | ||
121 | colour_box->insertItem(QObject::tr("white on black"), id_term_white); | ||
122 | |||
123 | QButtonGroup *group_size = new QButtonGroup( QObject::tr("Font size"), root ); | ||
124 | QRadioButton *size_small = new QRadioButton(QObject::tr("small"), group_size ); | ||
125 | QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), group_size ); | ||
126 | QRadioButton *size_large = new QRadioButton(QObject::tr("large"), group_size ); | ||
127 | |||
128 | QHGroupBox *group_conv = new QHGroupBox( QObject::tr("Line-break conversions"), root ); | ||
129 | QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), group_conv); | ||
130 | QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), group_conv); | ||
131 | |||
132 | QHGroupBox *group_options = new QHGroupBox( QObject::tr("Options"), root ); | ||
133 | QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), group_options); | ||
134 | QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), group_options); | ||
135 | |||
136 | // Build Layout | ||
137 | lroot = new QVBoxLayout(root, 2); | ||
138 | |||
139 | QVBoxLayout *typeBox = new QVBoxLayout( lroot ); | ||
140 | typeBox->add(terminal); | ||
141 | typeBox->add(terminal_box); | ||
142 | |||
143 | QHBoxLayout *hbox = new QHBoxLayout( group_size, 2); | ||
144 | hbox->add(size_small); | ||
145 | hbox->add(size_medium); | ||
146 | hbox->add(size_large); | ||
147 | lroot->add( group_size ); | ||
148 | |||
149 | QVBoxLayout *colourBox = new QVBoxLayout( lroot ); | ||
150 | colourBox->add(colourlabel); | ||
151 | colourBox->add(colour_box); | ||
152 | |||
153 | lroot->add(group_conv); | ||
154 | lroot->add(group_options); | ||
155 | |||
156 | // Apply profile settings | ||
157 | |||
158 | int term = m_profile->readNumEntry("Terminal"); | ||
159 | int colour = m_profile->readNumEntry("Colour"); | ||
160 | int fontsize = m_profile->readNumEntry("Font"); | ||
161 | int opt_echo = m_profile->readNumEntry("Echo"); | ||
162 | int opt_wrap = m_profile->readNumEntry("Wrap"); | ||
163 | int opt_inbound = m_profile->readNumEntry("Inbound"); | ||
164 | int opt_outbound = m_profile->readNumEntry("Outbound"); | ||
165 | |||
166 | if(term == Profile::VT102) terminal_box->setCurrentItem(id_term_vt100); | ||
167 | |||
168 | if(colour == Profile::Black) colour_box->setCurrentItem(id_term_black); | ||
169 | if(colour == Profile::White) colour_box->setCurrentItem(id_term_white); | ||
170 | |||
171 | if(fontsize == Profile::Micro) size_small->setChecked(true); | ||
172 | if(fontsize == Profile::Small) size_medium->setChecked(true); | ||
173 | if(fontsize == Profile::Medium) size_large->setChecked(true); | ||
174 | |||
175 | if(opt_echo) option_echo->setChecked(true); | ||
176 | if(opt_wrap) option_wrap->setChecked(true); | ||
177 | if(opt_inbound) conv_inbound->setChecked(true); | ||
178 | if(opt_outbound) conv_outbound->setChecked(true); | ||
179 | |||
180 | // Signals | ||
181 | |||
182 | connect(terminal_box, SIGNAL(activated(int)), SLOT(slotTermTerm(int))); | ||
183 | connect(colour_box, SIGNAL(activated(int)), SLOT(slotTermColour(int))); | ||
184 | connect(group_size, SIGNAL(clicked(int)), SLOT(slotTermFont(int))); | ||
185 | |||
186 | connect(option_echo, SIGNAL(toggled(bool)), SLOT(slotTermEcho(bool))); | ||
187 | connect(option_wrap, SIGNAL(toggled(bool)), SLOT(slotTermWrap(bool))); | ||
188 | connect(conv_inbound, SIGNAL(toggled(bool)), SLOT(slotTermInbound(bool))); | ||
189 | connect(conv_outbound, SIGNAL(toggled(bool)), SLOT(slotTermOutbound(bool))); | ||
190 | |||
191 | return root; | ||
192 | } | ||
193 | |||
194 | void ProfileEditorPlugin::slotConnFlow(int id) | ||
195 | { | ||
196 | switch(id) | ||
197 | { | ||
198 | case id_flow_hw: | ||
199 | m_profile->writeEntry("Flow", IOSerial::FlowHW); | ||
200 | break; | ||
201 | case id_flow_sw: | ||
202 | m_profile->writeEntry("Flow", IOSerial::FlowSW); | ||
203 | break; | ||
204 | case id_flow_sw: | ||
205 | m_profile->writeEntry("None", IOSerial::None); | ||
206 | break; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | void ProfileEditorPlugin::slotConnParity(int id) | ||
211 | { | ||
212 | switch(id) | ||
213 | { | ||
214 | case id_parity_odd: | ||
215 | m_profile->writeEntry("Parity", IOSerial::ParityEven); | ||
216 | break; | ||
217 | case id_parity_even: | ||
218 | m_profile->writeEntry("Parity", IOSerial::ParityOdd); | ||
219 | break; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | void ProfileEditorPlugin::slotConnSpeed(int id) | ||
224 | { | ||
225 | switch(id) | ||
226 | { | ||
227 | |||
228 | case id_baud_115200: | ||
229 | m_profile->writeEntry("Speed", 115200); | ||
230 | break; | ||
231 | case id_baud_57600: | ||
232 | m_profile->writeEntry("Speed", 57600); | ||
233 | break; | ||
234 | case id_baud_38400: | ||
235 | m_profile->writeEntry("Speed", 38400); | ||
236 | break; | ||
237 | case id_baud_19200: | ||
238 | m_profile->writeEntry("Speed", 19200); | ||
239 | break; | ||
240 | case id_baud_9600: | ||
241 | m_profile->writeEntry("Speed", 9600); | ||
242 | break; | ||
243 | } | ||
244 | } | ||
245 | |||
246 | void ProfileEditorPlugin::slotTermTerm(int id) | ||
247 | { | ||
248 | switch(id) | ||
249 | { | ||
250 | case id_term_vt100: | ||
251 | m_profile->writeEntry("Terminal", Profile::VT102); | ||
252 | break; | ||
253 | case id_term_vt220: | ||
254 | m_profile->writeEntry("Terminal", Profile::VT102); | ||
255 | break; | ||
256 | case id_term_ansi: | ||
257 | m_profile->writeEntry("Terminal", Profile::VT102); | ||
258 | break; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | void ProfileEditorPlugin::slotTermColour(int id) | ||
263 | { | ||
264 | switch(id) | ||
265 | { | ||
266 | case id_term_black: | ||
267 | m_profile->writeEntry("Colour", Profile::Black); | ||
268 | break; | ||
269 | case id_term_white: | ||
270 | m_profile->writeEntry("Colour", Profile::White); | ||
271 | break; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | void ProfileEditorPlugin::slotTermFont(int id) | ||
276 | { | ||
277 | switch(id) | ||
278 | { | ||
279 | case id_size_small: | ||
280 | m_profile->writeEntry("Font", Profile::Micro); | ||
281 | break; | ||
282 | case id_size_medium: | ||
283 | m_profile->writeEntry("Font", Profile::Small); | ||
284 | break; | ||
285 | case id_size_large: | ||
286 | m_profile->writeEntry("Font", Profile::Medium); | ||
287 | break; | ||
288 | } | ||
289 | } | ||
290 | |||
291 | void ProfileEditorPlugin::slotTermEcho(bool on) | ||
292 | { | ||
293 | m_profile->writeEntry("Echo", on ? 1 : 0); | ||
294 | } | ||
295 | |||
296 | void ProfileEditorPlugin::slotTermWrap(bool on) | ||
297 | { | ||
298 | m_profile->writeEntry("Wrap", on ? 1 : 0); | ||
299 | } | ||
300 | |||
301 | void ProfileEditorPlugin::slotTermInbound(bool on) | ||
302 | { | ||
303 | m_profile->writeEntry("Inbound", on ? 1 : 0); | ||
304 | } | ||
305 | |||
306 | void ProfileEditorPlugin::slotTermOutbound(bool on) | ||
307 | { | ||
308 | m_profile->writeEntry("Outbound", on ? 1 : 0); | ||
309 | } | ||
310 | |||
311 | // Inherited classes | ||
312 | |||
313 | class ProfileEditorPluginSerial : public ProfileEditorPlugin | ||
314 | { | ||
315 | public: | ||
316 | |||
317 | ProfileEditorPluginSerial(QWidget *parent, Profile *p) | ||
318 | : ProfileEditorPlugin(parent, p) | ||
319 | { | ||
320 | } | ||
321 | |||
322 | ~ProfileEditorPluginSerial() | ||
323 | { | ||
324 | } | ||
325 | |||
326 | QWidget *widget() | ||
327 | { | ||
328 | if(!m_widget) | ||
329 | { | ||
330 | |||
331 | QWidget *device_frame = new QWidget( m_parent ); | ||
332 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | ||
333 | |||
334 | device_line = new QLineEdit("/dev/ttyS0", device_frame); | ||
335 | |||
336 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | ||
337 | vbox_frame->add(frame_device); | ||
338 | vbox_frame->add(device_line); | ||
339 | |||
340 | m_widget = device_frame; | ||
341 | |||
342 | // Load special settings | ||
343 | |||
344 | QString dev = m_profile->readEntry("Device"); | ||
345 | if(!dev.isNull()) device_line->setText(dev); | ||
346 | } | ||
347 | |||
348 | return m_widget; | ||
349 | } | ||
350 | |||
351 | void save() | ||
352 | { | ||
353 | // special settings | ||
354 | m_profile->writeEntry("Device", device_line->text()); | ||
355 | } | ||
356 | |||
357 | private: | ||
358 | QLineEdit *device_line; | ||
359 | }; | ||
360 | |||
361 | class ProfileEditorPluginIrda : public ProfileEditorPlugin | ||
362 | { | ||
363 | public: | ||
364 | |||
365 | ProfileEditorPluginIrda(QWidget *parent, Profile *p) | ||
366 | : ProfileEditorPlugin(parent, p) | ||
367 | { | ||
368 | } | ||
369 | |||
370 | ~ProfileEditorPluginIrda() | ||
371 | { | ||
372 | } | ||
373 | |||
374 | QWidget *widget() | ||
375 | { | ||
376 | if(!m_widget) | ||
377 | { | ||
378 | QWidget *device_frame = new QWidget(m_parent); | ||
379 | |||
380 | |||
381 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | ||
382 | |||
383 | device_line = new QLineEdit("/dev/ircomm0", device_frame); | ||
384 | |||
385 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | ||
386 | vbox_frame->add(frame_device); | ||
387 | vbox_frame->add(device_line); | ||
388 | |||
389 | m_widget = device_frame; | ||
390 | |||
391 | // Load special settings | ||
392 | QString dev = m_profile->readEntry("Device"); | ||
393 | if(!dev.isNull()) device_line->setText(dev); | ||
394 | } | ||
395 | |||
396 | return m_widget; | ||
397 | } | ||
398 | |||
399 | void save() | ||
400 | { | ||
401 | // special settings | ||
402 | m_profile->writeEntry("Device", device_line->text()); | ||
403 | } | ||
404 | |||
405 | private: | ||
406 | QLineEdit *device_line; | ||
407 | }; | ||
408 | |||
409 | class ProfileEditorPluginModem : public ProfileEditorPlugin | ||
410 | { | ||
411 | public: | ||
412 | |||
413 | ProfileEditorPluginModem(QWidget *parent, Profile *p) | ||
414 | : ProfileEditorPlugin(parent, p) | ||
415 | { | ||
416 | } | ||
417 | |||
418 | ~ProfileEditorPluginModem() | ||
419 | { | ||
420 | } | ||
421 | |||
422 | QWidget *widget() | ||
423 | { | ||
424 | if(!m_widget) | ||
425 | { | ||
426 | QWidget *device_frame = new QWidget(m_parent); | ||
427 | |||
428 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | ||
429 | QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame); | ||
430 | |||
431 | device_line = new QLineEdit("/dev/ttyS0", device_frame); | ||
432 | number_line = new QLineEdit(device_frame); | ||
433 | |||
434 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | ||
435 | vbox_frame->add(frame_device); | ||
436 | vbox_frame->add(device_line); | ||
437 | vbox_frame->add(frame_number); | ||
438 | vbox_frame->add(number_line); | ||
439 | |||
440 | m_widget = device_frame; | ||
441 | |||
442 | // Load special settings | ||
443 | QString dev = m_profile->readEntry("Device"); | ||
444 | QString num = m_profile->readEntry("Number"); | ||
445 | if(!dev.isNull()) device_line->setText(dev); | ||
446 | number_line->setText(num); | ||
447 | } | ||
448 | |||
449 | return m_widget; | ||
450 | } | ||
451 | |||
452 | void save() | ||
453 | { | ||
454 | // special settings | ||
455 | m_profile->writeEntry("Device", device_line->text()); | ||
456 | m_profile->writeEntry("Number", number_line->text()); | ||
457 | } | ||
458 | |||
459 | private: | ||
460 | QLineEdit *device_line, *number_line; | ||
461 | }; | ||
462 | |||
463 | ProfileEditorPlugin *factory_serial(QWidget *parent, Profile *p) | ||
464 | { | ||
465 | return new ProfileEditorPluginSerial(parent, p); | ||
466 | } | ||
467 | |||
468 | ProfileEditorPlugin *factory_irda(QWidget *parent, Profile *p) | ||
469 | { | ||
470 | return new ProfileEditorPluginIrda(parent, p); | ||
471 | } | ||
472 | |||
473 | ProfileEditorPlugin *factory_modem(QWidget *parent, Profile *p) | ||
474 | { | ||
475 | return new ProfileEditorPluginModem(parent, p); | ||
476 | } | ||
477 | |||