author | josef <josef> | 2002-10-07 13:32:35 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-07 13:32:35 (UTC) |
commit | fa8df8b9d316f15bc089df5bde7eafb2ef10b36d (patch) (unidiff) | |
tree | 8e450fb00ea73504573a35fa782a2a1735aea355 | |
parent | 68d98791b05217163f97d7c233952df8075416bb (diff) | |
download | opie-fa8df8b9d316f15bc089df5bde7eafb2ef10b36d.zip opie-fa8df8b9d316f15bc089df5bde7eafb2ef10b36d.tar.gz opie-fa8df8b9d316f15bc089df5bde7eafb2ef10b36d.tar.bz2 |
- finish factorization :)
- does not work yet, but only minor bugs are left
-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,352 +1,178 @@ | |||
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 ) |
19 | : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) | 16 | : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) |
20 | { | 17 | { |
21 | initUI(); | 18 | initUI(); |
22 | 19 | ||
23 | // Apply current profile | 20 | // Apply current profile |
24 | // plugin_plugin->load(profile); | 21 | // plugin_plugin->load(profile); |
25 | // ... (reset profile name line edit etc.) | 22 | // ... (reset profile name line edit etc.) |
26 | } | 23 | } |
27 | 24 | ||
28 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | 25 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) |
29 | : QTabDialog(0, 0, TRUE), m_fact( fact ) | 26 | : QTabDialog(0, 0, TRUE), m_fact( fact ) |
30 | { | 27 | { |
31 | // Default profile | 28 | // Default profile |
32 | m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102); | 29 | m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102); |
33 | 30 | ||
34 | initUI(); | 31 | initUI(); |
35 | 32 | ||
36 | // Apply current profile | 33 | // Apply current profile |
37 | // plugin_plugin->load(profile); | 34 | // plugin_plugin->load(profile); |
38 | } | 35 | } |
39 | 36 | ||
40 | Profile ProfileEditorDialog::profile() const | 37 | Profile ProfileEditorDialog::profile() const |
41 | { | 38 | { |
42 | return m_prof; | 39 | return m_prof; |
43 | } | 40 | } |
44 | 41 | ||
45 | void ProfileEditorDialog::initUI() | 42 | void ProfileEditorDialog::initUI() |
46 | { | 43 | { |
47 | QWidget *tabterm, *tabconn, *tabprof; | 44 | QWidget *tabterm, *tabconn, *tabprof; |
48 | 45 | ||
49 | tabprof = new QWidget(this); | 46 | tabprof = new QWidget(this); |
50 | tabterm = new QWidget(this); | 47 | tabterm = new QWidget(this); |
51 | tabconn = new QWidget(this); | 48 | tabconn = new QWidget(this); |
52 | 49 | ||
53 | // for the time being: fake factory | 50 | // for the time being: fake factory |
54 | 51 | ||
55 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); | 52 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); |
56 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); | 53 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); |
57 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); | 54 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); |
58 | 55 | ||
59 | // profile tab | 56 | // profile tab |
60 | 57 | ||
61 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 58 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
62 | 59 | ||
63 | name_line = new QLineEdit(tabprof); | 60 | name_line = new QLineEdit(tabprof); |
64 | 61 | ||
65 | // connection tab, fixed part | 62 | // connection tab, fixed part |
66 | 63 | ||
67 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); | 64 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); |
68 | 65 | ||
69 | device_box = new QComboBox(tabconn); | 66 | device_box = new QComboBox(tabconn); |
70 | 67 | ||
71 | QStringList w = m_fact->configWidgets(); | 68 | QStringList w = m_fact->configWidgets(); |
72 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 69 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
73 | device_box->insertItem(m_fact->name((*it))); | 70 | device_box->insertItem(m_fact->name((*it))); |
74 | 71 | ||
75 | // connection tab, factory part | 72 | // connection tab, factory part |
76 | plugin_base = new QWidget(tabconn); | 73 | plugin_base = new QWidget(tabconn); |
77 | plugin_layout = new QHBoxLayout(plugin_base, 0); | 74 | plugin_layout = new QHBoxLayout(plugin_base, 0); |
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")); |
195 | setCancelButton(QObject::tr("Cancel")); | 110 | setCancelButton(QObject::tr("Cancel")); |
196 | 111 | ||
197 | // load profile values | 112 | // load profile values |
198 | 113 | ||
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 | ||
218 | void ProfileEditorDialog::slotDevice(int id) | 126 | void ProfileEditorDialog::slotDevice(int id) |
219 | { | 127 | { |
220 | delete plugin_plugin; | 128 | delete plugin_plugin; |
221 | 129 | ||
222 | plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, m_prof); | 130 | plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, m_prof); |
223 | plugin_layout->add(plugin_plugin->widget()); | 131 | plugin_layout->add(plugin_plugin->widget()); |
224 | 132 | ||
225 | // Reload profile associated to device, including e.g. conn_device() | 133 | // Reload profile associated to device, including e.g. conn_device() |
226 | // m_prof = plugin_plugin->profile() | 134 | // m_prof = plugin_plugin->profile() |
227 | // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) | 135 | // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) |
228 | 136 | ||
229 | //plugin_plugin->show(); | 137 | //plugin_plugin->show(); |
230 | plugin_plugin->widget()->show(); | 138 | plugin_plugin->widget()->show(); |
231 | } | 139 | } |
232 | 140 | ||
233 | void ProfileEditorDialog::accept() | 141 | void ProfileEditorDialog::accept() |
234 | { | 142 | { |
235 | if(prof_name().isEmpty()) | 143 | if(prof_name().isEmpty()) |
236 | { | 144 | { |
237 | QMessageBox::information(this, | 145 | QMessageBox::information(this, |
238 | QObject::tr("Invalid profile"), | 146 | QObject::tr("Invalid profile"), |
239 | QObject::tr("Please enter a profile name.")); | 147 | QObject::tr("Please enter a profile name.")); |
240 | return; | 148 | return; |
241 | } | 149 | } |
242 | // Save profile and plugin profile | 150 | // Save profile and plugin profile |
243 | if(plugin_plugin) plugin_plugin->save(); | 151 | if(plugin_plugin) plugin_plugin->save(); |
244 | 152 | ||
245 | // Save general values | 153 | // Save general values |
246 | m_prof.setName(prof_name()); | 154 | m_prof.setName(prof_name()); |
247 | 155 | ||
248 | QDialog::accept(); | 156 | QDialog::accept(); |
249 | } | 157 | } |
250 | 158 | ||
251 | void ProfileEditorDialog::slotCancel() | 159 | void ProfileEditorDialog::slotCancel() |
252 | { | 160 | { |
253 | reject(); | 161 | reject(); |
254 | } | 162 | } |
255 | 163 | ||
256 | QString ProfileEditorDialog::prof_name() | 164 | QString ProfileEditorDialog::prof_name() |
257 | { | 165 | { |
258 | return name_line->text(); | 166 | return name_line->text(); |
259 | } | 167 | } |
260 | 168 | ||
261 | QString ProfileEditorDialog::prof_type() | 169 | QString ProfileEditorDialog::prof_type() |
262 | { | 170 | { |
263 | QStringList w = m_fact->configWidgets(); | 171 | QStringList w = m_fact->configWidgets(); |
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 | |||
@@ -1,94 +1,53 @@ | |||
1 | #ifndef PROFILE_EDITOR_DIALOG | 1 | #ifndef PROFILE_EDITOR_DIALOG |
2 | #define PROFILE_EDITOR_DIALOG | 2 | #define PROFILE_EDITOR_DIALOG |
3 | 3 | ||
4 | #include <qtabdialog.h> | 4 | #include <qtabdialog.h> |
5 | 5 | ||
6 | #include "profile.h" | 6 | #include "profile.h" |
7 | 7 | ||
8 | class MetaFactory; | 8 | class MetaFactory; |
9 | class EditBase; | 9 | class EditBase; |
10 | class QTabWidget; | 10 | class QTabWidget; |
11 | class QHBoxLayout; | 11 | class QHBoxLayout; |
12 | class QLineEdit; | 12 | class QLineEdit; |
13 | class QComboBox; | 13 | class QComboBox; |
14 | class QLabel; | 14 | class QLabel; |
15 | class ProfileEditorPlugin; | 15 | class ProfileEditorPlugin; |
16 | 16 | ||
17 | class ProfileEditorDialog : public QTabDialog { | 17 | class ProfileEditorDialog : public QTabDialog { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | ProfileEditorDialog(MetaFactory* fact, | 20 | ProfileEditorDialog(MetaFactory* fact, |
21 | const Profile& prof ); | 21 | const Profile& prof ); |
22 | ProfileEditorDialog(MetaFactory* fact ); | 22 | ProfileEditorDialog(MetaFactory* fact ); |
23 | ~ProfileEditorDialog(); | 23 | ~ProfileEditorDialog(); |
24 | Profile profile()const; | 24 | Profile profile()const; |
25 | 25 | ||
26 | QString prof_name(); | 26 | QString prof_name(); |
27 | QString prof_type(); | 27 | QString prof_type(); |
28 | 28 | ||
29 | public slots: | 29 | 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; |
48 | QHBoxLayout* m_lay; | 42 | QHBoxLayout* m_lay; |
49 | Profile m_prof; | 43 | Profile m_prof; |
50 | 44 | ||
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 | |||
@@ -1,176 +1,479 @@ | |||
1 | 1 | ||
2 | #include "profileeditorplugins.h" | 2 | #include "profileeditorplugins.h" |
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; |
15 | } | 23 | } |
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) |
28 | { | 321 | { |
29 | } | 322 | } |
30 | 323 | ||
31 | ~ProfileEditorPluginSerial() | 324 | ~ProfileEditorPluginSerial() |
32 | { | 325 | { |
33 | } | 326 | } |
34 | 327 | ||
35 | QWidget *widget() | 328 | QWidget *widget() |
36 | { | 329 | { |
37 | if(!m_widget) | 330 | if(!m_widget) |
38 | { | 331 | { |
39 | QFrame *device_frame = new QFrame(m_parent); | 332 | QFrame *device_frame = new QFrame(m_parent); |
40 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 333 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
41 | 334 | ||
42 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | 335 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); |
43 | 336 | ||
44 | device_line = new QLineEdit("/dev/ttyS0", device_frame); | 337 | device_line = new QLineEdit("/dev/ttyS0", device_frame); |
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() |
57 | { | 353 | { |
58 | // special settings | 354 | // special settings |
59 | Profile p = m_profile; | 355 | Profile p = m_profile; |
60 | p.writeEntry("Device", device_line->text()); | 356 | p.writeEntry("Device", device_line->text()); |
61 | } | 357 | } |
62 | 358 | ||
63 | private: | 359 | private: |
64 | QLineEdit *device_line; | 360 | QLineEdit *device_line; |
65 | }; | 361 | }; |
66 | 362 | ||
67 | class ProfileEditorPluginIrda : public ProfileEditorPlugin | 363 | class ProfileEditorPluginIrda : public ProfileEditorPlugin |
68 | { | 364 | { |
69 | public: | 365 | public: |
70 | 366 | ||
71 | ProfileEditorPluginIrda(QWidget *parent, Profile p) | 367 | ProfileEditorPluginIrda(QWidget *parent, Profile p) |
72 | : ProfileEditorPlugin(parent, p) | 368 | : ProfileEditorPlugin(parent, p) |
73 | { | 369 | { |
74 | } | 370 | } |
75 | 371 | ||
76 | ~ProfileEditorPluginIrda() | 372 | ~ProfileEditorPluginIrda() |
77 | { | 373 | { |
78 | } | 374 | } |
79 | 375 | ||
80 | QWidget *widget() | 376 | QWidget *widget() |
81 | { | 377 | { |
82 | if(!m_widget) | 378 | if(!m_widget) |
83 | { | 379 | { |
84 | QFrame *device_frame = new QFrame(m_parent); | 380 | QFrame *device_frame = new QFrame(m_parent); |
85 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 381 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
86 | 382 | ||
87 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | 383 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); |
88 | 384 | ||
89 | device_line = new QLineEdit("/dev/ircomm0", device_frame); | 385 | device_line = new QLineEdit("/dev/ircomm0", device_frame); |
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() |
102 | { | 401 | { |
103 | // special settings | 402 | // special settings |
104 | Profile p = m_profile; | 403 | Profile p = m_profile; |
105 | p.writeEntry("Device", device_line->text()); | 404 | p.writeEntry("Device", device_line->text()); |
106 | } | 405 | } |
107 | 406 | ||
108 | private: | 407 | private: |
109 | QLineEdit *device_line; | 408 | QLineEdit *device_line; |
110 | }; | 409 | }; |
111 | 410 | ||
112 | class ProfileEditorPluginModem : public ProfileEditorPlugin | 411 | class ProfileEditorPluginModem : public ProfileEditorPlugin |
113 | { | 412 | { |
114 | public: | 413 | public: |
115 | 414 | ||
116 | ProfileEditorPluginModem(QWidget *parent, Profile p) | 415 | ProfileEditorPluginModem(QWidget *parent, Profile p) |
117 | : ProfileEditorPlugin(parent, p) | 416 | : ProfileEditorPlugin(parent, p) |
118 | { | 417 | { |
119 | } | 418 | } |
120 | 419 | ||
121 | ~ProfileEditorPluginModem() | 420 | ~ProfileEditorPluginModem() |
122 | { | 421 | { |
123 | } | 422 | } |
124 | 423 | ||
125 | QWidget *widget() | 424 | QWidget *widget() |
126 | { | 425 | { |
127 | if(!m_widget) | 426 | if(!m_widget) |
128 | { | 427 | { |
129 | QFrame *device_frame = new QFrame(m_parent); | 428 | QFrame *device_frame = new QFrame(m_parent); |
130 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); | 429 | device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken); |
131 | 430 | ||
132 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); | 431 | QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame); |
133 | QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame); | 432 | QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame); |
134 | 433 | ||
135 | device_line = new QLineEdit("/dev/ttyS0", device_frame); | 434 | device_line = new QLineEdit("/dev/ttyS0", device_frame); |
136 | number_line = new QLineEdit(device_frame); | 435 | number_line = new QLineEdit(device_frame); |
137 | 436 | ||
138 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); | 437 | QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2); |
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() |
151 | { | 454 | { |
152 | // special settings | 455 | // special settings |
153 | Profile p = m_profile; | 456 | Profile p = m_profile; |
154 | p.writeEntry("Device", device_line->text()); | 457 | p.writeEntry("Device", device_line->text()); |
155 | p.writeEntry("Number", number_line->text()); | 458 | p.writeEntry("Number", number_line->text()); |
156 | } | 459 | } |
157 | 460 | ||
158 | private: | 461 | private: |
159 | QLineEdit *device_line, *number_line; | 462 | QLineEdit *device_line, *number_line; |
160 | }; | 463 | }; |
161 | 464 | ||
162 | ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p) | 465 | ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p) |
163 | { | 466 | { |
164 | return new ProfileEditorPluginSerial(parent, p); | 467 | return new ProfileEditorPluginSerial(parent, p); |
165 | } | 468 | } |
166 | 469 | ||
167 | ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p) | 470 | ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p) |
168 | { | 471 | { |
169 | return new ProfileEditorPluginIrda(parent, p); | 472 | return new ProfileEditorPluginIrda(parent, p); |
170 | } | 473 | } |
171 | 474 | ||
172 | ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p) | 475 | ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p) |
173 | { | 476 | { |
174 | return new ProfileEditorPluginModem(parent, p); | 477 | return new ProfileEditorPluginModem(parent, p); |
175 | } | 478 | } |
176 | 479 | ||
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,37 +1,97 @@ | |||
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 | ||
28 | ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p); | 88 | ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p); |
29 | ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p); | 89 | ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p); |
30 | ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p); | 90 | ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p); |
31 | 91 | ||
32 | //#ifdef __cplusplus | 92 | //#ifdef __cplusplus |
33 | //} | 93 | //} |
34 | //#endif | 94 | //#endif |
35 | 95 | ||
36 | #endif | 96 | #endif |
37 | 97 | ||