-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 188 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.h | 41 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditorplugins.cpp | 303 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditorplugins.h | 62 |
4 files changed, 371 insertions, 223 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 78885e1..d98e589 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -1,18 +1,15 @@ | |||
1 | 1 | ||
2 | #include "profileeditordialog.h" | 2 | #include "profileeditordialog.h" |
3 | 3 | ||
4 | #include "qlayout.h" | 4 | #include "qlayout.h" |
5 | #include "qlineedit.h" | 5 | #include "qlineedit.h" |
6 | #include "qlabel.h" | 6 | #include "qlabel.h" |
7 | #include "qradiobutton.h" | ||
8 | #include "qcombobox.h" | ||
9 | #include "qcheckbox.h" | ||
10 | #include "qmessagebox.h" | 7 | #include "qmessagebox.h" |
11 | #include "qbuttongroup.h" | ||
12 | #include "qstringlist.h" | 8 | #include "qstringlist.h" |
9 | #include "qcombobox.h" | ||
13 | 10 | ||
14 | #include "profileeditorplugins.h" | 11 | #include "profileeditorplugins.h" |
15 | #include "metafactory.h" | 12 | #include "metafactory.h" |
16 | 13 | ||
17 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 14 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
18 | const Profile& prof ) | 15 | const Profile& prof ) |
@@ -78,117 +75,35 @@ void ProfileEditorDialog::initUI() | |||
78 | 75 | ||
79 | plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, m_prof); | 76 | plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, m_prof); |
80 | plugin_layout->add(plugin_plugin->widget()); | 77 | plugin_layout->add(plugin_plugin->widget()); |
81 | 78 | ||
82 | // connection tab, general part | 79 | // connection tab, general part |
83 | 80 | ||
84 | QComboBox *speed_box = new QComboBox(tabconn); | 81 | QWidget *conn_widget = plugin_plugin->connection_widget(); |
85 | speed_box->insertItem("115200 baud", id_baud_115200); | 82 | conn_widget->reparent(tabconn, 0, QPoint(), true); |
86 | speed_box->insertItem("57600 baud", id_baud_57600); | ||
87 | speed_box->insertItem("38400 baud", id_baud_38400); | ||
88 | speed_box->insertItem("19200 baud", id_baud_19200); | ||
89 | speed_box->insertItem("9600 baud", id_baud_9600); | ||
90 | |||
91 | QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn); | ||
92 | QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn); | ||
93 | QLabel *parity = new QLabel(QObject::tr("Parity"), tabconn); | ||
94 | |||
95 | QButtonGroup *group_flow = new QButtonGroup(tabconn); | ||
96 | group_flow->hide(); | ||
97 | QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), tabconn); | ||
98 | QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), tabconn); | ||
99 | group_flow->insert(flow_hw, id_flow_hw); | ||
100 | group_flow->insert(flow_sw, id_flow_sw); | ||
101 | |||
102 | QButtonGroup *group_parity = new QButtonGroup(tabconn); | ||
103 | group_parity->hide(); | ||
104 | QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), tabconn); | ||
105 | QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), tabconn); | ||
106 | group_parity->insert(parity_odd, id_parity_odd); | ||
107 | group_parity->insert(parity_even, id_parity_even); | ||
108 | |||
109 | flow_sw->setChecked(true); | ||
110 | parity_odd->setChecked(true); | ||
111 | 83 | ||
112 | // terminal tab | 84 | // terminal tab |
113 | 85 | ||
114 | QComboBox *terminal_box = new QComboBox(tabterm); | 86 | QWidget *term_widget = plugin_plugin->terminal_widget(); |
115 | terminal_box->insertItem("VT 100", id_term_vt100); | 87 | term_widget->reparent(tabterm, 0, QPoint(), true); |
116 | terminal_box->insertItem("VT 220", id_term_vt220); | ||
117 | terminal_box->insertItem("ANSI", id_term_ansi); | ||
118 | |||
119 | QLabel *terminal = new QLabel(QObject::tr("Terminal type"), tabterm); | ||
120 | QLabel *colour = new QLabel(QObject::tr("Colour scheme"), tabterm); | ||
121 | QLabel *size = new QLabel(QObject::tr("Font size"), tabterm); | ||
122 | QLabel *options = new QLabel(QObject::tr("Options"), tabterm); | ||
123 | QLabel *conversions = new QLabel(QObject::tr("Line-break conversions"), tabterm); | ||
124 | |||
125 | QComboBox *colour_box = new QComboBox(tabterm); | ||
126 | colour_box->insertItem(QObject::tr("black on white")); | ||
127 | colour_box->insertItem(QObject::tr("white on black")); | ||
128 | |||
129 | QButtonGroup *group_size = new QButtonGroup(tabterm); | ||
130 | group_size->hide(); | ||
131 | QRadioButton *size_small = new QRadioButton(QObject::tr("small"), tabterm); | ||
132 | QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), tabterm); | ||
133 | QRadioButton *size_large = new QRadioButton(QObject::tr("large"), tabterm); | ||
134 | group_size->insert(size_small); | ||
135 | group_size->insert(size_medium); | ||
136 | group_size->insert(size_large); | ||
137 | |||
138 | QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm); | ||
139 | QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm); | ||
140 | |||
141 | QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), tabterm); | ||
142 | QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm); | ||
143 | |||
144 | size_small->setChecked(true); | ||
145 | 88 | ||
146 | // layouting | 89 | // layouting |
147 | 90 | ||
148 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 91 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
149 | vbox3->add(name); | 92 | vbox3->add(name); |
150 | vbox3->add(name_line); | 93 | vbox3->add(name_line); |
151 | vbox3->addStretch(1); | 94 | vbox3->addStretch(1); |
152 | 95 | ||
153 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); | 96 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); |
154 | vbox->add(device); | 97 | vbox->add(device); |
155 | vbox->add(device_box); | 98 | vbox->add(device_box); |
156 | vbox->add(plugin_base); | 99 | vbox->add(plugin_base); |
157 | vbox->add(speed); | 100 | vbox->add(conn_widget); |
158 | vbox->add(speed_box); | ||
159 | vbox->add(flow); | ||
160 | QHBoxLayout *hbox = new QHBoxLayout(vbox, 2); | ||
161 | hbox->add(flow_hw); | ||
162 | hbox->add(flow_sw); | ||
163 | //vbox->add(group_flow); | ||
164 | vbox->add(parity); | ||
165 | QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2); | ||
166 | hbox2->add(parity_odd); | ||
167 | hbox2->add(parity_even); | ||
168 | //vbox->add(group_parity); | ||
169 | 101 | ||
170 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); | 102 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); |
171 | vbox2->add(terminal); | 103 | vbox2->add(term_widget); |
172 | vbox2->add(terminal_box); | ||
173 | vbox2->add(size); | ||
174 | QHBoxLayout *hbox3 = new QHBoxLayout(vbox2, 2); | ||
175 | hbox3->add(size_small); | ||
176 | hbox3->add(size_medium); | ||
177 | hbox3->add(size_large); | ||
178 | //vbox2->add(group_size); | ||
179 | vbox2->add(colour); | ||
180 | vbox2->add(colour_box); | ||
181 | vbox2->add(conversions); | ||
182 | QHBoxLayout *hbox5 = new QHBoxLayout(vbox2, 2); | ||
183 | hbox5->add(conv_inbound); | ||
184 | hbox5->add(conv_outbound); | ||
185 | vbox2->add(options); | ||
186 | QHBoxLayout *hbox4 = new QHBoxLayout(vbox2, 2); | ||
187 | hbox4->add(option_wrap); | ||
188 | hbox4->add(option_echo); | ||
189 | 104 | ||
190 | addTab(tabprof, QObject::tr("Profile")); | 105 | addTab(tabprof, QObject::tr("Profile")); |
191 | addTab(tabconn, QObject::tr("Connection")); | 106 | addTab(tabconn, QObject::tr("Connection")); |
192 | addTab(tabterm, QObject::tr("Terminal")); | 107 | addTab(tabterm, QObject::tr("Terminal")); |
193 | 108 | ||
194 | setOkButton(QObject::tr("OK")); | 109 | setOkButton(QObject::tr("OK")); |
@@ -199,19 +114,12 @@ void ProfileEditorDialog::initUI() | |||
199 | name_line->setText(m_prof.name()); | 114 | name_line->setText(m_prof.name()); |
200 | 115 | ||
201 | // signals | 116 | // signals |
202 | 117 | ||
203 | connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel())); | 118 | connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel())); |
204 | connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); | 119 | connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); |
205 | |||
206 | connect(group_flow, SIGNAL(clicked(int)), SLOT(slotConnFlow(int))); | ||
207 | connect(group_parity, SIGNAL(clicked(int)), SLOT(slotConnParity(int))); | ||
208 | connect(speed_box, SIGNAL(activated(int)), SLOT(slotConnSpeed(int))); | ||
209 | |||
210 | connect(terminal_box, SIGNAL(activated(int)), SLOT(slotTermTerm(int))); | ||
211 | connect(group_size, SIGNAL(clicked(int)), SLOT(slotTermFont(int))); | ||
212 | } | 120 | } |
213 | 121 | ||
214 | ProfileEditorDialog::~ProfileEditorDialog() { | 122 | ProfileEditorDialog::~ProfileEditorDialog() { |
215 | 123 | ||
216 | } | 124 | } |
217 | 125 | ||
@@ -264,89 +172,7 @@ QString ProfileEditorDialog::prof_type() | |||
264 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 172 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
265 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 173 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
266 | 174 | ||
267 | return QString::null; | 175 | return QString::null; |
268 | } | 176 | } |
269 | 177 | ||
270 | void ProfileEditorDialog::slotConnFlow(int id) | ||
271 | { | ||
272 | switch(id) | ||
273 | { | ||
274 | case id_flow_hw: | ||
275 | m_prof.writeEntry("Flow", 0x01); | ||
276 | break; | ||
277 | case id_flow_sw: | ||
278 | m_prof.writeEntry("Flow", 0x02); | ||
279 | break; | ||
280 | } | ||
281 | } | ||
282 | |||
283 | void ProfileEditorDialog::slotConnParity(int id) | ||
284 | { | ||
285 | switch(id) | ||
286 | { | ||
287 | case id_parity_odd: | ||
288 | m_prof.writeEntry("Parity", 2); | ||
289 | break; | ||
290 | case id_parity_even: | ||
291 | m_prof.writeEntry("Parity", 1); | ||
292 | break; | ||
293 | } | ||
294 | } | ||
295 | |||
296 | void ProfileEditorDialog::slotConnSpeed(int id) | ||
297 | { | ||
298 | switch(id) | ||
299 | { | ||
300 | |||
301 | case id_baud_115200: | ||
302 | m_prof.writeEntry("Speed", 115200); | ||
303 | break; | ||
304 | case id_baud_57600: | ||
305 | m_prof.writeEntry("Speed", 57600); | ||
306 | break; | ||
307 | case id_baud_38400: | ||
308 | m_prof.writeEntry("Speed", 38400); | ||
309 | break; | ||
310 | case id_baud_19200: | ||
311 | m_prof.writeEntry("Speed", 19200); | ||
312 | break; | ||
313 | case id_baud_9600: | ||
314 | m_prof.writeEntry("Speed", 9600); | ||
315 | break; | ||
316 | } | ||
317 | } | ||
318 | |||
319 | void ProfileEditorDialog::slotTermTerm(int id) | ||
320 | { | ||
321 | switch(id) | ||
322 | { | ||
323 | |||
324 | case id_term_vt100: | ||
325 | m_prof.writeEntry("Terminal", 2); | ||
326 | break; | ||
327 | case id_term_vt220: | ||
328 | m_prof.writeEntry("Terminal", 1); | ||
329 | break; | ||
330 | case id_term_ansi: | ||
331 | m_prof.writeEntry("Terminal", 0); | ||
332 | break; | ||
333 | } | ||
334 | } | ||
335 | |||
336 | void ProfileEditorDialog::slotTermFont(int id) | ||
337 | { | ||
338 | switch(id) | ||
339 | { | ||
340 | case id_size_small: | ||
341 | m_prof.writeEntry("Font", 0); | ||
342 | break; | ||
343 | case id_size_medium: | ||
344 | m_prof.writeEntry("Font", 1); | ||
345 | break; | ||
346 | case id_size_large: | ||
347 | m_prof.writeEntry("Font", 2); | ||
348 | break; | ||
349 | } | ||
350 | } | ||
351 | |||
352 | 178 | ||
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h index a6808d0..18e2ec0 100644 --- a/noncore/apps/opie-console/profileeditordialog.h +++ b/noncore/apps/opie-console/profileeditordialog.h | |||
@@ -30,18 +30,12 @@ public slots: | |||
30 | void accept(); | 30 | void accept(); |
31 | //void slotOk(); | 31 | //void slotOk(); |
32 | void slotCancel(); | 32 | void slotCancel(); |
33 | 33 | ||
34 | void slotDevice(int id); | 34 | void slotDevice(int id); |
35 | 35 | ||
36 | void slotConnFlow(int id); | ||
37 | void slotConnParity(int id); | ||
38 | void slotConnSpeed(int id); | ||
39 | void slotTermTerm(int id); | ||
40 | void slotTermFont(int id); | ||
41 | |||
42 | private: | 36 | private: |
43 | void initUI(); | 37 | void initUI(); |
44 | 38 | ||
45 | MetaFactory* m_fact; | 39 | MetaFactory* m_fact; |
46 | EditBase* m_base; | 40 | EditBase* m_base; |
47 | QTabWidget* m_tab; | 41 | QTabWidget* m_tab; |
@@ -51,44 +45,9 @@ private: | |||
51 | QLineEdit *name_line; | 45 | QLineEdit *name_line; |
52 | QComboBox *device_box; | 46 | QComboBox *device_box; |
53 | 47 | ||
54 | QWidget *plugin_base; | 48 | QWidget *plugin_base; |
55 | ProfileEditorPlugin *plugin_plugin; | 49 | ProfileEditorPlugin *plugin_plugin; |
56 | QHBoxLayout *plugin_layout; | 50 | QHBoxLayout *plugin_layout; |
57 | |||
58 | enum ParityIds | ||
59 | { | ||
60 | id_parity_odd, | ||
61 | id_parity_even | ||
62 | }; | ||
63 | |||
64 | enum FlowIds | ||
65 | { | ||
66 | id_flow_hw, | ||
67 | id_flow_sw | ||
68 | }; | ||
69 | |||
70 | enum SpeedIds | ||
71 | { | ||
72 | id_baud_115200, | ||
73 | id_baud_57600, | ||
74 | id_baud_38400, | ||
75 | id_baud_19200, | ||
76 | id_baud_9600 | ||
77 | }; | ||
78 | |||
79 | enum TermIds | ||
80 | { | ||
81 | id_term_vt100, | ||
82 | id_term_vt220, | ||
83 | id_term_ansi | ||
84 | }; | ||
85 | |||
86 | enum FontIds | ||
87 | { | ||
88 | id_size_small, | ||
89 | id_size_medium, | ||
90 | id_size_large | ||
91 | }; | ||
92 | }; | 51 | }; |
93 | 52 | ||
94 | #endif | 53 | #endif |
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 | |||
@@ -3,12 +3,20 @@ | |||
3 | #include "profile.h" | 3 | #include "profile.h" |
4 | 4 | ||
5 | #include "qframe.h" | 5 | #include "qframe.h" |
6 | #include "qlabel.h" | 6 | #include "qlabel.h" |
7 | #include "qlineedit.h" | 7 | #include "qlineedit.h" |
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 | ||
10 | ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile p) | 18 | ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile p) |
11 | { | 19 | { |
12 | m_parent = parent; | 20 | m_parent = parent; |
13 | m_profile = p; | 21 | m_profile = p; |
14 | m_widget = NULL; | 22 | m_widget = NULL; |
@@ -16,12 +24,297 @@ ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile p) | |||
16 | 24 | ||
17 | ProfileEditorPlugin::~ProfileEditorPlugin() | 25 | ProfileEditorPlugin::~ProfileEditorPlugin() |
18 | { | 26 | { |
19 | if(m_widget) delete m_widget; | 27 | if(m_widget) delete m_widget; |
20 | } | 28 | } |
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 |
23 | { | 316 | { |
24 | public: | 317 | public: |
25 | 318 | ||
26 | ProfileEditorPluginSerial(QWidget *parent, Profile p) | 319 | ProfileEditorPluginSerial(QWidget *parent, Profile p) |
27 | : ProfileEditorPlugin(parent, p) | 320 | : ProfileEditorPlugin(parent, p) |
@@ -45,12 +338,15 @@ class ProfileEditorPluginSerial : public ProfileEditorPlugin | |||
45 | 338 | ||
46 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | 339 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); |
47 | vbox_frame->add(frame_device); | 340 | vbox_frame->add(frame_device); |
48 | vbox_frame->add(device_line); | 341 | vbox_frame->add(device_line); |
49 | 342 | ||
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 | } |
52 | 348 | ||
53 | return m_widget; | 349 | return m_widget; |
54 | } | 350 | } |
55 | 351 | ||
56 | void save() | 352 | void save() |
@@ -90,12 +386,15 @@ class ProfileEditorPluginIrda : public ProfileEditorPlugin | |||
90 | 386 | ||
91 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | 387 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); |
92 | vbox_frame->add(frame_device); | 388 | vbox_frame->add(frame_device); |
93 | vbox_frame->add(device_line); | 389 | vbox_frame->add(device_line); |
94 | 390 | ||
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 | } |
97 | 396 | ||
98 | return m_widget; | 397 | return m_widget; |
99 | } | 398 | } |
100 | 399 | ||
101 | void save() | 400 | void save() |
@@ -139,12 +438,16 @@ class ProfileEditorPluginModem : public ProfileEditorPlugin | |||
139 | vbox_frame->add(frame_device); | 438 | vbox_frame->add(frame_device); |
140 | vbox_frame->add(device_line); | 439 | vbox_frame->add(device_line); |
141 | vbox_frame->add(frame_number); | 440 | vbox_frame->add(frame_number); |
142 | vbox_frame->add(number_line); | 441 | vbox_frame->add(number_line); |
143 | 442 | ||
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 | } |
146 | 449 | ||
147 | return m_widget; | 450 | return m_widget; |
148 | } | 451 | } |
149 | 452 | ||
150 | void save() | 453 | void save() |
diff --git a/noncore/apps/opie-console/profileeditorplugins.h b/noncore/apps/opie-console/profileeditorplugins.h index 7e0219b..caec7ba 100644 --- a/noncore/apps/opie-console/profileeditorplugins.h +++ b/noncore/apps/opie-console/profileeditorplugins.h | |||
@@ -1,27 +1,87 @@ | |||
1 | #ifndef PROFILE_EDITOR_PLUGINS_H | 1 | #ifndef PROFILE_EDITOR_PLUGINS_H |
2 | #define PROFILE_EDITOR_PLUGINS_H | 2 | #define PROFILE_EDITOR_PLUGINS_H |
3 | 3 | ||
4 | #include "profile.h" | 4 | #include "profile.h" |
5 | 5 | ||
6 | #include "qobject.h" | ||
7 | |||
6 | class QWidget; | 8 | class QWidget; |
7 | 9 | ||
8 | class ProfileEditorPlugin | 10 | class ProfileEditorPlugin : public QObject |
9 | { | 11 | { |
12 | Q_OBJECT | ||
10 | public: | 13 | public: |
11 | ProfileEditorPlugin(QWidget *parent, Profile p); | 14 | ProfileEditorPlugin(QWidget *parent, Profile p); |
12 | 15 | ||
13 | virtual ~ProfileEditorPlugin(); | 16 | virtual ~ProfileEditorPlugin(); |
14 | 17 | ||
15 | virtual void save() = 0; | 18 | virtual void save() = 0; |
16 | 19 | ||
17 | virtual QWidget *widget() = 0; | 20 | virtual QWidget *widget() = 0; |
18 | 21 | ||
22 | QWidget *connection_widget(); | ||
23 | QWidget *terminal_widget(); | ||
24 | |||
25 | public slots: | ||
26 | void slotConnFlow(int id); | ||
27 | void slotConnParity(int id); | ||
28 | void slotConnSpeed(int id); | ||
29 | void slotTermTerm(int id); | ||
30 | void slotTermColour(int id); | ||
31 | void slotTermFont(int id); | ||
32 | void slotTermEcho(bool on); | ||
33 | void slotTermWrap(bool on); | ||
34 | void slotTermInbound(bool on); | ||
35 | void slotTermOutbound(bool on); | ||
36 | |||
19 | protected: | 37 | protected: |
20 | QWidget *m_parent, *m_widget; | 38 | QWidget *m_parent, *m_widget; |
21 | Profile m_profile; | 39 | Profile m_profile; |
40 | |||
41 | private: | ||
42 | enum ParityIds | ||
43 | { | ||
44 | id_parity_odd, | ||
45 | id_parity_even | ||
46 | }; | ||
47 | |||
48 | enum FlowIds | ||
49 | { | ||
50 | id_flow_hw, | ||
51 | id_flow_sw | ||
52 | }; | ||
53 | |||
54 | enum SpeedIds | ||
55 | { | ||
56 | id_baud_115200, | ||
57 | id_baud_57600, | ||
58 | id_baud_38400, | ||
59 | id_baud_19200, | ||
60 | id_baud_9600 | ||
61 | }; | ||
62 | |||
63 | enum TermIds | ||
64 | { | ||
65 | id_term_vt100, | ||
66 | id_term_vt220, | ||
67 | id_term_ansi | ||
68 | }; | ||
69 | |||
70 | enum ColourIds | ||
71 | { | ||
72 | id_term_black, | ||
73 | id_term_white | ||
74 | }; | ||
75 | |||
76 | enum FontIds | ||
77 | { | ||
78 | id_size_small, | ||
79 | id_size_medium, | ||
80 | id_size_large | ||
81 | }; | ||
22 | }; | 82 | }; |
23 | 83 | ||
24 | //#ifdef __cplusplus | 84 | //#ifdef __cplusplus |
25 | //extern "C" { | 85 | //extern "C" { |
26 | //#endif | 86 | //#endif |
27 | 87 | ||