summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/configdialog.cpp46
-rw-r--r--noncore/apps/opie-console/main.cpp5
-rw-r--r--noncore/apps/opie-console/opie-console.pro6
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp256
-rw-r--r--noncore/apps/opie-console/profileeditordialog.h34
5 files changed, 335 insertions, 12 deletions
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp
index ba3cd31..d09cec3 100644
--- a/noncore/apps/opie-console/configdialog.cpp
+++ b/noncore/apps/opie-console/configdialog.cpp
@@ -2,6 +2,9 @@
2#include "profile.h" 2#include "profile.h"
3#include "qlistview.h" 3#include "qlistview.h"
4#include "configdialog.h" 4#include "configdialog.h"
5#include "profileeditordialog.h"
6#include "metafactory.h"
7#include "qdialog.h"
5 8
6class ConfigListItem : public QListViewItem { 9class ConfigListItem : public QListViewItem {
7public: 10public:
@@ -59,10 +62,53 @@ void ConfigDialog::slotRemove() {
59 lstView->takeItem( item ); 62 lstView->takeItem( item );
60 delete item; 63 delete item;
61} 64}
65
62void ConfigDialog::slotEdit() { 66void ConfigDialog::slotEdit() {
67 ProfileEditorDialog dlg(new MetaFactory());
68
69 dlg.setCaption("Edit Connection Profile");
70 dlg.showMaximized();
71 int ret = dlg.exec();
63 72
73 if(ret == QDialog::Accepted)
74 {
75 // if(listView->current()) delete lstView->current(); ...
76 // use dlg.terminal()!
77 new ConfigListItem(lstView, Profile(dlg.prof_name(), dlg.prof_type(), Profile::White, Profile::Black, Profile::VT102));
78 }
64} 79}
80
81
65void ConfigDialog::slotAdd() { 82void ConfigDialog::slotAdd() {
83 qWarning("ConfigDialog::slotAdd");
84
85 ProfileEditorDialog dlg(new MetaFactory());
86
87 dlg.setCaption("New Connection");
88 dlg.showMaximized();
89 int ret = dlg.exec();
90
91 if(ret == QDialog::Accepted)
92 {
93 // defaults
94 int profile = Profile::VT102;
95
96 // assignments
97 QString type = dlg.term_type();
98 if(type == "VT102") profile = Profile::VT102;
99
100 // new profile
101 Profile p(dlg.prof_name(), dlg.prof_type(), Profile::White, Profile::Black, profile);
102
103 // special settings
104 p.writeEntry("Device", dlg.conn_device());
105 p.writeEntry("Baud", dlg.conn_baud());
106 p.writeEntry("Parity", dlg.conn_parity());
107 p.writeEntry("DataBits", dlg.conn_databits());
108 p.writeEntry("StopBits", dlg.conn_stopbits());
109 p.writeEntry("Flow", dlg.conn_flow());
66 110
111 new ConfigListItem(lstView, p);
112 }
67} 113}
68 114
diff --git a/noncore/apps/opie-console/main.cpp b/noncore/apps/opie-console/main.cpp
index 4b5107e..350bb3e 100644
--- a/noncore/apps/opie-console/main.cpp
+++ b/noncore/apps/opie-console/main.cpp
@@ -9,8 +9,5 @@ int main(int argc, char **argv) {
9 mw.setCaption(QObject::tr("Opie console") ); 9 mw.setCaption(QObject::tr("Opie console") );
10 app.showMainWidget( &mw ); 10 app.showMainWidget( &mw );
11 11
12 app.exec(); 12 return app.exec();
13
14
15 return 0;
16} 13}
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 9e44ab0..5a352e0 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -11,7 +11,8 @@ HEADERS = io_layer.h io_serial.h \
11 profilemanager.h \ 11 profilemanager.h \
12 configwidget.h \ 12 configwidget.h \
13 tabwidget.h \ 13 tabwidget.h \
14 configdialog.h 14 configdialog.h \
15 profileeditordialog.h
15SOURCES = io_layer.cpp io_serial.cpp \ 16SOURCES = io_layer.cpp io_serial.cpp \
16 file_layer.cpp main.cpp \ 17 file_layer.cpp main.cpp \
17 metafactory.cpp \ 18 metafactory.cpp \
@@ -21,7 +22,8 @@ SOURCES = io_layer.cpp io_serial.cpp \
21 profileconfig.cpp \ 22 profileconfig.cpp \
22 profilemanager.cpp \ 23 profilemanager.cpp \
23 tabwidget.cpp \ 24 tabwidget.cpp \
24 configdialog.cpp 25 configdialog.cpp \
26 profileeditordialog.cpp
25INTERFACES = configurebase.ui editbase.ui 27INTERFACES = configurebase.ui editbase.ui
26INCLUDEPATH += $(OPIEDIR)/include 28INCLUDEPATH += $(OPIEDIR)/include
27DEPENDPATH += $(OPIEDIR)/include 29DEPENDPATH += $(OPIEDIR)/include
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
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h
index 5ccc691..f81354c 100644
--- a/noncore/apps/opie-console/profileeditordialog.h
+++ b/noncore/apps/opie-console/profileeditordialog.h
@@ -1,7 +1,7 @@
1#ifndef PROFILE_EDITOR_DIALOG 1#ifndef PROFILE_EDITOR_DIALOG
2#define PROFILE_EDITOR_DIALOG 2#define PROFILE_EDITOR_DIALOG
3 3
4#include <qdialog.h> 4#include <qtabdialog.h>
5 5
6#include "profile.h" 6#include "profile.h"
7 7
@@ -9,20 +9,48 @@ class MetaFactory;
9class EditBase; 9class EditBase;
10class QTabWidget; 10class QTabWidget;
11class QHBoxLayout; 11class QHBoxLayout;
12class ProfileEditorDialog : public QDialog { 12class QLineEdit;
13class QComboBox;
14class QLabel;
15
16class ProfileEditorDialog : public QTabDialog {
13 Q_OBJECT 17 Q_OBJECT
14public: 18public:
15 ProfileEditorDialog(MetaFactory* fact, 19 ProfileEditorDialog(MetaFactory* fact,
16 const Profile& prof ); 20 const Profile& prof );
17 ProfileEditorDialog(MetaFactory* fact ); 21 ProfileEditorDialog(MetaFactory* fact );
22 ~ProfileEditorDialog();
18 Profile profile()const; 23 Profile profile()const;
24
25 QString prof_name();
26 QString prof_type();
27
28 QString conn_device();
29 int conn_baud();
30 int conn_parity();
31 int conn_databits();
32 int conn_stopbits();
33 int conn_flow();
34
35 QString term_type();
36
37public slots:
38 void slotOk();
39 void slotCancel();
40
41 void slotDevice(int id);
42
19private: 43private:
20 void initUI(); 44 //void initUI();
21 MetaFactory* m_fact; 45 MetaFactory* m_fact;
22 EditBase* m_base; 46 EditBase* m_base;
23 QTabWidget* m_tab; 47 QTabWidget* m_tab;
24 QHBoxLayout* m_lay; 48 QHBoxLayout* m_lay;
25 Profile m_prof; 49 Profile m_prof;
50
51 QLabel *frame_number;
52 QLineEdit *name_line, *frame_device_line, *frame_number_line;
53 QComboBox *terminal_box, *speed_box, *device_box;
26}; 54};
27 55
28#endif 56#endif