summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/profileeditordialog.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/profileeditordialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp92
1 files changed, 49 insertions, 43 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index 374844e..aee4051 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -62,24 +62,54 @@ static QWidget *factory_modem(QWidget *parent)
62 vbox_frame->add(frame_number); 62 vbox_frame->add(frame_number);
63 vbox_frame->add(frame_number_line); 63 vbox_frame->add(frame_number_line);
64 64
65 return device_frame; 65 return device_frame;
66} 66}
67 67
68// Something like that must be called upon plugin_plugin->save()
69//void save_modem()
70//{
71 //// special settings
72 //p.writeEntry("Device", dlg.conn_device());
73 //p.writeEntry("Baud", dlg.conn_baud());
74 //p.writeEntry("Parity", dlg.conn_parity());
75 //p.writeEntry("DataBits", dlg.conn_databits());
76 //p.writeEntry("StopBits", dlg.conn_stopbits());
77 //p.writeEntry("Flow", dlg.conn_flow());
78//}
79
68ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, 80ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
69 const Profile& prof ) 81 const Profile& prof )
70 : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) 82 : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
71{ 83{
72// initUI(); 84 initUI();
73 /* now set the widgets */
74 85
86 // Apply current profile
87 // plugin_plugin->load(profile);
88 // ... (reset profile name line edit etc.)
75} 89}
76 90
77ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 91ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
78 : QTabDialog(0, 0, TRUE), m_fact( fact ) 92 : QTabDialog(0, 0, TRUE), m_fact( fact )
79{ 93{
94 // Default profile
95 m_prof = Profile("serial", QString::null, Profile::Black, Profile::White, Profile::VT102);
96
97 initUI();
98
99 // Apply current profile
100 // plugin_plugin->load(profile);
101}
102
103Profile ProfileEditorDialog::profile() const
104{
105 return m_prof;
106}
107
108void ProfileEditorDialog::initUI()
109{
80 QWidget *tabterm, *tabconn, *tabprof; 110 QWidget *tabterm, *tabconn, *tabprof;
81 111
82 tabprof = new QWidget(this); 112 tabprof = new QWidget(this);
83 tabterm = new QWidget(this); 113 tabterm = new QWidget(this);
84 tabconn = new QWidget(this); 114 tabconn = new QWidget(this);
85 115
@@ -171,12 +201,14 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
171 QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm); 201 QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm);
172 QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm); 202 QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm);
173 203
174 QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), tabterm); 204 QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), tabterm);
175 QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm); 205 QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm);
176 206
207 size_small->setChecked(true);
208
177 // layouting 209 // layouting
178 210
179 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); 211 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
180 vbox3->add(name); 212 vbox3->add(name);
181 vbox3->add(name_line); 213 vbox3->add(name_line);
182 vbox3->addStretch(1); 214 vbox3->addStretch(1);
@@ -222,13 +254,13 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
222 addTab(tabconn, QObject::tr("Connection")); 254 addTab(tabconn, QObject::tr("Connection"));
223 addTab(tabterm, QObject::tr("Terminal")); 255 addTab(tabterm, QObject::tr("Terminal"));
224 256
225 setOkButton(QObject::tr("OK")); 257 setOkButton(QObject::tr("OK"));
226 setCancelButton(QObject::tr("Cancel")); 258 setCancelButton(QObject::tr("Cancel"));
227 259
228 connect(this, SIGNAL(applyButtonPressed()), SLOT(slotOk())); 260 //connect(this, SIGNAL(applyButtonPressed()), SLOT(slotOk()));
229 connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotOk())); 261 connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotOk()));
230 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel())); 262 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel()));
231 263
232 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); 264 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
233} 265}
234 266
@@ -240,26 +272,34 @@ void ProfileEditorDialog::slotDevice(int id)
240{ 272{
241 delete plugin_plugin; 273 delete plugin_plugin;
242 274
243 plugin_plugin = m_fact->newConfigWidget(prof_type(), plugin_base); 275 plugin_plugin = m_fact->newConfigWidget(prof_type(), plugin_base);
244 plugin_layout->add(plugin_plugin); 276 plugin_layout->add(plugin_plugin);
245 277
278 // Reload profile associated to device, including e.g. conn_device()
279 // m_prof = plugin_plugin->profile()
280 // or, keeping the profile name: m_prof->reload(plugin_plugin->profile())
281
246 plugin_plugin->show(); 282 plugin_plugin->show();
283 // This would be: plugin_plugin->widget()->show();
247} 284}
248 285
249void ProfileEditorDialog::slotOk() 286void ProfileEditorDialog::accept()
250{ 287{
251 if(prof_name().isEmpty()) 288 if(prof_name().isEmpty())
252 { 289 {
253 QMessageBox::information(this, 290 QMessageBox::information(this,
254 QObject::tr("Invalid profile"), 291 QObject::tr("Invalid profile"),
255 QObject::tr("Please enter a profile name.")); 292 QObject::tr("Please enter a profile name."));
256 return; 293 return;
257 } 294 }
258 295
259 accept(); 296 // Save profile and plugin profile
297 //if(plugin_plugin) plugin_plugin->save();
298
299 QDialog::accept();
260} 300}
261 301
262void ProfileEditorDialog::slotCancel() 302void ProfileEditorDialog::slotCancel()
263{ 303{
264 reject(); 304 reject();
265} 305}
@@ -268,57 +308,23 @@ QString ProfileEditorDialog::prof_name()
268{ 308{
269 return name_line->text(); 309 return name_line->text();
270} 310}
271 311
272QString ProfileEditorDialog::prof_type() 312QString ProfileEditorDialog::prof_type()
273{ 313{
274 switch(device_box->currentItem()) 314 QStringList w = m_fact->configWidgets();
275 { 315 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
276 case 0: 316 if(device_box->currentText() == m_fact->name((*it))) return (*it);
277 return "serial";
278 break;
279 case 1:
280 return "irda";
281 break;
282 case 2:
283 return "modem";
284 break;
285 }
286 317
287 return QString::null; 318 return QString::null;
288} 319}
289 320
290QString ProfileEditorDialog::conn_device() 321QString ProfileEditorDialog::conn_device()
291{ 322{
292 //return frame_device_line->text(); 323 //return frame_device_line->text();
293 return "serial"; 324 return "/dev/ttyS0";
294}
295
296int ProfileEditorDialog::conn_baud()
297{
298 return speed_box->currentText().toInt();
299}
300
301int ProfileEditorDialog::conn_parity()
302{
303 return 0;
304}
305
306int ProfileEditorDialog::conn_databits()
307{
308 return 0;
309}
310
311int ProfileEditorDialog::conn_stopbits()
312{
313 return 0;
314}
315
316int ProfileEditorDialog::conn_flow()
317{
318 return 0;
319} 325}
320 326
321QString ProfileEditorDialog::term_type() 327QString ProfileEditorDialog::term_type()
322{ 328{
323 return terminal_box->currentText(); 329 return terminal_box->currentText();
324} 330}