summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/metafactory.cpp8
-rw-r--r--noncore/apps/opie-console/metafactory.h5
-rw-r--r--noncore/apps/opie-console/opie-console.pro2
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp81
-rw-r--r--noncore/apps/opie-console/profileeditordialog.h4
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.cpp164
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.h37
7 files changed, 221 insertions, 80 deletions
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp
index ea7f739..c5e614d 100644
--- a/noncore/apps/opie-console/metafactory.cpp
+++ b/noncore/apps/opie-console/metafactory.cpp
@@ -57,20 +57,20 @@ IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
57 lay = (*laye )(conf);*/ 57 lay = (*laye )(conf);*/
58 } 58 }
59 59
60 return lay; 60 return lay;
61} 61}
62 62
63QWidget *MetaFactory::newConfigWidget ( const QString& str, QWidget* parent) { 63ProfileEditorPlugin *MetaFactory::newConfigPlugin ( const QString& str, QWidget *parent, const Profile& prof) {
64 QWidget *w = NULL; 64 ProfileEditorPlugin *p = NULL;
65 configWidget c; 65 configWidget c;
66 66
67 c = m_confFact[str]; 67 c = m_confFact[str];
68 if(c) w = c(parent); 68 if(c) p = c(parent, prof);
69 69
70 return w; 70 return p;
71} 71}
72 72
73QString MetaFactory::name( const QString& str ) { 73QString MetaFactory::name( const QString& str ) {
74 return m_namemap[str]; 74 return m_namemap[str];
75} 75}
76 76
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h
index 2245231..8c714b3 100644
--- a/noncore/apps/opie-console/metafactory.h
+++ b/noncore/apps/opie-console/metafactory.h
@@ -11,16 +11,17 @@
11 11
12#include <qpe/config.h> 12#include <qpe/config.h>
13 13
14#include "io_layer.h" 14#include "io_layer.h"
15#include "file_layer.h" 15#include "file_layer.h"
16#include "profile.h" 16#include "profile.h"
17#include "profileeditorplugins.h"
17 18
18class MetaFactory { 19class MetaFactory {
19public: 20public:
20 typedef QWidget* (*configWidget)(QWidget* parent); 21 typedef ProfileEditorPlugin* (*configWidget)(QWidget* parent, const Profile&);
21 typedef IOLayer* (*iolayer)(const Profile& ); 22 typedef IOLayer* (*iolayer)(const Profile& );
22 typedef FileTransferLayer* (*filelayer)(IOLayer*); 23 typedef FileTransferLayer* (*filelayer)(IOLayer*);
23 24
24 MetaFactory(); 25 MetaFactory();
25 ~MetaFactory(); 26 ~MetaFactory();
26 27
@@ -32,13 +33,13 @@ public:
32 void addFileTransferLayer( const QString&, 33 void addFileTransferLayer( const QString&,
33 filelayer ); 34 filelayer );
34 QStringList ioLayers()const; 35 QStringList ioLayers()const;
35 QStringList configWidgets()const; 36 QStringList configWidgets()const;
36 QStringList fileTransferLayers()const; 37 QStringList fileTransferLayers()const;
37 IOLayer* newIOLayer( const QString&,const Profile& ); 38 IOLayer* newIOLayer( const QString&,const Profile& );
38 QWidget *newConfigWidget ( const QString&, QWidget* ); 39 ProfileEditorPlugin *newConfigPlugin ( const QString&, QWidget*, const Profile& );
39 40
40 QString name( const QString& ); 41 QString name( const QString& );
41 42
42private: 43private:
43 QMap<QString, configWidget> m_confFact; 44 QMap<QString, configWidget> m_confFact;
44 QMap<QString, iolayer> m_layerFact; 45 QMap<QString, iolayer> m_layerFact;
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro
index 7abf385..831ca34 100644
--- a/noncore/apps/opie-console/opie-console.pro
+++ b/noncore/apps/opie-console/opie-console.pro
@@ -11,12 +11,13 @@ HEADERS = io_layer.h io_serial.h \
11 profileconfig.h \ 11 profileconfig.h \
12 profilemanager.h \ 12 profilemanager.h \
13 configwidget.h \ 13 configwidget.h \
14 tabwidget.h \ 14 tabwidget.h \
15 configdialog.h \ 15 configdialog.h \
16 profileeditordialog.h \ 16 profileeditordialog.h \
17 profileeditorplugins.h \
17 emulation_layer.h \ 18 emulation_layer.h \
18 widget.h \ 19 widget.h \
19 vt102emulation.h \ 20 vt102emulation.h \
20 common.h \ 21 common.h \
21 history.h \ 22 history.h \
22 screen.h \ 23 screen.h \
@@ -30,12 +31,13 @@ SOURCES = io_layer.cpp io_serial.cpp \
30 profile.cpp \ 31 profile.cpp \
31 profileconfig.cpp \ 32 profileconfig.cpp \
32 profilemanager.cpp \ 33 profilemanager.cpp \
33 tabwidget.cpp \ 34 tabwidget.cpp \
34 configdialog.cpp \ 35 configdialog.cpp \
35 profileeditordialog.cpp \ 36 profileeditordialog.cpp \
37 profileeditorplugins.cpp \
36 emulation_layer.cpp \ 38 emulation_layer.cpp \
37 widget.cpp \ 39 widget.cpp \
38 vt102emulation.cpp \ 40 vt102emulation.cpp \
39 history.cpp \ 41 history.cpp \
40 screen.cpp \ 42 screen.cpp \
41 keytrans.cpp 43 keytrans.cpp
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
@@ -8,78 +8,15 @@
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
@@ -136,14 +73,14 @@ void ProfileEditorDialog::initUI()
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");
@@ -254,14 +191,12 @@ void ProfileEditorDialog::initUI()
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() {
@@ -269,21 +204,21 @@ ProfileEditorDialog::~ProfileEditorDialog() {
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 {
@@ -291,13 +226,13 @@ void ProfileEditorDialog::accept()
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{
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h
index 8ebfba1..faabda0 100644
--- a/noncore/apps/opie-console/profileeditordialog.h
+++ b/noncore/apps/opie-console/profileeditordialog.h
@@ -9,12 +9,13 @@ class MetaFactory;
9class EditBase; 9class EditBase;
10class QTabWidget; 10class QTabWidget;
11class QHBoxLayout; 11class QHBoxLayout;
12class QLineEdit; 12class QLineEdit;
13class QComboBox; 13class QComboBox;
14class QLabel; 14class QLabel;
15class ProfileEditorPlugin;
15 16
16class ProfileEditorDialog : public QTabDialog { 17class ProfileEditorDialog : public QTabDialog {
17 Q_OBJECT 18 Q_OBJECT
18public: 19public:
19 ProfileEditorDialog(MetaFactory* fact, 20 ProfileEditorDialog(MetaFactory* fact,
20 const Profile& prof ); 21 const Profile& prof );
@@ -46,11 +47,12 @@ private:
46 Profile m_prof; 47 Profile m_prof;
47 48
48 //QLabel *frame_number; 49 //QLabel *frame_number;
49 QLineEdit *name_line; 50 QLineEdit *name_line;
50 //QLineEdit *frame_device_line, *frame_number_line; 51 //QLineEdit *frame_device_line, *frame_number_line;
51 QComboBox *terminal_box, *speed_box, *device_box; 52 QComboBox *terminal_box, *speed_box, *device_box;
52 QWidget *plugin_base, *plugin_plugin; 53 QWidget *plugin_base;
54 ProfileEditorPlugin *plugin_plugin;
53 QHBoxLayout *plugin_layout; 55 QHBoxLayout *plugin_layout;
54}; 56};
55 57
56#endif 58#endif
diff --git a/noncore/apps/opie-console/profileeditorplugins.cpp b/noncore/apps/opie-console/profileeditorplugins.cpp
new file mode 100644
index 0000000..54eee3f
--- a/dev/null
+++ b/noncore/apps/opie-console/profileeditorplugins.cpp
@@ -0,0 +1,164 @@
1
2#include "profileeditorplugins.h"
3#include "profile.h"
4
5#include "qframe.h"
6#include "qlabel.h"
7#include "qlineedit.h"
8#include "qlayout.h"
9
10ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile p)
11{
12 m_parent = parent;
13 m_profile = p;
14 m_widget = NULL;
15}
16
17ProfileEditorPlugin::~ProfileEditorPlugin()
18{
19 if(m_widget) delete m_widget;
20}
21
22class ProfileEditorPluginSerial : public ProfileEditorPlugin
23{
24 public:
25
26 ProfileEditorPluginSerial(QWidget *parent, Profile p)
27 : ProfileEditorPlugin(parent, p)
28 {
29 }
30
31 ~ProfileEditorPluginSerial()
32 {
33 }
34
35 QWidget *widget()
36 {
37 if(!m_widget)
38 {
39 QFrame *device_frame = new QFrame(m_parent);
40 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
41
42 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
43
44 QLineEdit *frame_device_line = new QLineEdit("/dev/ttyS0", device_frame);
45
46 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
47 vbox_frame->add(frame_device);
48 vbox_frame->add(frame_device_line);
49
50 m_widget = device_frame;
51 }
52
53 return m_widget;
54 }
55
56 void save()
57 {
58 }
59};
60
61class ProfileEditorPluginIrda : public ProfileEditorPlugin
62{
63 public:
64
65 ProfileEditorPluginIrda(QWidget *parent, Profile p)
66 : ProfileEditorPlugin(parent, p)
67 {
68 }
69
70 ~ProfileEditorPluginIrda()
71 {
72 }
73
74 QWidget *widget()
75 {
76 if(!m_widget)
77 {
78 QFrame *device_frame = new QFrame(m_parent);
79 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
80
81 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
82
83 QLineEdit *frame_device_line = new QLineEdit("/dev/ircomm0", device_frame);
84
85 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
86 vbox_frame->add(frame_device);
87 vbox_frame->add(frame_device_line);
88
89 m_widget = device_frame;
90 }
91
92 return m_widget;
93 }
94
95 void save()
96 {
97 }
98};
99
100class ProfileEditorPluginModem : public ProfileEditorPlugin
101{
102 public:
103
104 ProfileEditorPluginModem(QWidget *parent, Profile p)
105 : ProfileEditorPlugin(parent, p)
106 {
107 }
108
109 ~ProfileEditorPluginModem()
110 {
111 }
112
113 QWidget *widget()
114 {
115 if(!m_widget)
116 {
117 QFrame *device_frame = new QFrame(m_parent);
118 device_frame->setFrameStyle(QFrame::Panel | QFrame::Sunken);
119
120 QLabel *frame_device = new QLabel(QObject::tr("Device"), device_frame);
121 QLabel *frame_number = new QLabel(QObject::tr("Phone number"), device_frame);
122
123 device_line = new QLineEdit("/dev/ttyS0", device_frame);
124 number_line = new QLineEdit(device_frame);
125
126 QVBoxLayout *vbox_frame = new QVBoxLayout(device_frame, 2);
127 vbox_frame->add(frame_device);
128 vbox_frame->add(device_line);
129 vbox_frame->add(frame_number);
130 vbox_frame->add(number_line);
131
132 m_widget = device_frame;
133 }
134
135 return m_widget;
136 }
137
138 void save()
139 {
140 // special settings
141 Profile p = m_profile;
142 p.writeEntry("Device", device_line->text());
143 p.writeEntry("Number", number_line->text());
144 }
145
146 private:
147 QLineEdit *device_line, *number_line;
148};
149
150ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p)
151{
152 return new ProfileEditorPluginSerial(parent, p);
153}
154
155ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p)
156{
157 return new ProfileEditorPluginIrda(parent, p);
158}
159
160ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p)
161{
162 return new ProfileEditorPluginModem(parent, p);
163}
164
diff --git a/noncore/apps/opie-console/profileeditorplugins.h b/noncore/apps/opie-console/profileeditorplugins.h
new file mode 100644
index 0000000..7e0219b
--- a/dev/null
+++ b/noncore/apps/opie-console/profileeditorplugins.h
@@ -0,0 +1,37 @@
1#ifndef PROFILE_EDITOR_PLUGINS_H
2#define PROFILE_EDITOR_PLUGINS_H
3
4#include "profile.h"
5
6class QWidget;
7
8class ProfileEditorPlugin
9{
10 public:
11 ProfileEditorPlugin(QWidget *parent, Profile p);
12
13 virtual ~ProfileEditorPlugin();
14
15 virtual void save() = 0;
16
17 virtual QWidget *widget() = 0;
18
19 protected:
20 QWidget *m_parent, *m_widget;
21 Profile m_profile;
22};
23
24//#ifdef __cplusplus
25//extern "C" {
26//#endif
27
28ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p);
29ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p);
30ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p);
31
32//#ifdef __cplusplus
33//}
34//#endif
35
36#endif
37