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.cpp256
1 files changed, 253 insertions, 3 deletions
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp
index a4246e1..849439d 100644
--- a/noncore/apps/opie-console/profileeditordialog.cpp
+++ b/noncore/apps/opie-console/profileeditordialog.cpp
@@ -1,20 +1,270 @@
1 1
2#include "profileeditordialog.h" 2#include "profileeditordialog.h"
3 3
4#include "qlayout.h"
5#include "qlineedit.h"
6#include "qlabel.h"
7#include "qradiobutton.h"
8#include "qcombobox.h"
9#include "qcheckbox.h"
10#include "qmessagebox.h"
4 11
5ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, 12ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
6 const Profile& prof ) 13 const Profile& prof )
7 : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) 14 : QTabDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
8{ 15{
9 initUI(); 16// initUI();
10 /* now set the widgets */ 17 /* now set the widgets */
18
11} 19}
20
12ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 21ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
13 : QDialog(0, 0, TRUE), m_fact( fact ) 22 : QTabDialog(0, 0, TRUE), m_fact( fact )
14{ 23{
24 QWidget *tabterm, *tabconn, *tabprof;
25
26 tabprof = new QWidget(this);
27 tabterm = new QWidget(this);
28 tabconn = new QWidget(this);
29
30 // profile tab
31
32 QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
33 QLabel *device = new QLabel(QObject::tr("Device"), tabprof);
34
35 name_line = new QLineEdit(tabprof);
36
37 device_box = new QComboBox(tabprof);
38 device_box->insertItem(QObject::tr("Serial cable"));
39 device_box->insertItem(QObject::tr("IrDA port"));
40 device_box->insertItem(QObject::tr("Serial via modem"));
41
42 QFrame *device_frame = new QFrame(tabprof);
43 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
44
45 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
46 frame_number = new QLabel(QObject::tr("Phone number"), device_frame);
47 frame_number->hide();
48
49 frame_device_line = new QLineEdit("/dev/ttyS0", device_frame);
50 frame_number_line = new QLineEdit(device_frame);
51 frame_number_line->hide();
52
53 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
54 vbox_frame->add(frame_device);
55 vbox_frame->add(frame_device_line);
56 vbox_frame->add(frame_number);
57 vbox_frame->add(frame_number_line);
58
59 // connection tab
60
61 speed_box = new QComboBox(tabconn);
62 speed_box->insertItem("115200 baud");
63 speed_box->insertItem("57600 baud");
64 speed_box->insertItem("38400 baud");
65 speed_box->insertItem("19200 baud");
66 speed_box->insertItem("9600 baud");
67
68 QLabel *protocol = new QLabel(QObject::tr("Protocol"), tabconn);
69 QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn);
70 QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn);
71 QLabel *parity = new QLabel(QObject::tr("Parity"), tabconn);
72
73 QComboBox *protocol_box = new QComboBox(tabconn);
74 protocol_box->insertItem(QObject::tr("XModem"));
75 protocol_box->insertItem(QObject::tr("YModem"));
76 protocol_box->insertItem(QObject::tr("ZModem"));
77
78 QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), tabconn);
79 QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), tabconn);
80
81 QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), tabconn);
82 QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), tabconn);
83
84 flow_sw->setChecked(true);
85 parity_odd->setChecked(true);
15 86
87 // terminal tab
88
89 terminal_box = new QComboBox(tabterm);
90 terminal_box->insertItem("VT 100");
91 terminal_box->insertItem("VT 102");
92
93 QLabel *terminal = new QLabel(QObject::tr("Terminal type"), tabterm);
94 QLabel *colour = new QLabel(QObject::tr("Colour scheme"), tabterm);
95 QLabel *size = new QLabel(QObject::tr("Font size"), tabterm);
96 QLabel *options = new QLabel(QObject::tr("Options"), tabterm);
97 QLabel *conversions = new QLabel(QObject::tr("Line-break conversions"), tabterm);
98
99 QComboBox *colour_box = new QComboBox(tabterm);
100 colour_box->insertItem(QObject::tr("black on white"));
101 colour_box->insertItem(QObject::tr("white on black"));
102
103 QRadioButton *size_small = new QRadioButton(QObject::tr("small"), tabterm);
104 QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), tabterm);
105 QRadioButton *size_large = new QRadioButton(QObject::tr("large"), tabterm);
106
107 QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm);
108 QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm);
109
110 QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), tabterm);
111 QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm);
112
113 // layouting
114
115 QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
116 vbox3->add(name);
117 vbox3->add(name_line);
118 vbox3->add(device);
119 vbox3->add(device_box);
120 vbox3->add(device_frame);
121
122 QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2);
123 vbox->add(protocol);
124 vbox->add(protocol_box);
125 vbox->add(speed);
126 vbox->add(speed_box);
127 vbox->add(flow);
128 QHBoxLayout *hbox = new QHBoxLayout(vbox, 2);
129 hbox->add(flow_hw);
130 hbox->add(flow_sw);
131 vbox->add(parity);
132 QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2);
133 hbox2->add(parity_odd);
134 hbox2->add(parity_even);
135
136 QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2);
137 vbox2->add(terminal);
138 vbox2->add(terminal_box);
139 vbox2->add(size);
140 QHBoxLayout *hbox3 = new QHBoxLayout(vbox2, 2);
141 hbox3->add(size_small);
142 hbox3->add(size_medium);
143 hbox3->add(size_large);
144 vbox2->add(colour);
145 vbox2->add(colour_box);
146 vbox2->add(conversions);
147 QHBoxLayout *hbox5 = new QHBoxLayout(vbox2, 2);
148 hbox5->add(conv_inbound);
149 hbox5->add(conv_outbound);
150 vbox2->add(options);
151 QHBoxLayout *hbox4 = new QHBoxLayout(vbox2, 2);
152 hbox4->add(option_wrap);
153 hbox4->add(option_echo);
154
155 addTab(tabprof, QObject::tr("Profile"));
156 addTab(tabconn, QObject::tr("Connection"));
157 addTab(tabterm, QObject::tr("Terminal"));
158
159 setOkButton(QObject::tr("OK"));
160 setCancelButton(QObject::tr("Cancel"));
161
162 connect(this, SIGNAL(applyButtonPressed()), SLOT(slotOk()));
163 connect(this, SIGNAL(defaultButtonPressed()), SLOT(slotOk()));
164 connect(this, SIGNAL(cancelButtonPressed()), SLOT(slotCancel()));
165
166 connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
16} 167}
168
17ProfileEditorDialog::~ProfileEditorDialog() { 169ProfileEditorDialog::~ProfileEditorDialog() {
18 170
19} 171}
20 172
173void ProfileEditorDialog::slotDevice(int id)
174{
175 switch(id)
176 {
177 case 0:
178 frame_device_line->setText("/dev/ttyS0");
179 frame_number->hide();
180 frame_number_line->hide();
181 break;
182 case 1:
183 frame_device_line->setText("/dev/ircomm0");
184 frame_number->hide();
185 frame_number_line->hide();
186 break;
187 case 2:
188 frame_device_line->setText("/dev/ttyS0");
189 frame_number->show();
190 frame_number_line->show();
191 break;
192 }
193}
194
195void ProfileEditorDialog::slotOk()
196{
197 if(prof_name().isEmpty())
198 {
199 QMessageBox::information(this,
200 QObject::tr("Invalid profile"),
201 QObject::tr("Please enter a profile name."));
202 return;
203 }
204
205 accept();
206}
207
208void ProfileEditorDialog::slotCancel()
209{
210 reject();
211}
212
213QString ProfileEditorDialog::prof_name()
214{
215 return name_line->text();
216}
217
218QString ProfileEditorDialog::prof_type()
219{
220 switch(device_box->currentItem())
221 {
222 case 0:
223 return "serial";
224 break;
225 case 1:
226 return "irda";
227 break;
228 case 2:
229 return "modem";
230 break;
231 }
232
233 return QString::null;
234}
235
236QString ProfileEditorDialog::conn_device()
237{
238 return frame_device_line->text();
239}
240
241int ProfileEditorDialog::conn_baud()
242{
243 return speed_box->currentText().toInt();
244}
245
246int ProfileEditorDialog::conn_parity()
247{
248 return 0;
249}
250
251int ProfileEditorDialog::conn_databits()
252{
253 return 0;
254}
255
256int ProfileEditorDialog::conn_stopbits()
257{
258 return 0;
259}
260
261int ProfileEditorDialog::conn_flow()
262{
263 return 0;
264}
265
266QString ProfileEditorDialog::term_type()
267{
268 return terminal_box->currentText();
269}
270