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
@@ -1,103 +1,40 @@
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" 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 )
92 : QTabDialog(0, 0, TRUE), m_fact( fact ) 29 : QTabDialog(0, 0, TRUE), m_fact( fact )
93{ 30{
94 // Default profile 31 // Default profile
95 m_prof = Profile("serial", QString::null, Profile::Black, Profile::White, Profile::VT102); 32 m_prof = Profile("serial", QString::null, Profile::Black, Profile::White, Profile::VT102);
96 33
97 initUI(); 34 initUI();
98 35
99 // Apply current profile 36 // Apply current profile
100 // plugin_plugin->load(profile); 37 // plugin_plugin->load(profile);
101} 38}
102 39
103Profile ProfileEditorDialog::profile() const 40Profile ProfileEditorDialog::profile() const
@@ -118,50 +55,50 @@ void ProfileEditorDialog::initUI()
118 m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); 55 m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial);
119 m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); 56 m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda);
120 m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); 57 m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem);
121 58
122 // profile tab 59 // profile tab
123 60
124 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); 61 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
125 62
126 name_line = new QLineEdit(tabprof); 63 name_line = new QLineEdit(tabprof);
127 64
128 // connection tab, fixed part 65 // connection tab, fixed part
129 66
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);
156 QLabel *parity = new QLabel(QObject::tr("Parity"), tabconn); 93 QLabel *parity = new QLabel(QObject::tr("Parity"), tabconn);
157 94
158 QButtonGroup *group_flow = new QButtonGroup(tabconn); 95 QButtonGroup *group_flow = new QButtonGroup(tabconn);
159 group_flow->hide(); 96 group_flow->hide();
160 QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), tabconn); 97 QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), tabconn);
161 QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), tabconn); 98 QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), tabconn);
162 group_flow->insert(flow_hw); 99 group_flow->insert(flow_hw);
163 group_flow->insert(flow_sw); 100 group_flow->insert(flow_sw);
164 101
165 QButtonGroup *group_parity = new QButtonGroup(tabconn); 102 QButtonGroup *group_parity = new QButtonGroup(tabconn);
166 group_parity->hide(); 103 group_parity->hide();
167 QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), tabconn); 104 QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), tabconn);
@@ -236,86 +173,84 @@ void ProfileEditorDialog::initUI()
236 vbox2->add(size); 173 vbox2->add(size);
237 QHBoxLayout *hbox3 = new QHBoxLayout(vbox2, 2); 174 QHBoxLayout *hbox3 = new QHBoxLayout(vbox2, 2);
238 hbox3->add(size_small); 175 hbox3->add(size_small);
239 hbox3->add(size_medium); 176 hbox3->add(size_medium);
240 hbox3->add(size_large); 177 hbox3->add(size_large);
241 //vbox2->add(group_size); 178 //vbox2->add(group_size);
242 vbox2->add(colour); 179 vbox2->add(colour);
243 vbox2->add(colour_box); 180 vbox2->add(colour_box);
244 vbox2->add(conversions); 181 vbox2->add(conversions);
245 QHBoxLayout *hbox5 = new QHBoxLayout(vbox2, 2); 182 QHBoxLayout *hbox5 = new QHBoxLayout(vbox2, 2);
246 hbox5->add(conv_inbound); 183 hbox5->add(conv_inbound);
247 hbox5->add(conv_outbound); 184 hbox5->add(conv_outbound);
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();
310} 245}
311 246
312QString ProfileEditorDialog::prof_type() 247QString ProfileEditorDialog::prof_type()
313{ 248{
314 QStringList w = m_fact->configWidgets(); 249 QStringList w = m_fact->configWidgets();
315 for(QStringList::Iterator it = w.begin(); it != w.end(); it++) 250 for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
316 if(device_box->currentText() == m_fact->name((*it))) return (*it); 251 if(device_box->currentText() == m_fact->name((*it))) return (*it);
317 252
318 return QString::null; 253 return QString::null;
319} 254}
320 255
321QString ProfileEditorDialog::conn_device() 256QString ProfileEditorDialog::conn_device()