summaryrefslogtreecommitdiff
path: root/noncore/apps
Unidiff
Diffstat (limited to 'noncore/apps') (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
@@ -62,4 +62,4 @@ IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
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;
@@ -67,5 +67,5 @@ QWidget *MetaFactory::newConfigWidget ( const QString& str, QWidget* parent) {
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}
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
@@ -16,2 +16,3 @@
16#include "profile.h" 16#include "profile.h"
17#include "profileeditorplugins.h"
17 18
@@ -19,3 +20,3 @@ class 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& );
@@ -37,3 +38,3 @@ public:
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
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
@@ -16,2 +16,3 @@ HEADERS = io_layer.h io_serial.h \
16 profileeditordialog.h \ 16 profileeditordialog.h \
17 profileeditorplugins.h \
17 emulation_layer.h \ 18 emulation_layer.h \
@@ -35,2 +36,3 @@ SOURCES = io_layer.cpp io_serial.cpp \
35 profileeditordialog.cpp \ 36 profileeditordialog.cpp \
37 profileeditorplugins.cpp \
36 emulation_layer.cpp \ 38 emulation_layer.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
@@ -13,68 +13,5 @@
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,
@@ -141,4 +78,4 @@ void ProfileEditorDialog::initUI()
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
@@ -259,4 +196,2 @@ void ProfileEditorDialog::initUI()
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()));
@@ -274,4 +209,4 @@ void ProfileEditorDialog::slotDevice(int id)
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
@@ -281,4 +216,4 @@ void ProfileEditorDialog::slotDevice(int id)
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}
@@ -296,3 +231,3 @@ void ProfileEditorDialog::accept()
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
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
@@ -14,2 +14,3 @@ class QComboBox;
14class QLabel; 14class QLabel;
15class ProfileEditorPlugin;
15 16
@@ -51,3 +52,4 @@ private:
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;
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