summaryrefslogtreecommitdiff
authorjosef <josef>2002-10-07 11:26:41 (UTC)
committer josef <josef>2002-10-07 11:26:41 (UTC)
commitd9b425252bc2d3b0d9cb848f823d8eb254f38a26 (patch) (unidiff)
tree6a6e67d77d9d836fcf6d6460c2cad234211e9d97
parent4fad0b73ae2940099bbb6f20bb94ed1f29e6d05b (diff)
downloadopie-d9b425252bc2d3b0d9cb848f823d8eb254f38a26.zip
opie-d9b425252bc2d3b0d9cb848f823d8eb254f38a26.tar.gz
opie-d9b425252bc2d3b0d9cb848f823d8eb254f38a26.tar.bz2
- oops... QComboBox doesn't handle non-consecutive values
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp39
-rw-r--r--noncore/apps/opie-console/profileeditordialog.h32
2 files changed, 59 insertions, 12 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 5b7f851..78885e1 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -110,216 +110,243 @@ void ProfileEditorDialog::initUI()
110 parity_odd->setChecked(true); 110 parity_odd->setChecked(true);
111 111
112 // terminal tab 112 // terminal tab
113 113
114 QComboBox *terminal_box = new QComboBox(tabterm); 114 QComboBox *terminal_box = new QComboBox(tabterm);
115 terminal_box->insertItem("VT 100", id_term_vt100); 115 terminal_box->insertItem("VT 100", id_term_vt100);
116 terminal_box->insertItem("VT 220", id_term_vt220); 116 terminal_box->insertItem("VT 220", id_term_vt220);
117 terminal_box->insertItem("ANSI", id_term_ansi); 117 terminal_box->insertItem("ANSI", id_term_ansi);
118 118
119 QLabel *terminal = new QLabel(QObject::tr("Terminal type"), tabterm); 119 QLabel *terminal = new QLabel(QObject::tr("Terminal type"), tabterm);
120 QLabel *colour = new QLabel(QObject::tr("Colour scheme"), tabterm); 120 QLabel *colour = new QLabel(QObject::tr("Colour scheme"), tabterm);
121 QLabel *size = new QLabel(QObject::tr("Font size"), tabterm); 121 QLabel *size = new QLabel(QObject::tr("Font size"), tabterm);
122 QLabel *options = new QLabel(QObject::tr("Options"), tabterm); 122 QLabel *options = new QLabel(QObject::tr("Options"), tabterm);
123 QLabel *conversions = new QLabel(QObject::tr("Line-break conversions"), tabterm); 123 QLabel *conversions = new QLabel(QObject::tr("Line-break conversions"), tabterm);
124 124
125 QComboBox *colour_box = new QComboBox(tabterm); 125 QComboBox *colour_box = new QComboBox(tabterm);
126 colour_box->insertItem(QObject::tr("black on white")); 126 colour_box->insertItem(QObject::tr("black on white"));
127 colour_box->insertItem(QObject::tr("white on black")); 127 colour_box->insertItem(QObject::tr("white on black"));
128 128
129 QButtonGroup *group_size = new QButtonGroup(tabterm); 129 QButtonGroup *group_size = new QButtonGroup(tabterm);
130 group_size->hide(); 130 group_size->hide();
131 QRadioButton *size_small = new QRadioButton(QObject::tr("small"), tabterm); 131 QRadioButton *size_small = new QRadioButton(QObject::tr("small"), tabterm);
132 QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), tabterm); 132 QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), tabterm);
133 QRadioButton *size_large = new QRadioButton(QObject::tr("large"), tabterm); 133 QRadioButton *size_large = new QRadioButton(QObject::tr("large"), tabterm);
134 group_size->insert(size_small); 134 group_size->insert(size_small);
135 group_size->insert(size_medium); 135 group_size->insert(size_medium);
136 group_size->insert(size_large); 136 group_size->insert(size_large);
137 137
138 QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm); 138 QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm);
139 QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm); 139 QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm);
140 140
141 QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), tabterm); 141 QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), tabterm);
142 QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm); 142 QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm);
143 143
144 size_small->setChecked(true); 144 size_small->setChecked(true);
145 145
146 // layouting 146 // layouting
147 147
148 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); 148 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
149 vbox3->add(name); 149 vbox3->add(name);
150 vbox3->add(name_line); 150 vbox3->add(name_line);
151 vbox3->addStretch(1); 151 vbox3->addStretch(1);
152 152
153 QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); 153 QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2);
154 vbox->add(device); 154 vbox->add(device);
155 vbox->add(device_box); 155 vbox->add(device_box);
156 vbox->add(plugin_base); 156 vbox->add(plugin_base);
157 vbox->add(speed); 157 vbox->add(speed);
158 vbox->add(speed_box); 158 vbox->add(speed_box);
159 vbox->add(flow); 159 vbox->add(flow);
160 QHBoxLayout *hbox = new QHBoxLayout(vbox, 2); 160 QHBoxLayout *hbox = new QHBoxLayout(vbox, 2);
161 hbox->add(flow_hw); 161 hbox->add(flow_hw);
162 hbox->add(flow_sw); 162 hbox->add(flow_sw);
163 //vbox->add(group_flow); 163 //vbox->add(group_flow);
164 vbox->add(parity); 164 vbox->add(parity);
165 QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2); 165 QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2);
166 hbox2->add(parity_odd); 166 hbox2->add(parity_odd);
167 hbox2->add(parity_even); 167 hbox2->add(parity_even);
168 //vbox->add(group_parity); 168 //vbox->add(group_parity);
169 169
170 QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); 170 QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2);
171 vbox2->add(terminal); 171 vbox2->add(terminal);
172 vbox2->add(terminal_box); 172 vbox2->add(terminal_box);
173 vbox2->add(size); 173 vbox2->add(size);
174 QHBoxLayout *hbox3 = new QHBoxLayout(vbox2, 2); 174 QHBoxLayout *hbox3 = new QHBoxLayout(vbox2, 2);
175 hbox3->add(size_small); 175 hbox3->add(size_small);
176 hbox3->add(size_medium); 176 hbox3->add(size_medium);
177 hbox3->add(size_large); 177 hbox3->add(size_large);
178 //vbox2->add(group_size); 178 //vbox2->add(group_size);
179 vbox2->add(colour); 179 vbox2->add(colour);
180 vbox2->add(colour_box); 180 vbox2->add(colour_box);
181 vbox2->add(conversions); 181 vbox2->add(conversions);
182 QHBoxLayout *hbox5 = new QHBoxLayout(vbox2, 2); 182 QHBoxLayout *hbox5 = new QHBoxLayout(vbox2, 2);
183 hbox5->add(conv_inbound); 183 hbox5->add(conv_inbound);
184 hbox5->add(conv_outbound); 184 hbox5->add(conv_outbound);
185 vbox2->add(options); 185 vbox2->add(options);
186 QHBoxLayout *hbox4 = new QHBoxLayout(vbox2, 2); 186 QHBoxLayout *hbox4 = new QHBoxLayout(vbox2, 2);
187 hbox4->add(option_wrap); 187 hbox4->add(option_wrap);
188 hbox4->add(option_echo); 188 hbox4->add(option_echo);
189 189
190 addTab(tabprof, QObject::tr("Profile")); 190 addTab(tabprof, QObject::tr("Profile"));
191 addTab(tabconn, QObject::tr("Connection")); 191 addTab(tabconn, QObject::tr("Connection"));
192 addTab(tabterm, QObject::tr("Terminal")); 192 addTab(tabterm, QObject::tr("Terminal"));
193 193
194 setOkButton(QObject::tr("OK")); 194 setOkButton(QObject::tr("OK"));
195 setCancelButton(QObject::tr("Cancel")); 195 setCancelButton(QObject::tr("Cancel"));
196 196
197 // load profile values 197 // load profile values
198 198
199 name_line->setText(m_prof.name()); 199 name_line->setText(m_prof.name());
200 200
201 // signals 201 // signals
202 202
203 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel())); 203 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel()));
204 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); 204 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
205 205
206 connect(group_flow, SIGNAL(clicked(int)), SLOT(slotConn(int))); 206 connect(group_flow, SIGNAL(clicked(int)), SLOT(slotConnFlow(int)));
207 connect(group_parity, SIGNAL(clicked(int)), SLOT(slotConn(int))); 207 connect(group_parity, SIGNAL(clicked(int)), SLOT(slotConnParity(int)));
208 connect(speed_box, SIGNAL(clicked(int)), SLOT(slotConn(int))); 208 connect(speed_box, SIGNAL(activated(int)), SLOT(slotConnSpeed(int)));
209 209
210 connect(terminal_box, SIGNAL(clicked(int)), SLOT(slotConn(int))); 210 connect(terminal_box, SIGNAL(activated(int)), SLOT(slotTermTerm(int)));
211 connect(group_size, SIGNAL(clicked(int)), SLOT(slotConn(int))); 211 connect(group_size, SIGNAL(clicked(int)), SLOT(slotTermFont(int)));
212} 212}
213 213
214ProfileEditorDialog::~ProfileEditorDialog() { 214ProfileEditorDialog::~ProfileEditorDialog() {
215 215
216} 216}
217 217
218void ProfileEditorDialog::slotDevice(int id) 218void ProfileEditorDialog::slotDevice(int id)
219{ 219{
220 delete plugin_plugin; 220 delete plugin_plugin;
221 221
222 plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, m_prof); 222 plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, m_prof);
223 plugin_layout->add(plugin_plugin->widget()); 223 plugin_layout->add(plugin_plugin->widget());
224 224
225 // Reload profile associated to device, including e.g. conn_device() 225 // Reload profile associated to device, including e.g. conn_device()
226 // m_prof = plugin_plugin->profile() 226 // m_prof = plugin_plugin->profile()
227 // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) 227 // or, keeping the profile name: m_prof->reload(plugin_plugin->profile())
228 228
229 //plugin_plugin->show(); 229 //plugin_plugin->show();
230 plugin_plugin->widget()->show(); 230 plugin_plugin->widget()->show();
231} 231}
232 232
233void ProfileEditorDialog::accept() 233void ProfileEditorDialog::accept()
234{ 234{
235 if(prof_name().isEmpty()) 235 if(prof_name().isEmpty())
236 { 236 {
237 QMessageBox::information(this, 237 QMessageBox::information(this,
238 QObject::tr("Invalid profile"), 238 QObject::tr("Invalid profile"),
239 QObject::tr("Please enter a profile name.")); 239 QObject::tr("Please enter a profile name."));
240 return; 240 return;
241 } 241 }
242 // Save profile and plugin profile 242 // Save profile and plugin profile
243 if(plugin_plugin) plugin_plugin->save(); 243 if(plugin_plugin) plugin_plugin->save();
244 244
245 // Save general values 245 // Save general values
246 m_prof.setName(prof_name()); 246 m_prof.setName(prof_name());
247 247
248 QDialog::accept(); 248 QDialog::accept();
249} 249}
250 250
251void ProfileEditorDialog::slotCancel() 251void ProfileEditorDialog::slotCancel()
252{ 252{
253 reject(); 253 reject();
254} 254}
255 255
256QString ProfileEditorDialog::prof_name() 256QString ProfileEditorDialog::prof_name()
257{ 257{
258 return name_line->text(); 258 return name_line->text();
259} 259}
260 260
261QString ProfileEditorDialog::prof_type() 261QString ProfileEditorDialog::prof_type()
262{ 262{
263 QStringList w = m_fact->configWidgets(); 263 QStringList w = m_fact->configWidgets();
264 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 264 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
265 if(device_box->currentText() == m_fact->name((*it))) return (*it); 265 if(device_box->currentText() == m_fact->name((*it))) return (*it);
266 266
267 return QString::null; 267 return QString::null;
268} 268}
269 269
270void ProfileEditorDialog::slotConn(int id) 270void ProfileEditorDialog::slotConnFlow(int id)
271{ 271{
272 switch(id) 272 switch(id)
273 { 273 {
274 case id_flow_hw: 274 case id_flow_hw:
275 m_prof.writeEntry("Flow", 0x01); 275 m_prof.writeEntry("Flow", 0x01);
276 break; 276 break;
277 case id_flow_sw: 277 case id_flow_sw:
278 m_prof.writeEntry("Flow", 0x02); 278 m_prof.writeEntry("Flow", 0x02);
279 break; 279 break;
280 }
281}
282
283void ProfileEditorDialog::slotConnParity(int id)
284{
285 switch(id)
286 {
280 case id_parity_odd: 287 case id_parity_odd:
281 m_prof.writeEntry("Parity", 2); 288 m_prof.writeEntry("Parity", 2);
282 break; 289 break;
283 case id_parity_even: 290 case id_parity_even:
284 m_prof.writeEntry("Parity", 1); 291 m_prof.writeEntry("Parity", 1);
285 break; 292 break;
293 }
294}
295
296void ProfileEditorDialog::slotConnSpeed(int id)
297{
298 switch(id)
299 {
286 300
287 case id_baud_115200: 301 case id_baud_115200:
288 m_prof.writeEntry("Speed", 115200); 302 m_prof.writeEntry("Speed", 115200);
289 break; 303 break;
290 case id_baud_57600: 304 case id_baud_57600:
291 m_prof.writeEntry("Speed", 57600); 305 m_prof.writeEntry("Speed", 57600);
292 break; 306 break;
293 case id_baud_38400: 307 case id_baud_38400:
294 m_prof.writeEntry("Speed", 38400); 308 m_prof.writeEntry("Speed", 38400);
295 break; 309 break;
296 case id_baud_19200: 310 case id_baud_19200:
297 m_prof.writeEntry("Speed", 19200); 311 m_prof.writeEntry("Speed", 19200);
298 break; 312 break;
299 case id_baud_9600: 313 case id_baud_9600:
300 m_prof.writeEntry("Speed", 9600); 314 m_prof.writeEntry("Speed", 9600);
301 break; 315 break;
316 }
317}
318
319void ProfileEditorDialog::slotTermTerm(int id)
320{
321 switch(id)
322 {
302 323
303 case id_term_vt100: 324 case id_term_vt100:
304 m_prof.writeEntry("Terminal", 2); 325 m_prof.writeEntry("Terminal", 2);
305 break; 326 break;
306 case id_term_vt220: 327 case id_term_vt220:
307 m_prof.writeEntry("Terminal", 1); 328 m_prof.writeEntry("Terminal", 1);
308 break; 329 break;
309 case id_term_ansi: 330 case id_term_ansi:
310 m_prof.writeEntry("Terminal", 0); 331 m_prof.writeEntry("Terminal", 0);
311 break; 332 break;
333 }
334}
312 335
336void ProfileEditorDialog::slotTermFont(int id)
337{
338 switch(id)
339 {
313 case id_size_small: 340 case id_size_small:
314 m_prof.writeEntry("Font", 0); 341 m_prof.writeEntry("Font", 0);
315 break; 342 break;
316 case id_size_medium: 343 case id_size_medium:
317 m_prof.writeEntry("Font", 1); 344 m_prof.writeEntry("Font", 1);
318 break; 345 break;
319 case id_size_large: 346 case id_size_large:
320 m_prof.writeEntry("Font", 2); 347 m_prof.writeEntry("Font", 2);
321 break; 348 break;
322 } 349 }
323} 350}
324 351
325 352
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h
index 0637f44..a6808d0 100644
--- a/noncore/apps/opie-console/profileeditordialog.h
+++ b/noncore/apps/opie-console/profileeditordialog.h
@@ -1,74 +1,94 @@
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
8class MetaFactory; 8class MetaFactory;
9class EditBase; 9class EditBase;
10class QTabWidget; 10class QTabWidget;
11class QHBoxLayout; 11class QHBoxLayout;
12class QLineEdit; 12class QLineEdit;
13class QComboBox; 13class QComboBox;
14class QLabel; 14class QLabel;
15class ProfileEditorPlugin; 15class ProfileEditorPlugin;
16 16
17class ProfileEditorDialog : public QTabDialog { 17class ProfileEditorDialog : public QTabDialog {
18 Q_OBJECT 18 Q_OBJECT
19public: 19public:
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
29public slots: 29public 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 slotConn(int id); 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);
37 41
38private: 42private:
39 void initUI(); 43 void initUI();
40 44
41 MetaFactory* m_fact; 45 MetaFactory* m_fact;
42 EditBase* m_base; 46 EditBase* m_base;
43 QTabWidget* m_tab; 47 QTabWidget* m_tab;
44 QHBoxLayout* m_lay; 48 QHBoxLayout* m_lay;
45 Profile m_prof; 49 Profile m_prof;
46 50
47 QLineEdit *name_line; 51 QLineEdit *name_line;
48 QComboBox *device_box; 52 QComboBox *device_box;
49 53
50 QWidget *plugin_base; 54 QWidget *plugin_base;
51 ProfileEditorPlugin *plugin_plugin; 55 ProfileEditorPlugin *plugin_plugin;
52 QHBoxLayout *plugin_layout; 56 QHBoxLayout *plugin_layout;
53 57
54 enum Ids 58 enum ParityIds
55 { 59 {
56 id_parity_odd, 60 id_parity_odd,
57 id_parity_even, 61 id_parity_even
62 };
63
64 enum FlowIds
65 {
58 id_flow_hw, 66 id_flow_hw,
59 id_flow_sw, 67 id_flow_sw
68 };
69
70 enum SpeedIds
71 {
60 id_baud_115200, 72 id_baud_115200,
61 id_baud_57600, 73 id_baud_57600,
62 id_baud_38400, 74 id_baud_38400,
63 id_baud_19200, 75 id_baud_19200,
64 id_baud_9600, 76 id_baud_9600
77 };
78
79 enum TermIds
80 {
65 id_term_vt100, 81 id_term_vt100,
66 id_term_vt220, 82 id_term_vt220,
67 id_term_ansi, 83 id_term_ansi
84 };
85
86 enum FontIds
87 {
68 id_size_small, 88 id_size_small,
69 id_size_medium, 89 id_size_medium,
70 id_size_large 90 id_size_large
71 }; 91 };
72}; 92};
73 93
74#endif 94#endif