summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.cpp477
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.h96
2 files changed, 0 insertions, 573 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
19ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile *p)
20: QObject()
21{
22 m_parent = parent;
23 m_profile = p;
24 m_widget = NULL;
25}
26
27ProfileEditorPlugin::~ProfileEditorPlugin()
28{
29 if(m_widget) delete m_widget;
30}
31
32QWidget *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
101QWidget *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
194void 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
210void 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
223void 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
246void 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
262void 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
275void 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
291void ProfileEditorPlugin::slotTermEcho(bool on)
292{
293 m_profile->writeEntry("Echo", on ? 1 : 0);
294}
295
296void ProfileEditorPlugin::slotTermWrap(bool on)
297{
298 m_profile->writeEntry("Wrap", on ? 1 : 0);
299}
300
301void ProfileEditorPlugin::slotTermInbound(bool on)
302{
303 m_profile->writeEntry("Inbound", on ? 1 : 0);
304}
305
306void ProfileEditorPlugin::slotTermOutbound(bool on)
307{
308 m_profile->writeEntry("Outbound", on ? 1 : 0);
309}
310
311// Inherited classes
312
313class 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
361class 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
409class 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
463ProfileEditorPlugin *factory_serial(QWidget *parent, Profile *p)
464{
465 return new ProfileEditorPluginSerial(parent, p);
466}
467
468ProfileEditorPlugin *factory_irda(QWidget *parent, Profile *p)
469{
470 return new ProfileEditorPluginIrda(parent, p);
471}
472
473ProfileEditorPlugin *factory_modem(QWidget *parent, Profile *p)
474{
475 return new ProfileEditorPluginModem(parent, p);
476}
477
diff --git a/noncore/apps/opie-console/profileeditorplugins.h b/noncore/apps/opie-console/profileeditorplugins.h
deleted file mode 100644
index f576143..0000000
--- a/noncore/apps/opie-console/profileeditorplugins.h
+++ b/dev/null
@@ -1,96 +0,0 @@
1#ifndef PROFILE_EDITOR_PLUGINS_H
2#define PROFILE_EDITOR_PLUGINS_H
3
4
5#include <qobject.h>
6
7class QWidget;
8class Profile;
9class ProfileEditorPlugin : public QObject
10{
11 Q_OBJECT
12public:
13 ProfileEditorPlugin(QWidget *parent);
14
15 virtual ~ProfileEditorPlugin();
16
17 virtual void save() = 0;
18
19 virtual QWidget *widget() = 0;
20
21 QWidget *connection_widget();
22 QWidget *terminal_widget();
23
24public slots:
25 void slotConnFlow(int id);
26 void slotConnParity(int id);
27 void slotConnSpeed(int id);
28 void slotTermTerm(int id);
29 void slotTermColour(int id);
30 void slotTermFont(int id);
31 void slotTermEcho(bool on);
32 void slotTermWrap(bool on);
33 void slotTermInbound(bool on);
34 void slotTermOutbound(bool on);
35
36protected:
37 QWidget *m_parent, *m_widget;
38 Profile *m_profile;
39
40private:
41 enum ParityIds
42 {
43 id_parity_odd,
44 id_parity_even
45 };
46
47 enum FlowIds
48 {
49 id_flow_hw,
50 id_flow_sw
51 };
52
53 enum SpeedIds
54 {
55 id_baud_115200,
56 id_baud_57600,
57 id_baud_38400,
58 id_baud_19200,
59 id_baud_9600
60 };
61
62 enum TermIds
63 {
64 id_term_vt100,
65 id_term_vt220,
66 id_term_ansi
67 };
68
69 enum ColourIds
70 {
71 id_term_black,
72 id_term_white
73 };
74
75 enum FontIds
76 {
77 id_size_small,
78 id_size_medium,
79 id_size_large
80 };
81};
82
83//#ifdef __cplusplus
84//extern "C" {
85//#endif
86
87ProfileEditorPlugin *factory_serial(QWidget *parent, Profile *p);
88ProfileEditorPlugin *factory_irda(QWidget *parent, Profile *p);
89ProfileEditorPlugin *factory_modem(QWidget *parent, Profile *p);
90
91//#ifdef __cplusplus
92//}
93//#endif
94
95#endif
96