author | josef <josef> | 2002-10-06 18:34:28 (UTC) |
---|---|---|
committer | josef <josef> | 2002-10-06 18:34:28 (UTC) |
commit | aa8332baeebf7056d81fc245399477c7feaa1235 (patch) (unidiff) | |
tree | 4b23429bcad955d02df24b40144cf5b7b6ffe0f3 | |
parent | 6da8cac26f1d610d458c91bc2daad018cf9cf887 (diff) | |
download | opie-aa8332baeebf7056d81fc245399477c7feaa1235.zip opie-aa8332baeebf7056d81fc245399477c7feaa1235.tar.gz opie-aa8332baeebf7056d81fc245399477c7feaa1235.tar.bz2 |
- more factorization (is nearly complete now ;)
- move config plugins into separate file (3 classes and virtual superclass)
- first stub for save function
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/opie-console.pro | 2 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 81 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.h | 4 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditorplugins.cpp | 164 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditorplugins.h | 37 |
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 | |||
@@ -1,76 +1,76 @@ | |||
1 | #include <qpe/config.h> | 1 | #include <qpe/config.h> |
2 | #include "metafactory.h" | 2 | #include "metafactory.h" |
3 | 3 | ||
4 | MetaFactory::MetaFactory() { | 4 | MetaFactory::MetaFactory() { |
5 | } | 5 | } |
6 | MetaFactory::~MetaFactory() { | 6 | MetaFactory::~MetaFactory() { |
7 | 7 | ||
8 | } | 8 | } |
9 | void MetaFactory::addConfigWidgetFactory( const QString& str, | 9 | void MetaFactory::addConfigWidgetFactory( const QString& str, |
10 | const QString& name, | 10 | const QString& name, |
11 | configWidget wid) { | 11 | configWidget wid) { |
12 | m_namemap.insert ( str, name ); | 12 | m_namemap.insert ( str, name ); |
13 | m_confFact.insert( str, wid ); | 13 | m_confFact.insert( str, wid ); |
14 | } | 14 | } |
15 | void MetaFactory::addIOLayerFactory( const QString& str, | 15 | void MetaFactory::addIOLayerFactory( const QString& str, |
16 | iolayer lay) { | 16 | iolayer lay) { |
17 | m_layerFact.insert( str, lay ); | 17 | m_layerFact.insert( str, lay ); |
18 | } | 18 | } |
19 | void MetaFactory::addFileTransferLayer( const QString& str, | 19 | void MetaFactory::addFileTransferLayer( const QString& str, |
20 | filelayer lay) { | 20 | filelayer lay) { |
21 | m_fileFact.insert( str, lay ); | 21 | m_fileFact.insert( str, lay ); |
22 | } | 22 | } |
23 | QStringList MetaFactory::ioLayers()const { | 23 | QStringList MetaFactory::ioLayers()const { |
24 | QStringList list; | 24 | QStringList list; |
25 | QMap<QString, iolayer>::ConstIterator it; | 25 | QMap<QString, iolayer>::ConstIterator it; |
26 | for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { | 26 | for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { |
27 | list << it.key(); | 27 | list << it.key(); |
28 | } | 28 | } |
29 | return list; | 29 | return list; |
30 | } | 30 | } |
31 | QStringList MetaFactory::configWidgets()const { | 31 | QStringList MetaFactory::configWidgets()const { |
32 | QStringList list; | 32 | QStringList list; |
33 | QMap<QString, configWidget>::ConstIterator it; | 33 | QMap<QString, configWidget>::ConstIterator it; |
34 | for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) { | 34 | for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) { |
35 | list << it.key(); | 35 | list << it.key(); |
36 | } | 36 | } |
37 | return list; | 37 | return list; |
38 | } | 38 | } |
39 | QStringList MetaFactory::fileTransferLayers()const { | 39 | QStringList MetaFactory::fileTransferLayers()const { |
40 | QStringList list; | 40 | QStringList list; |
41 | QMap<QString, filelayer>::ConstIterator it; | 41 | QMap<QString, filelayer>::ConstIterator it; |
42 | for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { | 42 | for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { |
43 | list << it.key(); | 43 | list << it.key(); |
44 | } | 44 | } |
45 | return list; | 45 | return list; |
46 | } | 46 | } |
47 | 47 | ||
48 | IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { | 48 | IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { |
49 | IOLayer* lay = 0l; | 49 | IOLayer* lay = 0l; |
50 | 50 | ||
51 | QMap<QString, iolayer>::Iterator it; | 51 | QMap<QString, iolayer>::Iterator it; |
52 | it = m_layerFact.find( str ); | 52 | it = m_layerFact.find( str ); |
53 | if ( it != m_layerFact.end() ) { | 53 | if ( it != m_layerFact.end() ) { |
54 | lay = (*(it.data()))(prof); | 54 | lay = (*(it.data()))(prof); |
55 | /* | 55 | /* |
56 | iolayer laye = it.data(); | 56 | iolayer laye = it.data(); |
57 | lay = (*laye )(conf);*/ | 57 | lay = (*laye )(conf);*/ |
58 | } | 58 | } |
59 | 59 | ||
60 | return lay; | 60 | return lay; |
61 | } | 61 | } |
62 | 62 | ||
63 | QWidget *MetaFactory::newConfigWidget ( const QString& str, QWidget* parent) { | 63 | ProfileEditorPlugin *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 | ||
73 | QString MetaFactory::name( const QString& str ) { | 73 | QString 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 | |||
@@ -1,50 +1,51 @@ | |||
1 | #ifndef OPIE_META_FACTORY_H | 1 | #ifndef OPIE_META_FACTORY_H |
2 | #define OPIE_META_FACTORY_H | 2 | #define OPIE_META_FACTORY_H |
3 | 3 | ||
4 | /** | 4 | /** |
5 | * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets | 5 | * The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets |
6 | * and to instantiate these implementations on demand | 6 | * and to instantiate these implementations on demand |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <qwidget.h> | 9 | #include <qwidget.h> |
10 | #include <qmap.h> | 10 | #include <qmap.h> |
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 | ||
18 | class MetaFactory { | 19 | class MetaFactory { |
19 | public: | 20 | public: |
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 | ||
27 | void addConfigWidgetFactory( const QString&, | 28 | void addConfigWidgetFactory( const QString&, |
28 | const QString&, | 29 | const QString&, |
29 | configWidget ); | 30 | configWidget ); |
30 | void addIOLayerFactory(const QString&, | 31 | void addIOLayerFactory(const QString&, |
31 | iolayer ); | 32 | iolayer ); |
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 | ||
42 | private: | 43 | private: |
43 | QMap<QString, configWidget> m_confFact; | 44 | QMap<QString, configWidget> m_confFact; |
44 | QMap<QString, iolayer> m_layerFact; | 45 | QMap<QString, iolayer> m_layerFact; |
45 | QMap<QString, filelayer> m_fileFact; | 46 | QMap<QString, filelayer> m_fileFact; |
46 | QMap<QString, QString> m_namemap; | 47 | QMap<QString, QString> m_namemap; |
47 | }; | 48 | }; |
48 | 49 | ||
49 | 50 | ||
50 | #endif | 51 | #endif |
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 | |||
@@ -1,48 +1,50 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | #CONFIG = qt warn_on release | 2 | #CONFIG = qt warn_on release |
3 | CONFIG = qt debug | 3 | CONFIG = qt debug |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = io_layer.h io_serial.h \ | 5 | HEADERS = io_layer.h io_serial.h \ |
6 | file_layer.h \ | 6 | file_layer.h \ |
7 | metafactory.h \ | 7 | metafactory.h \ |
8 | session.h \ | 8 | session.h \ |
9 | mainwindow.h \ | 9 | mainwindow.h \ |
10 | profile.h \ | 10 | profile.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 \ |
23 | keytrans.h | 24 | keytrans.h |
24 | 25 | ||
25 | SOURCES = io_layer.cpp io_serial.cpp \ | 26 | SOURCES = io_layer.cpp io_serial.cpp \ |
26 | file_layer.cpp main.cpp \ | 27 | file_layer.cpp main.cpp \ |
27 | metafactory.cpp \ | 28 | metafactory.cpp \ |
28 | session.cpp \ | 29 | session.cpp \ |
29 | mainwindow.cpp \ | 30 | mainwindow.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 |
42 | 44 | ||
43 | INTERFACES = configurebase.ui editbase.ui | 45 | INTERFACES = configurebase.ui editbase.ui |
44 | INCLUDEPATH += $(OPIEDIR)/include | 46 | INCLUDEPATH += $(OPIEDIR)/include |
45 | DEPENDPATH += $(OPIEDIR)/include | 47 | DEPENDPATH += $(OPIEDIR)/include |
46 | LIBS += -lqpe -lopie | 48 | LIBS += -lqpe -lopie |
47 | TARGET = opie-console | 49 | TARGET = opie-console |
48 | 50 | ||
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 | |||
@@ -1,331 +1,266 @@ | |||
1 | 1 | ||
2 | #include "profileeditordialog.h" | 2 | #include "profileeditordialog.h" |
3 | 3 | ||
4 | #include "qlayout.h" | 4 | #include "qlayout.h" |
5 | #include "qlineedit.h" | 5 | #include "qlineedit.h" |
6 | #include "qlabel.h" | 6 | #include "qlabel.h" |
7 | #include "qradiobutton.h" | 7 | #include "qradiobutton.h" |
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 | ||
16 | static 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 | |||
32 | static 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 | |||
48 | static 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 | |||
80 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 17 | ProfileEditorDialog::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 | ||
86 | // Apply current profile | 23 | // Apply current profile |
87 | // plugin_plugin->load(profile); | 24 | // plugin_plugin->load(profile); |
88 | // ... (reset profile name line edit etc.) | 25 | // ... (reset profile name line edit etc.) |
89 | } | 26 | } |
90 | 27 | ||
91 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | 28 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) |
92 | : QTabDialog(0, 0, TRUE), m_fact( fact ) | 29 | : QTabDialog(0, 0, TRUE), m_fact( fact ) |
93 | { | 30 | { |
94 | // Default profile | 31 | // Default profile |
95 | m_prof = Profile("serial", QString::null, Profile::Black, Profile::White, Profile::VT102); | 32 | m_prof = Profile("serial", QString::null, Profile::Black, Profile::White, Profile::VT102); |
96 | 33 | ||
97 | initUI(); | 34 | initUI(); |
98 | 35 | ||
99 | // Apply current profile | 36 | // Apply current profile |
100 | // plugin_plugin->load(profile); | 37 | // plugin_plugin->load(profile); |
101 | } | 38 | } |
102 | 39 | ||
103 | Profile ProfileEditorDialog::profile() const | 40 | Profile ProfileEditorDialog::profile() const |
104 | { | 41 | { |
105 | return m_prof; | 42 | return m_prof; |
106 | } | 43 | } |
107 | 44 | ||
108 | void ProfileEditorDialog::initUI() | 45 | void ProfileEditorDialog::initUI() |
109 | { | 46 | { |
110 | QWidget *tabterm, *tabconn, *tabprof; | 47 | QWidget *tabterm, *tabconn, *tabprof; |
111 | 48 | ||
112 | tabprof = new QWidget(this); | 49 | tabprof = new QWidget(this); |
113 | tabterm = new QWidget(this); | 50 | tabterm = new QWidget(this); |
114 | tabconn = new QWidget(this); | 51 | tabconn = new QWidget(this); |
115 | 52 | ||
116 | // for the time being: fake factory | 53 | // for the time being: fake factory |
117 | 54 | ||
118 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); | 55 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); |
119 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); | 56 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); |
120 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); | 57 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); |
121 | 58 | ||
122 | // profile tab | 59 | // profile tab |
123 | 60 | ||
124 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 61 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
125 | 62 | ||
126 | name_line = new QLineEdit(tabprof); | 63 | name_line = new QLineEdit(tabprof); |
127 | 64 | ||
128 | // connection tab, fixed part | 65 | // connection tab, fixed part |
129 | 66 | ||
130 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); | 67 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); |
131 | 68 | ||
132 | device_box = new QComboBox(tabconn); | 69 | device_box = new QComboBox(tabconn); |
133 | 70 | ||
134 | QStringList w = m_fact->configWidgets(); | 71 | QStringList w = m_fact->configWidgets(); |
135 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 72 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
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"); |
150 | speed_box->insertItem("38400 baud"); | 87 | speed_box->insertItem("38400 baud"); |
151 | speed_box->insertItem("19200 baud"); | 88 | speed_box->insertItem("19200 baud"); |
152 | speed_box->insertItem("9600 baud"); | 89 | speed_box->insertItem("9600 baud"); |
153 | 90 | ||
154 | QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn); | 91 | QLabel *speed = new QLabel(QObject::tr("Speed"), tabconn); |
155 | QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn); | 92 | QLabel *flow = new QLabel(QObject::tr("Flow control"), tabconn); |
156 | QLabel *parity = new QLabel(QObject::tr("Parity"), tabconn); | 93 | QLabel *parity = new QLabel(QObject::tr("Parity"), tabconn); |
157 | 94 | ||
158 | QButtonGroup *group_flow = new QButtonGroup(tabconn); | 95 | QButtonGroup *group_flow = new QButtonGroup(tabconn); |
159 | group_flow->hide(); | 96 | group_flow->hide(); |
160 | QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), tabconn); | 97 | QRadioButton *flow_hw = new QRadioButton(QObject::tr("Hardware"), tabconn); |
161 | QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), tabconn); | 98 | QRadioButton *flow_sw = new QRadioButton(QObject::tr("Software"), tabconn); |
162 | group_flow->insert(flow_hw); | 99 | group_flow->insert(flow_hw); |
163 | group_flow->insert(flow_sw); | 100 | group_flow->insert(flow_sw); |
164 | 101 | ||
165 | QButtonGroup *group_parity = new QButtonGroup(tabconn); | 102 | QButtonGroup *group_parity = new QButtonGroup(tabconn); |
166 | group_parity->hide(); | 103 | group_parity->hide(); |
167 | QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), tabconn); | 104 | QRadioButton *parity_odd = new QRadioButton(QObject::tr("Odd"), tabconn); |
168 | QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), tabconn); | 105 | QRadioButton *parity_even = new QRadioButton(QObject::tr("Even"), tabconn); |
169 | group_parity->insert(parity_odd); | 106 | group_parity->insert(parity_odd); |
170 | group_parity->insert(parity_even); | 107 | group_parity->insert(parity_even); |
171 | 108 | ||
172 | flow_sw->setChecked(true); | 109 | flow_sw->setChecked(true); |
173 | parity_odd->setChecked(true); | 110 | parity_odd->setChecked(true); |
174 | 111 | ||
175 | // terminal tab | 112 | // terminal tab |
176 | 113 | ||
177 | terminal_box = new QComboBox(tabterm); | 114 | terminal_box = new QComboBox(tabterm); |
178 | terminal_box->insertItem("VT 100"); | 115 | terminal_box->insertItem("VT 100"); |
179 | terminal_box->insertItem("VT 220"); | 116 | terminal_box->insertItem("VT 220"); |
180 | terminal_box->insertItem("ANSI"); | 117 | terminal_box->insertItem("ANSI"); |
181 | 118 | ||
182 | QLabel *terminal = new QLabel(QObject::tr("Terminal type"), tabterm); | 119 | QLabel *terminal = new QLabel(QObject::tr("Terminal type"), tabterm); |
183 | QLabel *colour = new QLabel(QObject::tr("Colour scheme"), tabterm); | 120 | QLabel *colour = new QLabel(QObject::tr("Colour scheme"), tabterm); |
184 | QLabel *size = new QLabel(QObject::tr("Font size"), tabterm); | 121 | QLabel *size = new QLabel(QObject::tr("Font size"), tabterm); |
185 | QLabel *options = new QLabel(QObject::tr("Options"), tabterm); | 122 | QLabel *options = new QLabel(QObject::tr("Options"), tabterm); |
186 | QLabel *conversions = new QLabel(QObject::tr("Line-break conversions"), tabterm); | 123 | QLabel *conversions = new QLabel(QObject::tr("Line-break conversions"), tabterm); |
187 | 124 | ||
188 | QComboBox *colour_box = new QComboBox(tabterm); | 125 | QComboBox *colour_box = new QComboBox(tabterm); |
189 | colour_box->insertItem(QObject::tr("black on white")); | 126 | colour_box->insertItem(QObject::tr("black on white")); |
190 | colour_box->insertItem(QObject::tr("white on black")); | 127 | colour_box->insertItem(QObject::tr("white on black")); |
191 | 128 | ||
192 | QButtonGroup *group_size = new QButtonGroup(tabterm); | 129 | QButtonGroup *group_size = new QButtonGroup(tabterm); |
193 | group_size->hide(); | 130 | group_size->hide(); |
194 | QRadioButton *size_small = new QRadioButton(QObject::tr("small"), tabterm); | 131 | QRadioButton *size_small = new QRadioButton(QObject::tr("small"), tabterm); |
195 | QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), tabterm); | 132 | QRadioButton *size_medium = new QRadioButton(QObject::tr("medium"), tabterm); |
196 | QRadioButton *size_large = new QRadioButton(QObject::tr("large"), tabterm); | 133 | QRadioButton *size_large = new QRadioButton(QObject::tr("large"), tabterm); |
197 | group_size->insert(size_small); | 134 | group_size->insert(size_small); |
198 | group_size->insert(size_medium); | 135 | group_size->insert(size_medium); |
199 | group_size->insert(size_large); | 136 | group_size->insert(size_large); |
200 | 137 | ||
201 | QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm); | 138 | QCheckBox *option_echo = new QCheckBox(QObject::tr("Local echo"), tabterm); |
202 | QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm); | 139 | QCheckBox *option_wrap = new QCheckBox(QObject::tr("Line wrap"), tabterm); |
203 | 140 | ||
204 | QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), tabterm); | 141 | QCheckBox *conv_inbound = new QCheckBox(QObject::tr("Inbound"), tabterm); |
205 | QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm); | 142 | QCheckBox *conv_outbound = new QCheckBox(QObject::tr("Outbound"), tabterm); |
206 | 143 | ||
207 | size_small->setChecked(true); | 144 | size_small->setChecked(true); |
208 | 145 | ||
209 | // layouting | 146 | // layouting |
210 | 147 | ||
211 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 148 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
212 | vbox3->add(name); | 149 | vbox3->add(name); |
213 | vbox3->add(name_line); | 150 | vbox3->add(name_line); |
214 | vbox3->addStretch(1); | 151 | vbox3->addStretch(1); |
215 | 152 | ||
216 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); | 153 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); |
217 | vbox->add(device); | 154 | vbox->add(device); |
218 | vbox->add(device_box); | 155 | vbox->add(device_box); |
219 | vbox->add(plugin_base); | 156 | vbox->add(plugin_base); |
220 | vbox->add(speed); | 157 | vbox->add(speed); |
221 | vbox->add(speed_box); | 158 | vbox->add(speed_box); |
222 | vbox->add(flow); | 159 | vbox->add(flow); |
223 | QHBoxLayout *hbox = new QHBoxLayout(vbox, 2); | 160 | QHBoxLayout *hbox = new QHBoxLayout(vbox, 2); |
224 | hbox->add(flow_hw); | 161 | hbox->add(flow_hw); |
225 | hbox->add(flow_sw); | 162 | hbox->add(flow_sw); |
226 | //vbox->add(group_flow); | 163 | //vbox->add(group_flow); |
227 | vbox->add(parity); | 164 | vbox->add(parity); |
228 | QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2); | 165 | QHBoxLayout *hbox2 = new QHBoxLayout(vbox, 2); |
229 | hbox2->add(parity_odd); | 166 | hbox2->add(parity_odd); |
230 | hbox2->add(parity_even); | 167 | hbox2->add(parity_even); |
231 | //vbox->add(group_parity); | 168 | //vbox->add(group_parity); |
232 | 169 | ||
233 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); | 170 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); |
234 | vbox2->add(terminal); | 171 | vbox2->add(terminal); |
235 | vbox2->add(terminal_box); | 172 | vbox2->add(terminal_box); |
236 | vbox2->add(size); | 173 | vbox2->add(size); |
237 | QHBoxLayout *hbox3 = new QHBoxLayout(vbox2, 2); | 174 | QHBoxLayout *hbox3 = new QHBoxLayout(vbox2, 2); |
238 | hbox3->add(size_small); | 175 | hbox3->add(size_small); |
239 | hbox3->add(size_medium); | 176 | hbox3->add(size_medium); |
240 | hbox3->add(size_large); | 177 | hbox3->add(size_large); |
241 | //vbox2->add(group_size); | 178 | //vbox2->add(group_size); |
242 | vbox2->add(colour); | 179 | vbox2->add(colour); |
243 | vbox2->add(colour_box); | 180 | vbox2->add(colour_box); |
244 | vbox2->add(conversions); | 181 | vbox2->add(conversions); |
245 | QHBoxLayout *hbox5 = new QHBoxLayout(vbox2, 2); | 182 | QHBoxLayout *hbox5 = new QHBoxLayout(vbox2, 2); |
246 | hbox5->add(conv_inbound); | 183 | hbox5->add(conv_inbound); |
247 | hbox5->add(conv_outbound); | 184 | hbox5->add(conv_outbound); |
248 | vbox2->add(options); | 185 | vbox2->add(options); |
249 | QHBoxLayout *hbox4 = new QHBoxLayout(vbox2, 2); | 186 | QHBoxLayout *hbox4 = new QHBoxLayout(vbox2, 2); |
250 | hbox4->add(option_wrap); | 187 | hbox4->add(option_wrap); |
251 | hbox4->add(option_echo); | 188 | hbox4->add(option_echo); |
252 | 189 | ||
253 | addTab(tabprof, QObject::tr("Profile")); | 190 | addTab(tabprof, QObject::tr("Profile")); |
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 | ||
267 | ProfileEditorDialog::~ProfileEditorDialog() { | 202 | ProfileEditorDialog::~ProfileEditorDialog() { |
268 | 203 | ||
269 | } | 204 | } |
270 | 205 | ||
271 | void ProfileEditorDialog::slotDevice(int id) | 206 | 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 | ||
286 | void ProfileEditorDialog::accept() | 221 | void ProfileEditorDialog::accept() |
287 | { | 222 | { |
288 | if(prof_name().isEmpty()) | 223 | if(prof_name().isEmpty()) |
289 | { | 224 | { |
290 | QMessageBox::information(this, | 225 | QMessageBox::information(this, |
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 | ||
302 | void ProfileEditorDialog::slotCancel() | 237 | void ProfileEditorDialog::slotCancel() |
303 | { | 238 | { |
304 | reject(); | 239 | reject(); |
305 | } | 240 | } |
306 | 241 | ||
307 | QString ProfileEditorDialog::prof_name() | 242 | QString ProfileEditorDialog::prof_name() |
308 | { | 243 | { |
309 | return name_line->text(); | 244 | return name_line->text(); |
310 | } | 245 | } |
311 | 246 | ||
312 | QString ProfileEditorDialog::prof_type() | 247 | QString ProfileEditorDialog::prof_type() |
313 | { | 248 | { |
314 | QStringList w = m_fact->configWidgets(); | 249 | QStringList w = m_fact->configWidgets(); |
315 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 250 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
316 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 251 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
317 | 252 | ||
318 | return QString::null; | 253 | return QString::null; |
319 | } | 254 | } |
320 | 255 | ||
321 | QString ProfileEditorDialog::conn_device() | 256 | QString ProfileEditorDialog::conn_device() |
322 | { | 257 | { |
323 | //return frame_device_line->text(); | 258 | //return frame_device_line->text(); |
324 | return "/dev/ttyS0"; | 259 | return "/dev/ttyS0"; |
325 | } | 260 | } |
326 | 261 | ||
327 | QString ProfileEditorDialog::term_type() | 262 | QString ProfileEditorDialog::term_type() |
328 | { | 263 | { |
329 | return terminal_box->currentText(); | 264 | return terminal_box->currentText(); |
330 | } | 265 | } |
331 | 266 | ||
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 | |||
@@ -1,56 +1,58 @@ | |||
1 | #ifndef PROFILE_EDITOR_DIALOG | 1 | #ifndef PROFILE_EDITOR_DIALOG |
2 | #define PROFILE_EDITOR_DIALOG | 2 | #define PROFILE_EDITOR_DIALOG |
3 | 3 | ||
4 | #include <qtabdialog.h> | 4 | #include <qtabdialog.h> |
5 | 5 | ||
6 | #include "profile.h" | 6 | #include "profile.h" |
7 | 7 | ||
8 | class MetaFactory; | 8 | class MetaFactory; |
9 | class EditBase; | 9 | class EditBase; |
10 | class QTabWidget; | 10 | class QTabWidget; |
11 | class QHBoxLayout; | 11 | class QHBoxLayout; |
12 | class QLineEdit; | 12 | class QLineEdit; |
13 | class QComboBox; | 13 | class QComboBox; |
14 | class QLabel; | 14 | class QLabel; |
15 | class ProfileEditorPlugin; | ||
15 | 16 | ||
16 | class ProfileEditorDialog : public QTabDialog { | 17 | class ProfileEditorDialog : public QTabDialog { |
17 | Q_OBJECT | 18 | Q_OBJECT |
18 | public: | 19 | public: |
19 | ProfileEditorDialog(MetaFactory* fact, | 20 | ProfileEditorDialog(MetaFactory* fact, |
20 | const Profile& prof ); | 21 | const Profile& prof ); |
21 | ProfileEditorDialog(MetaFactory* fact ); | 22 | ProfileEditorDialog(MetaFactory* fact ); |
22 | ~ProfileEditorDialog(); | 23 | ~ProfileEditorDialog(); |
23 | Profile profile()const; | 24 | Profile profile()const; |
24 | 25 | ||
25 | QString prof_name(); | 26 | QString prof_name(); |
26 | QString prof_type(); | 27 | QString prof_type(); |
27 | 28 | ||
28 | QString conn_device(); | 29 | QString conn_device(); |
29 | 30 | ||
30 | QString term_type(); | 31 | QString term_type(); |
31 | 32 | ||
32 | public slots: | 33 | public slots: |
33 | void accept(); | 34 | void accept(); |
34 | //void slotOk(); | 35 | //void slotOk(); |
35 | void slotCancel(); | 36 | void slotCancel(); |
36 | 37 | ||
37 | void slotDevice(int id); | 38 | void slotDevice(int id); |
38 | 39 | ||
39 | private: | 40 | private: |
40 | void initUI(); | 41 | void initUI(); |
41 | 42 | ||
42 | MetaFactory* m_fact; | 43 | MetaFactory* m_fact; |
43 | EditBase* m_base; | 44 | EditBase* m_base; |
44 | QTabWidget* m_tab; | 45 | QTabWidget* m_tab; |
45 | QHBoxLayout* m_lay; | 46 | QHBoxLayout* m_lay; |
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 | |||
10 | ProfileEditorPlugin::ProfileEditorPlugin(QWidget *parent, Profile p) | ||
11 | { | ||
12 | m_parent = parent; | ||
13 | m_profile = p; | ||
14 | m_widget = NULL; | ||
15 | } | ||
16 | |||
17 | ProfileEditorPlugin::~ProfileEditorPlugin() | ||
18 | { | ||
19 | if(m_widget) delete m_widget; | ||
20 | } | ||
21 | |||
22 | class 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 | |||
61 | class 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 | |||
100 | class 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 | |||
150 | ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p) | ||
151 | { | ||
152 | return new ProfileEditorPluginSerial(parent, p); | ||
153 | } | ||
154 | |||
155 | ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p) | ||
156 | { | ||
157 | return new ProfileEditorPluginIrda(parent, p); | ||
158 | } | ||
159 | |||
160 | ProfileEditorPlugin *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 | |||
6 | class QWidget; | ||
7 | |||
8 | class 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 | |||
28 | ProfileEditorPlugin *factory_serial(QWidget *parent, const Profile& p); | ||
29 | ProfileEditorPlugin *factory_irda(QWidget *parent, const Profile& p); | ||
30 | ProfileEditorPlugin *factory_modem(QWidget *parent, const Profile& p); | ||
31 | |||
32 | //#ifdef __cplusplus | ||
33 | //} | ||
34 | //#endif | ||
35 | |||
36 | #endif | ||
37 | |||