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.cpp81
1 files changed, 8 insertions, 73 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index aee4051..fbe0f23 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -2,90 +2,27 @@
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" 7#include "qradiobutton.h"
8#include "qcombobox.h" 8#include "qcombobox.h"
9#include "qcheckbox.h" 9#include "qcheckbox.h"
10#include "qmessagebox.h" 10#include "qmessagebox.h"
11#include "qbuttongroup.h" 11#include "qbuttongroup.h"
12#include "qstringlist.h" 12#include "qstringlist.h"
13 13
14#include "profileeditorplugins.h"
14#include "metafactory.h" 15#include "metafactory.h"
15 16
16static QWidget *factory_serial(QWidget *parent)
17{
18 QFrame *device_frame = new QFrame(parent);
19 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
20
21 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
22
23 QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame);
24
25 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
26 vbox_frame->add(frame_device);
27 vbox_frame->add(frame_device_line);
28
29 return device_frame;
30}
31
32static QWidget *factory_irda(QWidget *parent)
33{
34 QFrame *device_frame = new QFrame(parent);
35 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
36
37 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
38
39 QLineEdit *frame_device_line = new QLineEdit("/dev/ircomm0", device_frame);
40
41 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
42 vbox_frame->add(frame_device);
43 vbox_frame->add(frame_device_line);
44
45 return device_frame;
46}
47
48static QWidget *factory_modem(QWidget *parent)
49{
50 QFrame *device_frame = new QFrame(parent);
51 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
52
53 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
54 QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame);
55
56 QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame);
57 QLineEdit *frame_number_line = new QLineEdit(device_frame);
58
59 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
60 vbox_frame->add(frame_device);
61 vbox_frame->add(frame_device_line);
62 vbox_frame->add(frame_number);
63 vbox_frame->add(frame_number_line);
64
65 return device_frame;
66}
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
80ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, 17ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
81 const Profile& prof ) 18 const Profile& prof )
82 : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) 19 : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
83{ 20{
84 initUI(); 21 initUI();
85 22
86 // Apply current profile 23 // Apply current profile
87 // plugin_plugin->load(profile); 24 // plugin_plugin->load(profile);
88 // ... (reset profile name line edit etc.) 25 // ... (reset profile name line edit etc.)
89} 26}
90 27
91ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 28ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
@@ -130,26 +67,26 @@ void ProfileEditorDialog::initUI()
130 QLabel *device = new QLabel(QObject::tr("Device"), tabconn); 67 QLabel *device = new QLabel(QObject::tr("Device"), tabconn);
131 68
132 device_box = new QComboBox(tabconn); 69 device_box = new QComboBox(tabconn);
133 70
134 QStringList w = m_fact->configWidgets(); 71 QStringList w = m_fact->configWidgets();
135 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 72 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
136 device_box->insertItem(m_fact->name((*it))); 73 device_box->insertItem(m_fact->name((*it)));
137 74
138 // connection tab, factory part 75 // connection tab, factory part
139 plugin_base = new QWidget(tabconn); 76 plugin_base = new QWidget(tabconn);
140 plugin_layout = new QHBoxLayout(plugin_base, 0); 77 plugin_layout = new QHBoxLayout(plugin_base, 0);
141 78
142 plugin_plugin = m_fact->newConfigWidget("serial", plugin_base); 79 plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, m_prof);
143 plugin_layout->add(plugin_plugin); 80 plugin_layout->add(plugin_plugin->widget());
144 81
145 // connection tab, general part 82 // connection tab, general part
146 83
147 speed_box = new QComboBox(tabconn); 84 speed_box = new QComboBox(tabconn);
148 speed_box->insertItem("115200 baud"); 85 speed_box->insertItem("115200 baud");
149 speed_box->insertItem("57600 baud"); 86 speed_box->insertItem("57600 baud");
150 speed_box->insertItem("38400 baud"); 87 speed_box->insertItem("38400 baud");
151 speed_box->insertItem("19200 baud"); 88 speed_box->insertItem("19200 baud");
152 speed_box->insertItem("9600 baud"); 89 speed_box->insertItem("9600 baud");
153 90
154 QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn); 91 QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn);
155 QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn); 92 QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn);
@@ -248,62 +185,60 @@ void ProfileEditorDialog::initUI()
248 vbox2->add(options); 185 vbox2->add(options);
249 QHBoxLayout *hbox4 = new QHBoxLayout(vbox2, 2); 186 QHBoxLayout *hbox4 = new QHBoxLayout(vbox2, 2);
250 hbox4->add(option_wrap); 187 hbox4->add(option_wrap);
251 hbox4->add(option_echo); 188 hbox4->add(option_echo);
252 189
253 addTab(tabprof, QObject::tr("Profile")); 190 addTab(tabprof, QObject::tr("Profile"));
254 addTab(tabconn, QObject::tr("Connection")); 191 addTab(tabconn, QObject::tr("Connection"));
255 addTab(tabterm, QObject::tr("Terminal")); 192 addTab(tabterm, QObject::tr("Terminal"));
256 193
257 setOkButton(QObject::tr("OK")); 194 setOkButton(QObject::tr("OK"));
258 setCancelButton(QObject::tr("Cancel")); 195 setCancelButton(QObject::tr("Cancel"));
259 196
260 //connect(this, SIGNAL(applyButtonPressed()), SLOT(slotOk()));
261 connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotOk()));
262 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel())); 197 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel()));
263 198
264 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); 199 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
265} 200}
266 201
267ProfileEditorDialog::~ProfileEditorDialog() { 202ProfileEditorDialog::~ProfileEditorDialog() {
268 203
269} 204}
270 205
271void ProfileEditorDialog::slotDevice(int id) 206void ProfileEditorDialog::slotDevice(int id)
272{ 207{
273 delete plugin_plugin; 208 delete plugin_plugin;
274 209
275 plugin_plugin = m_fact->newConfigWidget(prof_type(), plugin_base); 210 plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, m_prof);
276 plugin_layout->add(plugin_plugin); 211 plugin_layout->add(plugin_plugin->widget());
277 212
278 // Reload profile associated to device, including e.g. conn_device() 213 // Reload profile associated to device, including e.g. conn_device()
279 // m_prof = plugin_plugin->profile() 214 // m_prof = plugin_plugin->profile()
280 // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) 215 // or, keeping the profile name: m_prof->reload(plugin_plugin->profile())
281 216
282 plugin_plugin->show(); 217 //plugin_plugin->show();
283 // This would be: plugin_plugin->widget()->show(); 218 plugin_plugin->widget()->show();
284} 219}
285 220
286void ProfileEditorDialog::accept() 221void ProfileEditorDialog::accept()
287{ 222{
288 if(prof_name().isEmpty()) 223 if(prof_name().isEmpty())
289 { 224 {
290 QMessageBox::information(this, 225 QMessageBox::information(this,
291 QObject::tr("Invalid profile"), 226 QObject::tr("Invalid profile"),
292 QObject::tr("Please enter a profile name.")); 227 QObject::tr("Please enter a profile name."));
293 return; 228 return;
294 } 229 }
295 230
296 // Save profile and plugin profile 231 // Save profile and plugin profile
297 //if(plugin_plugin) plugin_plugin->save(); 232 if(plugin_plugin) plugin_plugin->save();
298 233
299 QDialog::accept(); 234 QDialog::accept();
300} 235}
301 236
302void ProfileEditorDialog::slotCancel() 237void ProfileEditorDialog::slotCancel()
303{ 238{
304 reject(); 239 reject();
305} 240}
306 241
307QString ProfileEditorDialog::prof_name() 242QString ProfileEditorDialog::prof_name()
308{ 243{
309 return name_line->text(); 244 return name_line->text();