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
@@ -60,14 +60,14 @@ IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
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 ) {
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
@@ -14,10 +14,11 @@
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
@@ -35,7 +36,7 @@ public:
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
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
@@ -14,6 +14,7 @@ HEADERS = io_layer.h io_serial.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 \
@@ -33,6 +34,7 @@ SOURCES = io_layer.cpp io_serial.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 \
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
@@ -11,72 +11,9 @@
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 )
@@ -139,8 +76,8 @@ void ProfileEditorDialog::initUI()
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
@@ -257,8 +194,6 @@ void ProfileEditorDialog::initUI()
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)));
@@ -272,15 +207,15 @@ void 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()
@@ -294,7 +229,7 @@ void ProfileEditorDialog::accept()
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}
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
@@ -12,6 +12,7 @@ class 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
@@ -49,7 +50,8 @@ private:
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
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