20 files changed, 452 insertions, 174 deletions
diff --git a/noncore/apps/opie-console/common.h b/noncore/apps/opie-console/common.h index ac0e2cf..979c2bd 100644 --- a/noncore/apps/opie-console/common.h +++ b/noncore/apps/opie-console/common.h | |||
@@ -5,49 +5,49 @@ | |||
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | /* */ | 6 | /* */ |
7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ | 7 | /* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */ |
8 | /* */ | 8 | /* */ |
9 | /* This file is part of Konsole - an X terminal for KDE */ | 9 | /* This file is part of Konsole - an X terminal for KDE */ |
10 | /* */ | 10 | /* */ |
11 | /* -------------------------------------------------------------------------- */ | 11 | /* -------------------------------------------------------------------------- */ |
12 | /* */ | 12 | /* */ |
13 | /* Ported Konsole to Qt/Embedded */ | 13 | /* Ported Konsole to Qt/Embedded */ |
14 | /* */ | 14 | /* */ |
15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ | 15 | /* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */ |
16 | /* */ | 16 | /* */ |
17 | /* -------------------------------------------------------------------------- */ | 17 | /* -------------------------------------------------------------------------- */ |
18 | 18 | ||
19 | /*! \file TECommon.h | 19 | /*! \file TECommon.h |
20 | \brief Definitions shared between TEScreen and TEWidget. | 20 | \brief Definitions shared between TEScreen and TEWidget. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #ifndef TECOMMON_H | 23 | #ifndef TECOMMON_H |
24 | #define TECOMMON_H | 24 | #define TECOMMON_H |
25 | 25 | ||
26 | #include <qcolor.h> | 26 | #include <qcolor.h> |
27 | 27 | ||
28 | #ifndef BOOL | 28 | #ifndef BOOL |
29 | typedef int BOOL; | 29 | typedef bool BOOL; |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #ifndef FALSE | 32 | #ifndef FALSE |
33 | #define FALSE 0 | 33 | #define FALSE 0 |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #ifndef TRUE | 36 | #ifndef TRUE |
37 | #define TRUE 1 | 37 | #define TRUE 1 |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #ifndef UINT8 | 40 | #ifndef UINT8 |
41 | typedef unsigned char UINT8; | 41 | typedef unsigned char UINT8; |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #ifndef UINT16 | 44 | #ifndef UINT16 |
45 | typedef unsigned short UINT16; | 45 | typedef unsigned short UINT16; |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | // Attributed Character Representations /////////////////////////////// | 48 | // Attributed Character Representations /////////////////////////////// |
49 | 49 | ||
50 | // Colors | 50 | // Colors |
51 | 51 | ||
52 | #define BASE_COLORS (2+8) | 52 | #define BASE_COLORS (2+8) |
53 | #define INTENSITIES 2 | 53 | #define INTENSITIES 2 |
diff --git a/noncore/apps/opie-console/configdialog.cpp b/noncore/apps/opie-console/configdialog.cpp index ee1ffb4..50512b6 100644 --- a/noncore/apps/opie-console/configdialog.cpp +++ b/noncore/apps/opie-console/configdialog.cpp | |||
@@ -8,105 +8,107 @@ | |||
8 | 8 | ||
9 | class ConfigListItem : public QListViewItem { | 9 | class ConfigListItem : public QListViewItem { |
10 | public: | 10 | public: |
11 | ConfigListItem( QListView* item, const Profile& ); | 11 | ConfigListItem( QListView* item, const Profile& ); |
12 | ~ConfigListItem(); | 12 | ~ConfigListItem(); |
13 | Profile profile()const; | 13 | Profile profile()const; |
14 | 14 | ||
15 | private: | 15 | private: |
16 | Profile m_prof; | 16 | Profile m_prof; |
17 | }; | 17 | }; |
18 | ConfigListItem::ConfigListItem( QListView* item, const Profile& prof ) | 18 | ConfigListItem::ConfigListItem( QListView* item, const Profile& prof ) |
19 | : QListViewItem( item ), m_prof( prof ) | 19 | : QListViewItem( item ), m_prof( prof ) |
20 | { | 20 | { |
21 | setText(0, prof.name() ); | 21 | setText(0, prof.name() ); |
22 | } | 22 | } |
23 | ConfigListItem::~ConfigListItem() { | 23 | ConfigListItem::~ConfigListItem() { |
24 | 24 | ||
25 | } | 25 | } |
26 | Profile ConfigListItem::profile()const { | 26 | Profile ConfigListItem::profile()const { |
27 | return m_prof; | 27 | return m_prof; |
28 | } | 28 | } |
29 | 29 | ||
30 | /* Dialog */ | 30 | /* Dialog */ |
31 | 31 | ||
32 | ConfigDialog::ConfigDialog( const Profile::ValueList& lis, QWidget* parent ) | 32 | ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa, |
33 | : ConfigureBase( parent, 0, TRUE ) | 33 | QWidget* parent ) |
34 | : ConfigureBase( parent, 0, TRUE ), m_fact( fa ) | ||
34 | { | 35 | { |
35 | //init(); | 36 | //init(); |
36 | { | 37 | { |
37 | Profile::ValueList::ConstIterator it; | 38 | Profile::ValueList::ConstIterator it; |
38 | for (it = lis.begin(); it != lis.end(); ++it ) { | 39 | for (it = lis.begin(); it != lis.end(); ++it ) { |
39 | new ConfigListItem( lstView, (*it) ); | 40 | new ConfigListItem( lstView, (*it) ); |
40 | } | 41 | } |
41 | } | 42 | } |
42 | } | 43 | } |
43 | ConfigDialog::~ConfigDialog() { | 44 | ConfigDialog::~ConfigDialog() { |
44 | 45 | ||
45 | } | 46 | } |
46 | Profile::ValueList ConfigDialog::list()const { | 47 | Profile::ValueList ConfigDialog::list()const { |
47 | /* iterate over the list */ | 48 | /* iterate over the list */ |
48 | Profile::ValueList lst; | 49 | Profile::ValueList lst; |
49 | QListViewItemIterator it(lstView); | 50 | QListViewItemIterator it(lstView); |
50 | for ( ; it.current(); ++it ) { | 51 | for ( ; it.current(); ++it ) { |
51 | ConfigListItem* item = (ConfigListItem*)it.current(); | 52 | ConfigListItem* item = (ConfigListItem*)it.current(); |
52 | lst.append( item->profile() ); | 53 | lst.append( item->profile() ); |
53 | } | 54 | } |
54 | return lst; | 55 | return lst; |
55 | } | 56 | } |
56 | /* our slots */ | 57 | /* our slots */ |
57 | void ConfigDialog::slotRemove() { | 58 | void ConfigDialog::slotRemove() { |
58 | ConfigListItem* item = (ConfigListItem*)lstView->currentItem(); | 59 | ConfigListItem* item = (ConfigListItem*)lstView->currentItem(); |
59 | if (!item ) | 60 | if (!item ) |
60 | return; | 61 | return; |
61 | 62 | ||
62 | lstView->takeItem( item ); | 63 | lstView->takeItem( item ); |
63 | delete item; | 64 | delete item; |
64 | } | 65 | } |
65 | 66 | ||
66 | void ConfigDialog::slotEdit() { | 67 | void ConfigDialog::slotEdit() { |
67 | Profile p; | 68 | Profile p; |
68 | 69 | ||
69 | if(!lstView->currentItem()) return; | 70 | if(!lstView->currentItem()) return; |
70 | 71 | ||
71 | // Load profile | 72 | // Load profile |
72 | p = ((ConfigListItem*)lstView->currentItem())->profile(); | 73 | p = ((ConfigListItem*)lstView->currentItem())->profile(); |
73 | 74 | ||
74 | ProfileEditorDialog dlg(new MetaFactory(), p); | 75 | ProfileEditorDialog dlg(m_fact, p); |
75 | 76 | ||
76 | dlg.setCaption("Edit Connection Profile"); | 77 | dlg.setCaption("Edit Connection Profile"); |
77 | dlg.showMaximized(); | 78 | dlg.showMaximized(); |
78 | int ret = dlg.exec(); | 79 | int ret = dlg.exec(); |
79 | 80 | ||
80 | if(ret == QDialog::Accepted) | 81 | if(ret == QDialog::Accepted) |
81 | { | 82 | { |
82 | if(lstView->currentItem()) delete lstView->currentItem(); | 83 | if(lstView->currentItem()) delete lstView->currentItem(); |
83 | 84 | ||
84 | // use dlg.terminal()! | 85 | // use dlg.terminal()! |
85 | Profile p = dlg.profile(); | 86 | Profile p = dlg.profile(); |
86 | 87 | ||
87 | new ConfigListItem(lstView, p); | 88 | new ConfigListItem(lstView, p); |
88 | } | 89 | } |
89 | } | 90 | } |
90 | 91 | ||
91 | 92 | ||
92 | void ConfigDialog::slotAdd() { | 93 | void ConfigDialog::slotAdd() { |
93 | ProfileEditorDialog dlg(new MetaFactory()); | 94 | qWarning("slotAdd"); |
95 | ProfileEditorDialog dlg(m_fact); | ||
94 | 96 | ||
95 | dlg.setCaption("New Connection"); | 97 | dlg.setCaption("New Connection"); |
96 | dlg.showMaximized(); | 98 | dlg.showMaximized(); |
97 | int ret = dlg.exec(); | 99 | int ret = dlg.exec(); |
98 | 100 | ||
99 | if(ret == QDialog::Accepted) | 101 | if(ret == QDialog::Accepted) |
100 | { | 102 | { |
101 | // TODO: Move into general profile save part | 103 | // TODO: Move into general profile save part |
102 | // assignments | 104 | // assignments |
103 | //QString type = dlg.term_type(); | 105 | //QString type = dlg.term_type(); |
104 | //if(type == "VT102") profile = Profile::VT102; | 106 | //if(type == "VT102") profile = Profile::VT102; |
105 | 107 | ||
106 | // get profile from editor | 108 | // get profile from editor |
107 | Profile p = dlg.profile(); | 109 | Profile p = dlg.profile(); |
108 | 110 | ||
109 | new ConfigListItem(lstView, p); | 111 | new ConfigListItem(lstView, p); |
110 | } | 112 | } |
111 | } | 113 | } |
112 | 114 | ||
diff --git a/noncore/apps/opie-console/configdialog.h b/noncore/apps/opie-console/configdialog.h index a0c40d0..b81a004 100644 --- a/noncore/apps/opie-console/configdialog.h +++ b/noncore/apps/opie-console/configdialog.h | |||
@@ -1,23 +1,26 @@ | |||
1 | #ifndef OPIE_CONFIG_DIALOG_H | 1 | #ifndef OPIE_CONFIG_DIALOG_H |
2 | #define OPIE_CONFIG_DIALOG_H | 2 | #define OPIE_CONFIG_DIALOG_H |
3 | 3 | ||
4 | #include <qdialog.h> | 4 | #include <qdialog.h> |
5 | 5 | ||
6 | #include "configurebase.h" | 6 | #include "configurebase.h" |
7 | #include "profile.h" | 7 | #include "profile.h" |
8 | 8 | ||
9 | class MetaFactory; | ||
9 | class ConfigDialog : public ConfigureBase { | 10 | class ConfigDialog : public ConfigureBase { |
10 | Q_OBJECT | 11 | Q_OBJECT |
11 | public: | 12 | public: |
12 | ConfigDialog( const Profile::ValueList&, QWidget* parent = 0l); | 13 | ConfigDialog( const Profile::ValueList&, MetaFactory*, QWidget* parent = 0l); |
13 | ~ConfigDialog(); | 14 | ~ConfigDialog(); |
14 | 15 | ||
15 | Profile::ValueList list()const; | 16 | Profile::ValueList list()const; |
16 | protected slots: | 17 | protected slots: |
17 | void slotRemove(); | 18 | void slotRemove(); |
18 | void slotEdit(); | 19 | void slotEdit(); |
19 | void slotAdd(); | 20 | void slotAdd(); |
21 | private: | ||
22 | MetaFactory* m_fact; | ||
20 | 23 | ||
21 | }; | 24 | }; |
22 | 25 | ||
23 | #endif | 26 | #endif |
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp new file mode 100644 index 0000000..78495d2 --- a/dev/null +++ b/noncore/apps/opie-console/default.cpp | |||
@@ -0,0 +1,65 @@ | |||
1 | #include "io_serial.h" | ||
2 | #include "sz_transfer.h" | ||
3 | |||
4 | #include "default.h" | ||
5 | |||
6 | extern "C" { | ||
7 | // FILE Transfer Stuff | ||
8 | FileTransferLayer* newSZTransfer(IOLayer* lay) { | ||
9 | return new SzTransfer( SzTransfer::SZ, lay ); | ||
10 | } | ||
11 | FileTransferLayer* newSYTransfer(IOLayer* lay) { | ||
12 | return new SzTransfer( SzTransfer::SY, lay ); | ||
13 | } | ||
14 | FileTransferLayer* newSXTransfer(IOLayer* lay) { | ||
15 | return new SzTransfer( SzTransfer::SX, lay ); | ||
16 | } | ||
17 | |||
18 | // Layer stuff | ||
19 | IOLayer* newSerialLayer( const Profile& prof) { | ||
20 | return new IOSerial( prof ); | ||
21 | } | ||
22 | IOLayer* newBTLayer( const Profile& ) { | ||
23 | return 0l; | ||
24 | } | ||
25 | IOLayer* newIrDaLayer( const Profile& ) { | ||
26 | return 0l; | ||
27 | } | ||
28 | |||
29 | // Connection Widgets | ||
30 | ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* ) { | ||
31 | return 0l; | ||
32 | } | ||
33 | ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) { | ||
34 | return newSerialWidget(str, wid); | ||
35 | } | ||
36 | ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) { | ||
37 | return newSerialWidget(str, wid ); | ||
38 | } | ||
39 | |||
40 | // Terminal Widget(s) | ||
41 | ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ) { | ||
42 | return 0l; | ||
43 | } | ||
44 | |||
45 | }; | ||
46 | |||
47 | Default::Default( MetaFactory* fact ) { | ||
48 | fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer ); | ||
49 | fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer ); | ||
50 | fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer ); | ||
51 | |||
52 | fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); | ||
53 | fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); | ||
54 | fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); | ||
55 | |||
56 | fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); | ||
57 | fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); | ||
58 | fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); | ||
59 | |||
60 | fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); | ||
61 | |||
62 | } | ||
63 | Default::~Default() { | ||
64 | |||
65 | } | ||
diff --git a/noncore/apps/opie-console/default.h b/noncore/apps/opie-console/default.h new file mode 100644 index 0000000..ed78986 --- a/dev/null +++ b/noncore/apps/opie-console/default.h | |||
@@ -0,0 +1,30 @@ | |||
1 | #ifndef OPIE_DEFAULT_H | ||
2 | #define OPIE_DEFAULT_H | ||
3 | |||
4 | #include "metafactory.h" | ||
5 | |||
6 | extern "C" { | ||
7 | FileTransferLayer* newSZTransfer(IOLayer*); | ||
8 | FileTransferLayer* newSYTransfer(IOLayer*); | ||
9 | FileTransferLayer* newSXTransfer(IOLayer*); | ||
10 | |||
11 | IOLayer* newSerialLayer(const Profile&); | ||
12 | IOLayer* newBTLayer(const Profile& ); | ||
13 | IOLayer* newIrDaLayer(const Profile& ); | ||
14 | |||
15 | ProfileDialogWidget* newSerialWidget(const QString&, QWidget* ); | ||
16 | ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* ); | ||
17 | ProfileDialogWidget* newBTWidget (const QString&, QWidget* ); | ||
18 | |||
19 | ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ); | ||
20 | }; | ||
21 | |||
22 | class MetaFactory; | ||
23 | struct Default { | ||
24 | public: | ||
25 | Default(MetaFactory* ); | ||
26 | ~Default(); | ||
27 | }; | ||
28 | |||
29 | |||
30 | #endif | ||
diff --git a/noncore/apps/opie-console/io_layer.h b/noncore/apps/opie-console/io_layer.h index 2f1ceef..b891b2b 100644 --- a/noncore/apps/opie-console/io_layer.h +++ b/noncore/apps/opie-console/io_layer.h | |||
@@ -60,28 +60,28 @@ signals: | |||
60 | * int for the error number | 60 | * int for the error number |
61 | * and QString for a text | 61 | * and QString for a text |
62 | */ | 62 | */ |
63 | virtual void error( int, const QString& ) = 0; | 63 | virtual void error( int, const QString& ) = 0; |
64 | 64 | ||
65 | public slots: | 65 | public slots: |
66 | /** | 66 | /** |
67 | * send a QCString to the device | 67 | * send a QCString to the device |
68 | */ | 68 | */ |
69 | virtual void send( const QByteArray& ) = 0; | 69 | virtual void send( const QByteArray& ) = 0; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * bool open | 72 | * bool open |
73 | */ | 73 | */ |
74 | virtual bool open() = 0; | 74 | virtual bool open() = 0; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * close the io | 77 | * close the io |
78 | */ | 78 | */ |
79 | virtual void close() = 0; | 79 | virtual void close() = 0; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | * closes and reloads the settings | 82 | * closes and reloads the settings |
83 | */ | 83 | */ |
84 | virtual void reload( const Config& ) = 0; | 84 | virtual void reload( const Profile& ) = 0; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | #endif | 87 | #endif |
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp index 31f1138..647a331 100644 --- a/noncore/apps/opie-console/mainwindow.cpp +++ b/noncore/apps/opie-console/mainwindow.cpp | |||
@@ -1,39 +1,41 @@ | |||
1 | 1 | ||
2 | #include <qaction.h> | 2 | #include <qaction.h> |
3 | #include <qmenubar.h> | 3 | #include <qmenubar.h> |
4 | #include <qlabel.h> | 4 | #include <qlabel.h> |
5 | #include <qpopupmenu.h> | 5 | #include <qpopupmenu.h> |
6 | #include <qtoolbar.h> | 6 | #include <qtoolbar.h> |
7 | 7 | ||
8 | #include "configdialog.h" | 8 | #include "configdialog.h" |
9 | #include "default.h" | ||
9 | #include "metafactory.h" | 10 | #include "metafactory.h" |
10 | #include "profilemanager.h" | 11 | #include "profilemanager.h" |
11 | #include "mainwindow.h" | 12 | #include "mainwindow.h" |
12 | #include "tabwidget.h" | 13 | #include "tabwidget.h" |
13 | 14 | ||
14 | MainWindow::MainWindow() { | 15 | MainWindow::MainWindow() { |
15 | m_factory = new MetaFactory(); | 16 | m_factory = new MetaFactory(); |
17 | Default def(m_factory); | ||
16 | m_sessions.setAutoDelete( TRUE ); | 18 | m_sessions.setAutoDelete( TRUE ); |
17 | m_curSession = 0; | 19 | m_curSession = 0; |
18 | m_manager = new ProfileManager( m_factory ); | 20 | m_manager = new ProfileManager( m_factory ); |
19 | m_manager->load(); | 21 | m_manager->load(); |
20 | 22 | ||
21 | initUI(); | 23 | initUI(); |
22 | populateProfiles(); | 24 | populateProfiles(); |
23 | } | 25 | } |
24 | void MainWindow::initUI() { | 26 | void MainWindow::initUI() { |
25 | setToolBarsMovable( FALSE ); | 27 | setToolBarsMovable( FALSE ); |
26 | 28 | ||
27 | m_tool = new QToolBar( this ); | 29 | m_tool = new QToolBar( this ); |
28 | m_tool->setHorizontalStretchable( TRUE ); | 30 | m_tool->setHorizontalStretchable( TRUE ); |
29 | 31 | ||
30 | m_bar = new QMenuBar( m_tool ); | 32 | m_bar = new QMenuBar( m_tool ); |
31 | m_console = new QPopupMenu( this ); | 33 | m_console = new QPopupMenu( this ); |
32 | m_sessionsPop= new QPopupMenu( this ); | 34 | m_sessionsPop= new QPopupMenu( this ); |
33 | m_settings = new QPopupMenu( this ); | 35 | m_settings = new QPopupMenu( this ); |
34 | 36 | ||
35 | /* | 37 | /* |
36 | * new Action for new sessions | 38 | * new Action for new sessions |
37 | */ | 39 | */ |
38 | QAction* a = new QAction(); | 40 | QAction* a = new QAction(); |
39 | a->setText( tr("New Connection") ); | 41 | a->setText( tr("New Connection") ); |
@@ -135,42 +137,42 @@ QList<Session> MainWindow::sessions() { | |||
135 | void MainWindow::slotNew() { | 137 | void MainWindow::slotNew() { |
136 | qWarning("New Connection"); | 138 | qWarning("New Connection"); |
137 | } | 139 | } |
138 | 140 | ||
139 | void MainWindow::slotConnect() { | 141 | void MainWindow::slotConnect() { |
140 | if ( currentSession() ) | 142 | if ( currentSession() ) |
141 | currentSession()->layer()->open(); | 143 | currentSession()->layer()->open(); |
142 | } | 144 | } |
143 | 145 | ||
144 | void MainWindow::slotDisconnect() { | 146 | void MainWindow::slotDisconnect() { |
145 | if ( currentSession() ) | 147 | if ( currentSession() ) |
146 | currentSession()->layer()->close(); | 148 | currentSession()->layer()->close(); |
147 | } | 149 | } |
148 | 150 | ||
149 | void MainWindow::slotTerminate() { | 151 | void MainWindow::slotTerminate() { |
150 | if ( currentSession() ) | 152 | if ( currentSession() ) |
151 | currentSession()->layer()->close(); | 153 | currentSession()->layer()->close(); |
152 | delete m_curSession; | 154 | delete m_curSession; |
153 | m_curSession = 0l; | 155 | m_curSession = 0l; |
154 | /* FIXME move to the next session */ | 156 | /* FIXME move to the next session */ |
155 | } | 157 | } |
156 | 158 | ||
157 | void MainWindow::slotConfigure() { | 159 | void MainWindow::slotConfigure() { |
158 | qWarning("configure"); | 160 | qWarning("configure"); |
159 | ConfigDialog conf( manager()->all() ); | 161 | ConfigDialog conf( manager()->all(), factory() ); |
160 | conf.showMaximized(); | 162 | conf.showMaximized(); |
161 | 163 | ||
162 | int ret = conf.exec(); | 164 | int ret = conf.exec(); |
163 | 165 | ||
164 | if ( QDialog::Accepted == ret ) { | 166 | if ( QDialog::Accepted == ret ) { |
165 | manager()->setProfiles( conf.list() ); | 167 | manager()->setProfiles( conf.list() ); |
166 | populateProfiles(); | 168 | populateProfiles(); |
167 | } | 169 | } |
168 | } | 170 | } |
169 | 171 | ||
170 | void MainWindow::slotClose() { | 172 | void MainWindow::slotClose() { |
171 | } | 173 | } |
172 | 174 | ||
173 | void MainWindow::slotProfile( int ) { | 175 | void MainWindow::slotProfile( int ) { |
174 | 176 | ||
175 | 177 | ||
176 | } | 178 | } |
diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index b69d6da..077b418 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp | |||
@@ -1,76 +1,114 @@ | |||
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::addConnectionWidgetFactory( const QCString& name, |
10 | const QString& name, | 10 | const QString& str, |
11 | configWidget wid) { | 11 | configWidget wid) { |
12 | m_namemap.insert ( str, name ); | 12 | m_strings.insert( str, name ); |
13 | m_confFact.insert( str, wid ); | 13 | m_conFact.insert( str, wid ); |
14 | } | 14 | } |
15 | void MetaFactory::addIOLayerFactory( const QString& str, | 15 | void MetaFactory::addTerminalWidgetFactory( const QCString& name, |
16 | const QString& str, | ||
17 | configWidget wid ) { | ||
18 | m_strings.insert( str, name ); | ||
19 | m_termFact.insert( str, wid ); | ||
20 | } | ||
21 | void MetaFactory::addIOLayerFactory( const QCString& name, | ||
22 | const QString& str, | ||
16 | iolayer lay) { | 23 | iolayer lay) { |
24 | m_strings.insert( str, name ); | ||
17 | m_layerFact.insert( str, lay ); | 25 | m_layerFact.insert( str, lay ); |
18 | } | 26 | } |
19 | void MetaFactory::addFileTransferLayer( const QString& str, | 27 | void MetaFactory::addFileTransferLayer( const QCString& name, |
28 | const QString& str, | ||
20 | filelayer lay) { | 29 | filelayer lay) { |
30 | m_strings.insert(str, name ); | ||
21 | m_fileFact.insert( str, lay ); | 31 | m_fileFact.insert( str, lay ); |
22 | } | 32 | } |
23 | QStringList MetaFactory::ioLayers()const { | 33 | QStringList MetaFactory::ioLayers()const { |
24 | QStringList list; | 34 | QStringList list; |
25 | QMap<QString, iolayer>::ConstIterator it; | 35 | QMap<QString, iolayer>::ConstIterator it; |
26 | for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { | 36 | for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) { |
27 | list << it.key(); | 37 | list << it.key(); |
28 | } | 38 | } |
29 | return list; | 39 | return list; |
30 | } | 40 | } |
31 | QStringList MetaFactory::configWidgets()const { | 41 | QStringList MetaFactory::connectionWidgets()const { |
42 | QStringList list; | ||
43 | QMap<QString, configWidget>::ConstIterator it; | ||
44 | for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) { | ||
45 | list << it.key(); | ||
46 | } | ||
47 | return list; | ||
48 | } | ||
49 | QStringList MetaFactory::terminalWidgets()const { | ||
32 | QStringList list; | 50 | QStringList list; |
33 | QMap<QString, configWidget>::ConstIterator it; | 51 | QMap<QString, configWidget>::ConstIterator it; |
34 | for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) { | 52 | for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) { |
35 | list << it.key(); | 53 | list << it.key(); |
36 | } | 54 | } |
37 | return list; | 55 | return list; |
38 | } | 56 | } |
39 | QStringList MetaFactory::fileTransferLayers()const { | 57 | QStringList MetaFactory::fileTransferLayers()const { |
40 | QStringList list; | 58 | QStringList list; |
41 | QMap<QString, filelayer>::ConstIterator it; | 59 | QMap<QString, filelayer>::ConstIterator it; |
42 | for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { | 60 | for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) { |
43 | list << it.key(); | 61 | list << it.key(); |
44 | } | 62 | } |
45 | return list; | 63 | return list; |
46 | } | 64 | } |
47 | 65 | ||
48 | IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { | 66 | IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) { |
49 | IOLayer* lay = 0l; | 67 | IOLayer* lay = 0l; |
50 | 68 | ||
51 | QMap<QString, iolayer>::Iterator it; | 69 | QMap<QString, iolayer>::Iterator it; |
52 | it = m_layerFact.find( str ); | 70 | it = m_layerFact.find( str ); |
53 | if ( it != m_layerFact.end() ) { | 71 | if ( it != m_layerFact.end() ) { |
54 | lay = (*(it.data()))(prof); | 72 | lay = (*(it.data()))(prof); |
55 | /* | 73 | /* |
56 | iolayer laye = it.data(); | 74 | iolayer laye = it.data(); |
57 | lay = (*laye )(conf);*/ | 75 | lay = (*laye )(conf);*/ |
58 | } | 76 | } |
59 | 77 | ||
60 | return lay; | 78 | return lay; |
61 | } | 79 | } |
62 | 80 | ||
63 | ProfileEditorPlugin *MetaFactory::newConfigPlugin ( const QString& str, QWidget *parent, Profile *prof) { | 81 | ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { |
64 | ProfileEditorPlugin *p = NULL; | 82 | ProfileDialogWidget* wid = 0l; |
65 | configWidget c; | ||
66 | 83 | ||
67 | c = m_confFact[str]; | 84 | QMap<QString, configWidget>::Iterator it; |
68 | if(c) p = c(parent, prof); | 85 | it = m_conFact.find( str ); |
69 | 86 | if ( it != m_conFact.end() ) { | |
70 | return p; | 87 | wid = (*(it.data() ) )(str,parent); |
71 | } | 88 | } |
72 | 89 | return wid; | |
73 | QString MetaFactory::name( const QString& str ) { | ||
74 | return m_namemap[str]; | ||
75 | } | 90 | } |
91 | ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) { | ||
92 | if (str.isEmpty() ) | ||
93 | return 0l; | ||
94 | ProfileDialogWidget* wid = 0l; | ||
95 | qWarning("new terminalPlugin %s %l", str.latin1(), parent ); | ||
76 | 96 | ||
97 | QMap<QString, configWidget>::Iterator it; | ||
98 | it = m_termFact.find( str ); | ||
99 | if ( it != m_conFact.end() ) { | ||
100 | wid = (*(it.data() ) )(str,parent); | ||
101 | } | ||
102 | return wid; | ||
103 | } | ||
104 | QCString MetaFactory::internal( const QString& str )const { | ||
105 | return m_strings[str]; | ||
106 | } | ||
107 | QString MetaFactory::external( const QCString& str )const { | ||
108 | QMap<QString, QCString>::ConstIterator it; | ||
109 | for ( it = m_strings.begin(); it != m_strings.end(); ++it ) { | ||
110 | if ( it.data() == str ) | ||
111 | return it.key(); | ||
112 | } | ||
113 | return QString::null; | ||
114 | } | ||
diff --git a/noncore/apps/opie-console/metafactory.h b/noncore/apps/opie-console/metafactory.h index 216de03..3f7ddce 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h | |||
@@ -1,51 +1,85 @@ | |||
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 | #include "profiledialogwidget.h" |
18 | 18 | ||
19 | class MetaFactory { | 19 | class MetaFactory { |
20 | public: | 20 | public: |
21 | typedef ProfileEditorPlugin* (*configWidget)(QWidget* parent, Profile* prof); | 21 | typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); |
22 | typedef IOLayer* (*iolayer)(const Profile& ); | 22 | typedef IOLayer* (*iolayer)(const Profile& ); |
23 | typedef FileTransferLayer* (*filelayer)(IOLayer*); | 23 | typedef FileTransferLayer* (*filelayer)(IOLayer*); |
24 | 24 | ||
25 | MetaFactory(); | 25 | MetaFactory(); |
26 | ~MetaFactory(); | 26 | ~MetaFactory(); |
27 | 27 | ||
28 | void addConfigWidgetFactory( const QString&, | 28 | /** |
29 | const QString&, | 29 | * add a ProfileDialogWidget to the factory |
30 | * name is the name shown to the user | ||
31 | */ | ||
32 | void addConnectionWidgetFactory( const QCString& internalName, | ||
33 | const QString& uiString, | ||
30 | configWidget ); | 34 | configWidget ); |
31 | void addIOLayerFactory(const QString&, | 35 | void addTerminalWidgetFactory ( const QCString& internalName, |
36 | const QString& name, | ||
37 | configWidget ); | ||
38 | |||
39 | /** | ||
40 | * adds an IOLayer factory | ||
41 | */ | ||
42 | void addIOLayerFactory( const QCString&, | ||
43 | const QString&, | ||
32 | iolayer ); | 44 | iolayer ); |
33 | void addFileTransferLayer( const QString&, | 45 | |
46 | /** | ||
47 | * adds a FileTransfer Layer | ||
48 | */ | ||
49 | void addFileTransferLayer( const QCString& name, | ||
50 | const QString&, | ||
34 | filelayer ); | 51 | filelayer ); |
52 | |||
53 | /* translated UI Strings */ | ||
35 | QStringList ioLayers()const; | 54 | QStringList ioLayers()const; |
36 | QStringList configWidgets()const; | 55 | QStringList connectionWidgets()const; |
56 | QStringList terminalWidgets()const; | ||
37 | QStringList fileTransferLayers()const; | 57 | QStringList fileTransferLayers()const; |
38 | IOLayer* newIOLayer( const QString&,const Profile& ); | 58 | IOLayer* newIOLayer( const QString&,const Profile& ); |
39 | ProfileEditorPlugin *newConfigPlugin ( const QString&, QWidget*, Profile* ); | 59 | ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); |
60 | ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); | ||
61 | |||
62 | /* | ||
63 | * internal takes the maybe translated | ||
64 | * public QString and maps it to the internal | ||
65 | * not translatable QCString | ||
66 | */ | ||
67 | QCString internal( const QString& )const; | ||
68 | |||
69 | /* | ||
70 | * external takes the internal name | ||
71 | * it returns a translated name | ||
72 | */ | ||
73 | QString external( const QCString& )const; | ||
40 | 74 | ||
41 | QString name( const QString& ); | ||
42 | 75 | ||
43 | private: | 76 | private: |
44 | QMap<QString, configWidget> m_confFact; | 77 | QMap<QString, QCString> m_strings; |
78 | QMap<QString, configWidget> m_conFact; | ||
79 | QMap<QString, configWidget> m_termFact; | ||
45 | QMap<QString, iolayer> m_layerFact; | 80 | QMap<QString, iolayer> m_layerFact; |
46 | QMap<QString, filelayer> m_fileFact; | 81 | QMap<QString, filelayer> m_fileFact; |
47 | QMap<QString, QString> m_namemap; | ||
48 | }; | 82 | }; |
49 | 83 | ||
50 | 84 | ||
51 | #endif | 85 | #endif |
diff --git a/noncore/apps/opie-console/opie-console.pro b/noncore/apps/opie-console/opie-console.pro index 768e453..984072a 100644 --- a/noncore/apps/opie-console/opie-console.pro +++ b/noncore/apps/opie-console/opie-console.pro | |||
@@ -1,55 +1,57 @@ | |||
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 sz_transfer.h \ | 6 | file_layer.h sz_transfer.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 \ | ||
17 | profileeditorplugins.h \ | ||
18 | emulation_layer.h \ | 16 | emulation_layer.h \ |
19 | widget.h \ | 17 | widget.h \ |
20 | vt102emulation.h \ | 18 | vt102emulation.h \ |
21 | common.h \ | 19 | common.h \ |
22 | history.h \ | 20 | history.h \ |
23 | screen.h \ | 21 | screen.h \ |
24 | keytrans.h \ | 22 | keytrans.h \ |
25 | widget_layer.h \ | 23 | widget_layer.h \ |
26 | transferdialog.h | 24 | transferdialog.h \ |
25 | profiledialogwidget.h \ | ||
26 | profileeditordialog.h \ | ||
27 | default.h | ||
27 | 28 | ||
28 | SOURCES = io_layer.cpp io_serial.cpp \ | 29 | SOURCES = io_layer.cpp io_serial.cpp \ |
29 | file_layer.cpp sz_transfer.cpp \ | 30 | file_layer.cpp sz_transfer.cpp \ |
30 | main.cpp \ | 31 | main.cpp \ |
31 | metafactory.cpp \ | 32 | metafactory.cpp \ |
32 | session.cpp \ | 33 | session.cpp \ |
33 | mainwindow.cpp \ | 34 | mainwindow.cpp \ |
34 | profile.cpp \ | 35 | profile.cpp \ |
35 | profileconfig.cpp \ | 36 | profileconfig.cpp \ |
36 | profilemanager.cpp \ | 37 | profilemanager.cpp \ |
37 | tabwidget.cpp \ | 38 | tabwidget.cpp \ |
38 | configdialog.cpp \ | 39 | configdialog.cpp \ |
39 | profileeditordialog.cpp \ | ||
40 | profileeditorplugins.cpp \ | ||
41 | emulation_layer.cpp \ | 40 | emulation_layer.cpp \ |
42 | widget.cpp \ | 41 | widget.cpp \ |
43 | vt102emulation.cpp \ | 42 | vt102emulation.cpp \ |
44 | history.cpp \ | 43 | history.cpp \ |
45 | screen.cpp \ | 44 | screen.cpp \ |
46 | keytrans.cpp \ | 45 | keytrans.cpp \ |
47 | widget_layer.cpp \ | 46 | widget_layer.cpp \ |
48 | transferdialog.cpp | 47 | transferdialog.cpp \ |
48 | profiledialogwidget.cpp \ | ||
49 | profileeditordialog.cpp \ | ||
50 | default.cpp | ||
49 | 51 | ||
50 | INTERFACES = configurebase.ui editbase.ui | 52 | INTERFACES = configurebase.ui editbase.ui |
51 | INCLUDEPATH += $(OPIEDIR)/include | 53 | INCLUDEPATH += $(OPIEDIR)/include |
52 | DEPENDPATH += $(OPIEDIR)/include | 54 | DEPENDPATH += $(OPIEDIR)/include |
53 | LIBS += -lqpe -lopie | 55 | LIBS += -lqpe -lopie |
54 | TARGET = opie-console | 56 | TARGET = opie-console |
55 | 57 | ||
diff --git a/noncore/apps/opie-console/profile.cpp b/noncore/apps/opie-console/profile.cpp index c8f5eb0..1a94619 100644 --- a/noncore/apps/opie-console/profile.cpp +++ b/noncore/apps/opie-console/profile.cpp | |||
@@ -1,83 +1,90 @@ | |||
1 | #include "profile.h" | 1 | #include "profile.h" |
2 | 2 | ||
3 | Profile::Profile() { | 3 | Profile::Profile() { |
4 | 4 | ||
5 | } | 5 | } |
6 | Profile::Profile( const QString& name, | 6 | Profile::Profile( const QString& name, |
7 | const QString& iolayerName, | 7 | const QCString& iolayerName, |
8 | const QCString& termName, | ||
8 | int background, | 9 | int background, |
9 | int foreground, | 10 | int foreground, |
10 | int terminal ) | 11 | int terminal ) |
11 | : m_name( name ), m_ioLayer( iolayerName ), m_back( background ), | 12 | : m_name( name ), m_ioLayer( iolayerName ), m_term( termName), |
12 | m_fore( foreground ), m_terminal( terminal ) | 13 | m_back( background ), m_fore( foreground ), m_terminal( terminal ) |
13 | { | 14 | {} |
14 | } | ||
15 | Profile::Profile( const Profile& prof ) | 15 | Profile::Profile( const Profile& prof ) |
16 | { | 16 | { |
17 | (*this) = prof; | 17 | (*this) = prof; |
18 | } | 18 | } |
19 | bool Profile::operator==( const Profile& prof ) { | 19 | bool Profile::operator==( const Profile& prof ) { |
20 | if ( m_name == prof.m_name ) return true; | 20 | if ( m_name == prof.m_name ) return true; |
21 | 21 | ||
22 | return false; | 22 | return false; |
23 | } | 23 | } |
24 | Profile &Profile::operator=( const Profile& prof ) { | 24 | Profile &Profile::operator=( const Profile& prof ) { |
25 | m_name = prof.m_name; | 25 | m_name = prof.m_name; |
26 | m_ioLayer = prof.m_ioLayer; | 26 | m_ioLayer = prof.m_ioLayer; |
27 | m_back = prof.m_back; | 27 | m_back = prof.m_back; |
28 | m_fore = prof.m_fore; | 28 | m_fore = prof.m_fore; |
29 | m_terminal = prof.m_terminal; | 29 | m_terminal = prof.m_terminal; |
30 | m_conf = prof.m_conf; | 30 | m_conf = prof.m_conf; |
31 | m_term = prof.m_term; | ||
31 | 32 | ||
32 | return *this; | 33 | return *this; |
33 | } | 34 | } |
34 | Profile::~Profile() { | 35 | Profile::~Profile() { |
35 | } | 36 | } |
36 | QMap<QString, QString> Profile::conf()const { | 37 | QMap<QString, QString> Profile::conf()const { |
37 | return m_conf; | 38 | return m_conf; |
38 | } | 39 | } |
39 | QString Profile::name()const { | 40 | QString Profile::name()const { |
40 | return m_name; | 41 | return m_name; |
41 | } | 42 | } |
42 | QString Profile::ioLayerName()const { | 43 | QCString Profile::ioLayerName()const { |
43 | return m_ioLayer; | 44 | return m_ioLayer; |
44 | } | 45 | } |
46 | QCString Profile::terminalName( )const { | ||
47 | return m_term; | ||
48 | } | ||
45 | int Profile::foreground()const { | 49 | int Profile::foreground()const { |
46 | return m_fore; | 50 | return m_fore; |
47 | } | 51 | } |
48 | int Profile::background()const { | 52 | int Profile::background()const { |
49 | return m_back; | 53 | return m_back; |
50 | } | 54 | } |
51 | int Profile::terminal()const { | 55 | int Profile::terminal()const { |
52 | return m_terminal; | 56 | return m_terminal; |
53 | } | 57 | } |
54 | void Profile::setName( const QString& str ) { | 58 | void Profile::setName( const QString& str ) { |
55 | m_name = str; | 59 | m_name = str; |
56 | } | 60 | } |
57 | void Profile::setIOLayer( const QString& name ) { | 61 | void Profile::setIOLayer( const QCString& name ) { |
58 | m_ioLayer = name; | 62 | m_ioLayer = name; |
59 | } | 63 | } |
64 | void Profile::setTerminalName( const QCString& str ) { | ||
65 | m_term = str; | ||
66 | } | ||
60 | void Profile::setBackground( int back ) { | 67 | void Profile::setBackground( int back ) { |
61 | m_back = back; | 68 | m_back = back; |
62 | } | 69 | } |
63 | void Profile::setForeground( int fore ) { | 70 | void Profile::setForeground( int fore ) { |
64 | m_fore = fore; | 71 | m_fore = fore; |
65 | } | 72 | } |
66 | void Profile::setTerminal( int term ) { | 73 | void Profile::setTerminal( int term ) { |
67 | m_terminal = term; | 74 | m_terminal = term; |
68 | } | 75 | } |
69 | /* config stuff */ | 76 | /* config stuff */ |
70 | void Profile::clearConf() { | 77 | void Profile::clearConf() { |
71 | m_conf.clear(); | 78 | m_conf.clear(); |
72 | } | 79 | } |
73 | void Profile::writeEntry( const QString& key, const QString& value ) { | 80 | void Profile::writeEntry( const QString& key, const QString& value ) { |
74 | m_conf.replace( key, value ); | 81 | m_conf.replace( key, value ); |
75 | } | 82 | } |
76 | void Profile::writeEntry( const QString& key, int num ) { | 83 | void Profile::writeEntry( const QString& key, int num ) { |
77 | writeEntry( key, QString::number( num ) ); | 84 | writeEntry( key, QString::number( num ) ); |
78 | } | 85 | } |
79 | void Profile::writeEntry( const QString& key, bool b ) { | 86 | void Profile::writeEntry( const QString& key, bool b ) { |
80 | writeEntry( key, QString::number(b) ); | 87 | writeEntry( key, QString::number(b) ); |
81 | } | 88 | } |
82 | void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) { | 89 | void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) { |
83 | writeEntry( key, lis.join(sep) ); | 90 | writeEntry( key, lis.join(sep) ); |
diff --git a/noncore/apps/opie-console/profile.h b/noncore/apps/opie-console/profile.h index 5652ac5..78fe6ab 100644 --- a/noncore/apps/opie-console/profile.h +++ b/noncore/apps/opie-console/profile.h | |||
@@ -1,68 +1,71 @@ | |||
1 | #ifndef OPIE_PROFILE_H | 1 | #ifndef OPIE_PROFILE_H |
2 | #define OPIE_PROFILE_H | 2 | #define OPIE_PROFILE_H |
3 | 3 | ||
4 | #include <qmap.h> | 4 | #include <qmap.h> |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qstringlist.h> | 6 | #include <qstringlist.h> |
7 | #include <qvaluelist.h> | 7 | #include <qvaluelist.h> |
8 | /** | 8 | /** |
9 | * A session will be generated from a saved | 9 | * A session will be generated from a saved |
10 | * profile. A profile contains the iolayername | 10 | * profile. A profile contains the iolayername |
11 | * a name. | 11 | * a name. |
12 | * We can generate a Session from a Profile | 12 | * We can generate a Session from a Profile |
13 | * Configuration is contained here too | 13 | * Configuration is contained here too |
14 | */ | 14 | */ |
15 | class Profile { | 15 | class Profile { |
16 | public: | 16 | public: |
17 | typedef QValueList<Profile> ValueList; | 17 | typedef QValueList<Profile> ValueList; |
18 | enum Color { Black = 0, | 18 | enum Color { Black = 0, |
19 | White, | 19 | White, |
20 | Gray }; | 20 | Gray }; |
21 | enum Terminal {VT102 = 0 }; | 21 | enum Terminal {VT102 = 0 }; |
22 | enum Font { Micro = 0, Small, Medium }; | 22 | enum Font { Micro = 0, Small, Medium }; |
23 | Profile(); | 23 | Profile(); |
24 | Profile( const QString& name, | 24 | Profile( const QString& name, |
25 | const QString& iolayerName, | 25 | const QCString& iolayerName, |
26 | const QCString& termName, | ||
26 | int background, | 27 | int background, |
27 | int foreground, | 28 | int foreground, |
28 | int terminal); | 29 | int terminal); |
29 | Profile( const Profile& ); | 30 | Profile( const Profile& ); |
30 | Profile &operator=( const Profile& ); | 31 | Profile &operator=( const Profile& ); |
31 | bool operator==( const Profile& prof ); | 32 | bool operator==( const Profile& prof ); |
32 | 33 | ||
33 | ~Profile(); | 34 | ~Profile(); |
34 | QString name()const; | 35 | QString name()const; |
35 | QString ioLayerName()const; | 36 | QCString ioLayerName()const; |
37 | QCString terminalName()const; | ||
36 | int foreground()const; | 38 | int foreground()const; |
37 | int background()const; | 39 | int background()const; |
38 | int terminal()const; | 40 | int terminal()const; |
39 | 41 | ||
40 | /* | 42 | /* |
41 | * config stuff | 43 | * config stuff |
42 | */ | 44 | */ |
43 | QMap<QString, QString> conf()const; | 45 | QMap<QString, QString> conf()const; |
44 | void clearConf(); | 46 | void clearConf(); |
45 | void writeEntry( const QString& key, const QString& value ); | 47 | void writeEntry( const QString& key, const QString& value ); |
46 | void writeEntry( const QString& key, int num ); | 48 | void writeEntry( const QString& key, int num ); |
47 | void writeEntry( const QString& key, bool b ); | 49 | void writeEntry( const QString& key, bool b ); |
48 | void writeEntry( const QString& key, const QStringList&, const QChar& ); | 50 | void writeEntry( const QString& key, const QStringList&, const QChar& ); |
49 | QString readEntry( const QString& key, const QString& deflt = QString::null)const; | 51 | QString readEntry( const QString& key, const QString& deflt = QString::null)const; |
50 | int readNumEntry( const QString& key, int = -1 )const; | 52 | int readNumEntry( const QString& key, int = -1 )const; |
51 | bool readBoolEntry( const QString& key, bool = FALSE )const; | 53 | bool readBoolEntry( const QString& key, bool = FALSE )const; |
52 | 54 | ||
53 | void setName( const QString& ); | 55 | void setName( const QString& ); |
54 | void setIOLayer( const QString& ); | 56 | void setIOLayer( const QCString& ); |
57 | void setTerminalName( const QCString& ); | ||
55 | void setBackground( int back ); | 58 | void setBackground( int back ); |
56 | void setForeground( int fore ); | 59 | void setForeground( int fore ); |
57 | void setTerminal( int term ); | 60 | void setTerminal( int term ); |
58 | void setConf( const QMap<QString, QString>& ); | 61 | void setConf( const QMap<QString, QString>& ); |
59 | private: | 62 | private: |
60 | QMap<QString, QString> m_conf; | 63 | QMap<QString, QString> m_conf; |
61 | QString m_name; | 64 | QString m_name; |
62 | QString m_ioLayer; | 65 | QCString m_ioLayer, m_term; |
63 | int m_back; | 66 | int m_back; |
64 | int m_fore; | 67 | int m_fore; |
65 | int m_terminal; | 68 | int m_terminal; |
66 | }; | 69 | }; |
67 | 70 | ||
68 | #endif | 71 | #endif |
diff --git a/noncore/apps/opie-console/profiledialogwidget.cpp b/noncore/apps/opie-console/profiledialogwidget.cpp new file mode 100644 index 0000000..24d59bf --- a/dev/null +++ b/noncore/apps/opie-console/profiledialogwidget.cpp | |||
@@ -0,0 +1,32 @@ | |||
1 | #include "profiledialogwidget.h" | ||
2 | |||
3 | ProfileDialogWidget::ProfileDialogWidget( const QString&, QWidget* parent, | ||
4 | const char* name ) | ||
5 | : QWidget( parent, name ) { | ||
6 | } | ||
7 | ProfileDialogWidget::~ProfileDialogWidget() { | ||
8 | } | ||
9 | |||
10 | ProfileDialogTerminalWidget::ProfileDialogTerminalWidget( const QString& na, | ||
11 | QWidget* parent, | ||
12 | const char* name ) | ||
13 | : ProfileDialogWidget( na, parent, name ) | ||
14 | { | ||
15 | } | ||
16 | ProfileDialogTerminalWidget::~ProfileDialogTerminalWidget() { | ||
17 | } | ||
18 | ProfileDialogWidget::Type ProfileDialogTerminalWidget::type()const { | ||
19 | return Terminal; | ||
20 | } | ||
21 | |||
22 | ProfileDialogConnectionWidget::ProfileDialogConnectionWidget( const QString& na, | ||
23 | QWidget* parent, | ||
24 | const char* name ) | ||
25 | : ProfileDialogWidget(na, parent, name ) | ||
26 | { | ||
27 | } | ||
28 | ProfileDialogConnectionWidget::~ProfileDialogConnectionWidget() { | ||
29 | } | ||
30 | ProfileDialogWidget::Type ProfileDialogConnectionWidget::type()const { | ||
31 | return Connection; | ||
32 | } | ||
diff --git a/noncore/apps/opie-console/profiledialogwidget.h b/noncore/apps/opie-console/profiledialogwidget.h new file mode 100644 index 0000000..5d279e6 --- a/dev/null +++ b/noncore/apps/opie-console/profiledialogwidget.h | |||
@@ -0,0 +1,50 @@ | |||
1 | #ifndef OPIE_PROFILE_DIALOG_WIDGET_H | ||
2 | #define OPIE_PROFILE_DIALOG_WIDGET_H | ||
3 | |||
4 | #include <qwidget.h> | ||
5 | |||
6 | #include "profile.h" | ||
7 | |||
8 | class ProfileDialogWidget : public QWidget { | ||
9 | Q_OBJECT | ||
10 | public: | ||
11 | enum Type { | ||
12 | Connection, | ||
13 | Terminal | ||
14 | }; | ||
15 | ProfileDialogWidget( const QString& name, QWidget* parent, const char* name = 0l); | ||
16 | ~ProfileDialogWidget(); | ||
17 | |||
18 | /* | ||
19 | * load data from a Profile into | ||
20 | * the DialogWidget | ||
21 | */ | ||
22 | virtual void load( const Profile& ) = 0; | ||
23 | |||
24 | /* | ||
25 | * save data into a profile | ||
26 | * from the DialogWidget | ||
27 | */ | ||
28 | virtual void save( Profile& ) = 0; | ||
29 | |||
30 | virtual Type type()const = 0; | ||
31 | }; | ||
32 | class ProfileDialogTerminalWidget : public ProfileDialogWidget { | ||
33 | Q_OBJECT | ||
34 | public: | ||
35 | ProfileDialogTerminalWidget( const QString& name, QWidget* widget, | ||
36 | const char* name =0l); | ||
37 | ~ProfileDialogTerminalWidget(); | ||
38 | Type type()const; | ||
39 | }; | ||
40 | class ProfileDialogConnectionWidget : public ProfileDialogWidget { | ||
41 | Q_OBJECT | ||
42 | public: | ||
43 | ProfileDialogConnectionWidget( const QString& name, QWidget* parent, | ||
44 | const char* name =0l); | ||
45 | ~ProfileDialogConnectionWidget(); | ||
46 | Type type() const; | ||
47 | |||
48 | }; | ||
49 | |||
50 | #endif | ||
diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index 3843943..061b1c2 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp | |||
@@ -1,189 +1,190 @@ | |||
1 | #include <qlayout.h> | ||
2 | #include <qlineedit.h> | ||
3 | #include <qlabel.h> | ||
4 | #include <qmessagebox.h> | ||
5 | #include <qstringlist.h> | ||
6 | #include <qcombobox.h> | ||
1 | 7 | ||
2 | #include <opie/otabwidget.h> | ||
3 | #include "profileeditordialog.h" | ||
4 | 8 | ||
5 | #include "qlayout.h" | 9 | #include <opie/otabwidget.h> |
6 | #include "qlineedit.h" | ||
7 | #include "qlabel.h" | ||
8 | #include "qmessagebox.h" | ||
9 | #include "qstringlist.h" | ||
10 | #include "qcombobox.h" | ||
11 | 10 | ||
12 | #include "profileeditorplugins.h" | 11 | #include "profileeditorplugins.h" |
13 | #include "metafactory.h" | 12 | #include "metafactory.h" |
13 | #include "profileeditordialog.h" | ||
14 | |||
15 | namespace { | ||
16 | void setCurrent( const QString& str, QComboBox* bo ) { | ||
17 | for (uint i = 0; i < bo->count(); i++ ) { | ||
18 | if ( bo->text(i) == str ) { | ||
19 | bo->setCurrentItem( i ); | ||
20 | } | ||
21 | } | ||
22 | } | ||
23 | |||
24 | |||
25 | } | ||
14 | 26 | ||
15 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, | 27 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact, |
16 | const Profile& prof ) | 28 | const Profile& prof ) |
17 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) | 29 | : QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof ) |
18 | { | 30 | { |
19 | initUI(); | 31 | initUI(); |
20 | 32 | ||
21 | // Apply current profile | 33 | // Apply current profile |
22 | // plugin_plugin->load(profile); | 34 | // plugin_plugin->load(profile); |
23 | // ... (reset profile name line edit etc.) | 35 | // ... (reset profile name line edit etc.) |
24 | } | 36 | } |
25 | 37 | ||
26 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) | 38 | ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) |
27 | : QDialog(0, 0, TRUE), m_fact( fact ) | 39 | : QDialog(0, 0, TRUE), m_fact( fact ) |
28 | { | 40 | { |
29 | // Default profile | 41 | // Default profile |
30 | m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102); | 42 | m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102); |
31 | 43 | ||
32 | initUI(); | 44 | initUI(); |
33 | 45 | ||
34 | // Apply current profile | 46 | // Apply current profile |
35 | // plugin_plugin->load(profile); | 47 | // plugin_plugin->load(profile); |
36 | } | 48 | } |
37 | 49 | ||
38 | Profile ProfileEditorDialog::profile() const | 50 | Profile ProfileEditorDialog::profile() const |
39 | { | 51 | { |
40 | return m_prof; | 52 | return m_prof; |
41 | } | 53 | } |
42 | 54 | ||
43 | void ProfileEditorDialog::initUI() | 55 | void ProfileEditorDialog::initUI() |
44 | { | 56 | { |
57 | m_con = m_term = 0l; | ||
45 | 58 | ||
46 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); | 59 | QVBoxLayout *mainLayout = new QVBoxLayout( this ); |
47 | OTabWidget *tabWidget = new OTabWidget( this ); | 60 | OTabWidget *tabWidget = new OTabWidget( this ); |
48 | mainLayout->add(tabWidget); | 61 | mainLayout->add(tabWidget); |
49 | 62 | ||
50 | QWidget *tabterm, *tabconn, *tabprof; | 63 | QWidget *tabprof; |
51 | 64 | ||
65 | /* base tabs */ | ||
52 | tabprof = new QWidget(this); | 66 | tabprof = new QWidget(this); |
53 | tabterm = new QWidget(this); | 67 | m_tabTerm = new QWidget(this); |
54 | tabconn = new QWidget(this); | 68 | m_tabCon = new QWidget(this); |
55 | 69 | ||
56 | // for the time being: fake factory | 70 | /* base layout for tabs */ |
57 | 71 | m_layCon = new QHBoxLayout( m_tabCon , 2 ); | |
58 | m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial); | 72 | m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); |
59 | m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda); | ||
60 | m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem); | ||
61 | 73 | ||
62 | // profile tab | 74 | // profile tab |
63 | 75 | ||
64 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); | 76 | QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof); |
65 | 77 | m_name = new QLineEdit(tabprof); | |
66 | name_line = new QLineEdit(tabprof); | 78 | QLabel *con = new QLabel(tr("Connection"), tabprof ); |
67 | 79 | QLabel *term = new QLabel(tr("Terminal"), tabprof ); | |
68 | // connection tab, fixed part | 80 | m_conCmb = new QComboBox( tabprof ); |
69 | 81 | m_termCmb = new QComboBox( tabprof ); | |
70 | QLabel *device = new QLabel(QObject::tr("Device"), tabconn); | ||
71 | |||
72 | device_box = new QComboBox(tabconn); | ||
73 | |||
74 | QStringList w = m_fact->configWidgets(); | ||
75 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | ||
76 | device_box->insertItem(m_fact->name((*it))); | ||
77 | |||
78 | // connection tab, factory part | ||
79 | plugin_base = new QWidget(tabconn); | ||
80 | plugin_layout = new QHBoxLayout(plugin_base, 0); | ||
81 | |||
82 | plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, &m_prof); | ||
83 | plugin_layout->add(plugin_plugin->widget()); | ||
84 | |||
85 | // connection tab, general part | ||
86 | |||
87 | QWidget *conn_widget = plugin_plugin->connection_widget(); | ||
88 | conn_widget->reparent(tabconn, 0, QPoint(), true); | ||
89 | |||
90 | // terminal tab | ||
91 | |||
92 | QWidget *term_widget = plugin_plugin->terminal_widget(); | ||
93 | term_widget->reparent(tabterm, 0, QPoint(), true); | ||
94 | 82 | ||
95 | // layouting | 83 | // layouting |
96 | |||
97 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); | 84 | QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2); |
98 | vbox3->add(name); | 85 | vbox3->add(name); |
99 | vbox3->add(name_line); | 86 | vbox3->add(m_name); |
87 | vbox3->add(con ); | ||
88 | vbox3->add(m_conCmb ); | ||
89 | vbox3->add(term ); | ||
90 | vbox3->add(m_termCmb ); | ||
100 | vbox3->addStretch(1); | 91 | vbox3->addStretch(1); |
101 | 92 | ||
102 | QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2); | ||
103 | vbox->add(device); | ||
104 | vbox->add(device_box); | ||
105 | vbox->add(plugin_base); | ||
106 | vbox->add(conn_widget); | ||
107 | vbox->setStretchFactor(device, 1); | ||
108 | vbox->setStretchFactor(device_box, 1); | ||
109 | vbox->setStretchFactor(plugin_base, 1); | ||
110 | vbox->setStretchFactor(conn_widget, 7); | ||
111 | |||
112 | QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2); | ||
113 | vbox2->add(term_widget); | ||
114 | |||
115 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); | 93 | tabWidget->addTab(tabprof, "", QObject::tr("Profile")); |
116 | tabWidget->addTab(tabconn, "", QObject::tr("Connection")); | 94 | tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); |
117 | tabWidget->addTab(tabterm, "", QObject::tr("Terminal")); | 95 | tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); |
118 | tabWidget->setCurrentTab( tabprof ); | 96 | tabWidget->setCurrentTab( tabprof ); |
119 | 97 | ||
120 | // load profile values | ||
121 | name_line->setText(m_prof.name()); | ||
122 | for(int i = 0; i < device_box->count(); i++) | ||
123 | { | ||
124 | device_box->setCurrentItem(i); | ||
125 | if(prof_type() == m_prof.ioLayerName()) | ||
126 | { | ||
127 | slotDevice(i); | ||
128 | break; | ||
129 | } | ||
130 | } | ||
131 | 98 | ||
132 | // signals | 99 | // fill the comboboxes |
133 | connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int))); | 100 | QStringList list = m_fact->connectionWidgets(); |
101 | QStringList::Iterator it; | ||
102 | for (it =list.begin(); it != list.end(); ++it ) { | ||
103 | m_conCmb->insertItem( (*it) ); | ||
134 | } | 104 | } |
135 | 105 | list = m_fact->terminalWidgets(); | |
136 | ProfileEditorDialog::~ProfileEditorDialog() { | 106 | for (it =list.begin(); it != list.end(); ++it ) { |
137 | 107 | m_termCmb->insertItem( (*it) ); | |
138 | } | 108 | } |
139 | 109 | ||
140 | void ProfileEditorDialog::slotDevice(int id) | 110 | // load profile values |
141 | { | 111 | m_name->setText(m_prof.name()); |
142 | delete plugin_plugin; | 112 | slotConActivated( m_fact->external(m_prof.ioLayerName() ) ); |
113 | slotTermActivated( m_fact->external(m_prof.terminalName() ) ); | ||
114 | setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); | ||
115 | setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); | ||
116 | |||
117 | qWarning("Layer: %s %s", m_prof.ioLayerName().data(), | ||
118 | m_fact->external(m_prof.ioLayerName() ).latin1() ); | ||
119 | qWarning("Term: %s %s", m_prof.terminalName().data(), | ||
120 | m_fact->external(m_prof.terminalName() ).latin1() ); | ||
121 | |||
122 | // signal and slots | ||
123 | connect(m_conCmb, SIGNAL(activated(const QString& ) ), | ||
124 | this, SLOT(slotConActivated(const QString&) ) ); | ||
125 | connect(m_termCmb, SIGNAL(activated(const QString& ) ), | ||
126 | this, SLOT(slotTermActivated(const QString& ) ) ); | ||
143 | 127 | ||
144 | plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof); | 128 | } |
145 | plugin_layout->add(plugin_plugin->widget()); | ||
146 | 129 | ||
147 | // Reload profile associated to device, including e.g. conn_device() | 130 | ProfileEditorDialog::~ProfileEditorDialog() { |
148 | // m_prof = plugin_plugin->profile() | ||
149 | // or, keeping the profile name: m_prof->reload(plugin_plugin->profile()) | ||
150 | 131 | ||
151 | //plugin_plugin->show(); | ||
152 | plugin_plugin->widget()->show(); | ||
153 | } | 132 | } |
154 | |||
155 | void ProfileEditorDialog::accept() | 133 | void ProfileEditorDialog::accept() |
156 | { | 134 | { |
157 | if(prof_name().isEmpty()) | 135 | if(profName().isEmpty()) |
158 | { | 136 | { |
159 | QMessageBox::information(this, | 137 | QMessageBox::information(this, |
160 | QObject::tr("Invalid profile"), | 138 | QObject::tr("Invalid profile"), |
161 | QObject::tr("Please enter a profile name.")); | 139 | QObject::tr("Please enter a profile name.")); |
162 | return; | 140 | return; |
163 | } | 141 | } |
164 | // Save profile and plugin profile | 142 | // Save profile and plugin profile |
165 | if(plugin_plugin) plugin_plugin->save(); | 143 | //if(plugin_plugin) plugin_plugin->save(); |
166 | 144 | ||
167 | // Save general values | 145 | // Save general values |
168 | m_prof.setName(prof_name()); | 146 | m_prof.setName(profName()); |
169 | m_prof.setIOLayer(prof_type()); | 147 | m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); |
148 | m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); | ||
149 | qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(), | ||
150 | m_termCmb->currentText().latin1() ); | ||
170 | 151 | ||
171 | QDialog::accept(); | 152 | QDialog::accept(); |
172 | } | 153 | } |
173 | 154 | ||
174 | 155 | ||
175 | QString ProfileEditorDialog::prof_name() | 156 | QString ProfileEditorDialog::profName()const |
176 | { | 157 | { |
177 | return name_line->text(); | 158 | return m_name->text(); |
178 | } | 159 | } |
179 | 160 | ||
180 | QString ProfileEditorDialog::prof_type() | 161 | QCString ProfileEditorDialog::profType()const |
181 | { | 162 | { |
182 | QStringList w = m_fact->configWidgets(); | 163 | /*QStringList w = m_fact->configWidgets(); |
183 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) | 164 | for(QStringList::Iterator it = w.begin(); it != w.end(); it++) |
184 | if(device_box->currentText() == m_fact->name((*it))) return (*it); | 165 | if(device_box->currentText() == m_fact->name((*it))) return (*it); |
185 | 166 | */ | |
186 | return QString::null; | 167 | return QCString(); |
168 | } | ||
169 | /* | ||
170 | * we need to switch the widget | ||
171 | */ | ||
172 | void ProfileEditorDialog::slotConActivated( const QString& str ) { | ||
173 | delete m_con; | ||
174 | m_con = m_fact->newConnectionPlugin( str, m_tabCon ); | ||
175 | |||
176 | if (m_con ) | ||
177 | m_layCon->addWidget( m_con ); | ||
178 | } | ||
179 | /* | ||
180 | * we need to switch the widget | ||
181 | */ | ||
182 | void ProfileEditorDialog::slotTermActivated( const QString& str ) { | ||
183 | delete m_term; | ||
184 | m_term = m_fact->newTerminalPlugin( str, 0l ); | ||
185 | qWarning("past"); | ||
186 | |||
187 | if (m_term) | ||
188 | m_layTerm->addWidget( m_term ); | ||
187 | } | 189 | } |
188 | |||
189 | 190 | ||
diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h index 8e830f1..3b67bb3 100644 --- a/noncore/apps/opie-console/profileeditordialog.h +++ b/noncore/apps/opie-console/profileeditordialog.h | |||
@@ -1,50 +1,51 @@ | |||
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 <qdialog.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 | class ProfileDialogWidget; |
16 | 16 | ||
17 | class ProfileEditorDialog : public QDialog { | 17 | class ProfileEditorDialog : public QDialog { |
18 | Q_OBJECT | 18 | Q_OBJECT |
19 | public: | 19 | public: |
20 | ProfileEditorDialog(MetaFactory* fact, | 20 | ProfileEditorDialog(MetaFactory* fact, |
21 | const Profile& prof ); | 21 | const Profile& prof ); |
22 | ProfileEditorDialog(MetaFactory* fact ); | 22 | ProfileEditorDialog(MetaFactory* fact ); |
23 | ~ProfileEditorDialog(); | 23 | ~ProfileEditorDialog(); |
24 | Profile profile()const; | 24 | Profile profile()const; |
25 | 25 | ||
26 | QString prof_name(); | 26 | |
27 | QString prof_type(); | ||
28 | 27 | ||
29 | public slots: | 28 | public slots: |
30 | void accept(); | 29 | void accept(); |
31 | void slotDevice(int id); | ||
32 | 30 | ||
31 | private slots: | ||
32 | void slotConActivated(const QString& ); | ||
33 | void slotTermActivated( const QString& ); | ||
33 | private: | 34 | private: |
34 | void initUI(); | 35 | void initUI(); |
36 | QString profName()const; | ||
37 | QCString profType()const; | ||
35 | 38 | ||
36 | MetaFactory* m_fact; | 39 | MetaFactory* m_fact; |
37 | EditBase* m_base; | ||
38 | QTabWidget* m_tab; | ||
39 | QHBoxLayout* m_lay; | 40 | QHBoxLayout* m_lay; |
40 | Profile m_prof; | 41 | Profile m_prof; |
41 | 42 | ||
42 | QLineEdit *name_line; | 43 | QLineEdit *m_name; |
43 | QComboBox *device_box; | 44 | QComboBox *m_conCmb, *m_termCmb; |
44 | 45 | ||
45 | QWidget *plugin_base; | 46 | QWidget *m_tabCon, *m_tabTerm; |
46 | ProfileEditorPlugin *plugin_plugin; | 47 | ProfileDialogWidget* m_con, *m_term; |
47 | QHBoxLayout *plugin_layout; | 48 | QHBoxLayout *m_layCon, *m_layTerm; |
48 | }; | 49 | }; |
49 | 50 | ||
50 | #endif | 51 | #endif |
diff --git a/noncore/apps/opie-console/profileeditorplugins.h b/noncore/apps/opie-console/profileeditorplugins.h index 591163a..4ca780e 100644 --- a/noncore/apps/opie-console/profileeditorplugins.h +++ b/noncore/apps/opie-console/profileeditorplugins.h | |||
@@ -1,38 +1,38 @@ | |||
1 | #ifndef PROFILE_EDITOR_PLUGINS_H | 1 | #ifndef PROFILE_EDITOR_PLUGINS_H |
2 | #define PROFILE_EDITOR_PLUGINS_H | 2 | #define PROFILE_EDITOR_PLUGINS_H |
3 | 3 | ||
4 | #include "profile.h" | 4 | #include "profile.h" |
5 | 5 | ||
6 | #include "qobject.h" | 6 | #include <qobject.h> |
7 | 7 | ||
8 | class QWidget; | 8 | class QWidget; |
9 | 9 | ||
10 | class ProfileEditorPlugin : public QObject | 10 | class ProfileEditorPlugin : public QObject |
11 | { | 11 | { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | public: | 13 | public: |
14 | ProfileEditorPlugin(QWidget *parent, Profile *p); | 14 | ProfileEditorPlugin(QWidget *parent); |
15 | 15 | ||
16 | virtual ~ProfileEditorPlugin(); | 16 | virtual ~ProfileEditorPlugin(); |
17 | 17 | ||
18 | virtual void save() = 0; | 18 | virtual void save() = 0; |
19 | 19 | ||
20 | virtual QWidget *widget() = 0; | 20 | virtual QWidget *widget() = 0; |
21 | 21 | ||
22 | QWidget *connection_widget(); | 22 | QWidget *connection_widget(); |
23 | QWidget *terminal_widget(); | 23 | QWidget *terminal_widget(); |
24 | 24 | ||
25 | public slots: | 25 | public slots: |
26 | void slotConnFlow(int id); | 26 | void slotConnFlow(int id); |
27 | void slotConnParity(int id); | 27 | void slotConnParity(int id); |
28 | void slotConnSpeed(int id); | 28 | void slotConnSpeed(int id); |
29 | void slotTermTerm(int id); | 29 | void slotTermTerm(int id); |
30 | void slotTermColour(int id); | 30 | void slotTermColour(int id); |
31 | void slotTermFont(int id); | 31 | void slotTermFont(int id); |
32 | void slotTermEcho(bool on); | 32 | void slotTermEcho(bool on); |
33 | void slotTermWrap(bool on); | 33 | void slotTermWrap(bool on); |
34 | void slotTermInbound(bool on); | 34 | void slotTermInbound(bool on); |
35 | void slotTermOutbound(bool on); | 35 | void slotTermOutbound(bool on); |
36 | 36 | ||
37 | protected: | 37 | protected: |
38 | QWidget *m_parent, *m_widget; | 38 | QWidget *m_parent, *m_widget; |
diff --git a/noncore/apps/opie-console/profilemanager.cpp b/noncore/apps/opie-console/profilemanager.cpp index 72a5117..6ad08b5 100644 --- a/noncore/apps/opie-console/profilemanager.cpp +++ b/noncore/apps/opie-console/profilemanager.cpp | |||
@@ -7,86 +7,88 @@ | |||
7 | 7 | ||
8 | ProfileManager::ProfileManager( MetaFactory* fact ) | 8 | ProfileManager::ProfileManager( MetaFactory* fact ) |
9 | : m_fact( fact ) | 9 | : m_fact( fact ) |
10 | { | 10 | { |
11 | 11 | ||
12 | } | 12 | } |
13 | ProfileManager::~ProfileManager() { | 13 | ProfileManager::~ProfileManager() { |
14 | 14 | ||
15 | } | 15 | } |
16 | void ProfileManager::load() { | 16 | void ProfileManager::load() { |
17 | m_list.clear(); | 17 | m_list.clear(); |
18 | qWarning("load"); | 18 | qWarning("load"); |
19 | ProfileConfig conf("opie-console-profiles"); | 19 | ProfileConfig conf("opie-console-profiles"); |
20 | QStringList groups = conf.groups(); | 20 | QStringList groups = conf.groups(); |
21 | QStringList::Iterator it; | 21 | QStringList::Iterator it; |
22 | 22 | ||
23 | /* | 23 | /* |
24 | * for each profile | 24 | * for each profile |
25 | */ | 25 | */ |
26 | for ( it = groups.begin(); it != groups.end(); ++it ) { | 26 | for ( it = groups.begin(); it != groups.end(); ++it ) { |
27 | qWarning("group " + (*it) ); | 27 | qWarning("group " + (*it) ); |
28 | conf.setGroup( (*it) ); | 28 | conf.setGroup( (*it) ); |
29 | Profile prof; | 29 | Profile prof; |
30 | prof.setName( conf.readEntry("name") ); | 30 | prof.setName( conf.readEntry("name") ); |
31 | prof.setIOLayer( conf.readEntry("iolayer") ); | 31 | prof.setIOLayer( conf.readEntry("iolayer").utf8() ); |
32 | prof.setTerminalName( conf.readEntry("term").utf8() ); | ||
32 | prof.setBackground( conf.readNumEntry("back") ); | 33 | prof.setBackground( conf.readNumEntry("back") ); |
33 | prof.setForeground( conf.readNumEntry("fore") ); | 34 | prof.setForeground( conf.readNumEntry("fore") ); |
34 | prof.setTerminal( conf.readNumEntry("terminal") ); | 35 | prof.setTerminal( conf.readNumEntry("terminal") ); |
35 | prof.setConf( conf.items( (*it) ) ); | 36 | prof.setConf( conf.items( (*it) ) ); |
36 | 37 | ||
37 | /* now add it */ | 38 | /* now add it */ |
38 | m_list.append( prof ); | 39 | m_list.append( prof ); |
39 | } | 40 | } |
40 | 41 | ||
41 | } | 42 | } |
42 | void ProfileManager::clear() { | 43 | void ProfileManager::clear() { |
43 | m_list.clear(); | 44 | m_list.clear(); |
44 | } | 45 | } |
45 | Profile::ValueList ProfileManager::all()const { | 46 | Profile::ValueList ProfileManager::all()const { |
46 | return m_list; | 47 | return m_list; |
47 | } | 48 | } |
48 | Session* ProfileManager::fromProfile( const Profile& prof) { | 49 | Session* ProfileManager::fromProfile( const Profile& prof) { |
49 | Session* session = new Session(); | 50 | Session* session = new Session(); |
50 | session->setName( prof.name() ); | 51 | session->setName( prof.name() ); |
51 | session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), | 52 | session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(), |
52 | prof) ); | 53 | prof) ); |
53 | /* | 54 | /* |
54 | * FIXME | 55 | * FIXME |
55 | * load emulation | 56 | * load emulation |
56 | * load widget? | 57 | * load widget? |
57 | * set colors + fonts | 58 | * set colors + fonts |
58 | */ | 59 | */ |
59 | return session; | 60 | return session; |
60 | } | 61 | } |
61 | void ProfileManager::save( ) { | 62 | void ProfileManager::save( ) { |
62 | ProfileConfig conf("opie-console-profiles"); | 63 | ProfileConfig conf("opie-console-profiles"); |
63 | conf.clearAll(); | 64 | conf.clearAll(); |
64 | Profile::ValueList::Iterator it; | 65 | Profile::ValueList::Iterator it; |
65 | for (it = m_list.begin(); it != m_list.end(); ++it ) { | 66 | for (it = m_list.begin(); it != m_list.end(); ++it ) { |
66 | conf.setGroup( (*it).name() ); | 67 | conf.setGroup( (*it).name() ); |
67 | conf.writeEntry( "name", (*it).name() ); | 68 | conf.writeEntry( "name", (*it).name() ); |
68 | conf.writeEntry( "ioplayer", (*it).ioLayerName() ); | 69 | conf.writeEntry( "ioplayer", QString::fromUtf8( (*it).ioLayerName() ) ); |
70 | conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) ); | ||
69 | conf.writeEntry( "back", (*it).background() ); | 71 | conf.writeEntry( "back", (*it).background() ); |
70 | conf.writeEntry( "fore", (*it).foreground() ); | 72 | conf.writeEntry( "fore", (*it).foreground() ); |
71 | conf.writeEntry( "terminal", (*it).terminal() ); | 73 | conf.writeEntry( "terminal", (*it).terminal() ); |
72 | /* now the config stuff */ | 74 | /* now the config stuff */ |
73 | QMap<QString, QString> map = (*it).conf(); | 75 | QMap<QString, QString> map = (*it).conf(); |
74 | QMap<QString, QString>::Iterator it; | 76 | QMap<QString, QString>::Iterator it; |
75 | for ( it = map.begin(); it != map.end(); ++it ) { | 77 | for ( it = map.begin(); it != map.end(); ++it ) { |
76 | conf.writeEntry( it.key(), it.data() ); | 78 | conf.writeEntry( it.key(), it.data() ); |
77 | } | 79 | } |
78 | } | 80 | } |
79 | } | 81 | } |
80 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { | 82 | void ProfileManager::setProfiles( const Profile::ValueList& list ) { |
81 | m_list = list; | 83 | m_list = list; |
82 | }; | 84 | }; |
83 | Profile ProfileManager::profile( const QString& name )const { | 85 | Profile ProfileManager::profile( const QString& name )const { |
84 | Profile prof; | 86 | Profile prof; |
85 | Profile::ValueList::ConstIterator it; | 87 | Profile::ValueList::ConstIterator it; |
86 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { | 88 | for ( it = m_list.begin(); it != m_list.end(); ++it ) { |
87 | if ( name == (*it).name() ) { | 89 | if ( name == (*it).name() ) { |
88 | prof = (*it); | 90 | prof = (*it); |
89 | break; | 91 | break; |
90 | } | 92 | } |
91 | } | 93 | } |
92 | return prof; | 94 | return prof; |
diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp index de321ae..10f3f7a 100644 --- a/noncore/apps/opie-console/sz_transfer.cpp +++ b/noncore/apps/opie-console/sz_transfer.cpp | |||
@@ -1,30 +1,30 @@ | |||
1 | 1 | ||
2 | #include "sz_transfer.h" | 2 | #include "sz_transfer.h" |
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <opie/oprocess.h> | 4 | #include <opie/oprocess.h> |
5 | 5 | ||
6 | SzTransfer::SzTransfer(IOLayer *layer) : FileTransferLayer(layer) | 6 | SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) |
7 | { | 7 | { |
8 | } | 8 | } |
9 | 9 | ||
10 | SzTransfer::~SzTransfer() { | 10 | SzTransfer::~SzTransfer() { |
11 | } | 11 | } |
12 | 12 | ||
13 | void SzTransfer::sendFile(const QFile& file) { | 13 | void SzTransfer::sendFile(const QFile& file) { |
14 | 14 | ||
15 | sendFile(file.name()); | 15 | sendFile(file.name()); |
16 | } | 16 | } |
17 | 17 | ||
18 | void SzTransfer::sendFile(const QString& file) { | 18 | void SzTransfer::sendFile(const QString& file) { |
19 | 19 | ||
20 | proc = new OProcess; | 20 | proc = new OProcess; |
21 | *proc << "sz"; | 21 | *proc << "sz"; |
22 | *proc << "-vv" << file; | 22 | *proc << "-vv" << file; |
23 | connect(proc, SIGNAL(processExited(OProcess *)), | 23 | connect(proc, SIGNAL(processExited(OProcess *)), |
24 | this, SLOT(sent())); | 24 | this, SLOT(sent())); |
25 | connect(proc, SIGNAL(processRecievedStdout(OProcess *, char *, int)), | 25 | connect(proc, SIGNAL(processRecievedStdout(OProcess *, char *, int)), |
26 | this, SLOT(SzRecievedStdout(OProcess *, char *, int))); | 26 | this, SLOT(SzRecievedStdout(OProcess *, char *, int))); |
27 | connect(proc, SIGNAL(processRecievedStderr(OProcess *, char *, int)), | 27 | connect(proc, SIGNAL(processRecievedStderr(OProcess *, char *, int)), |
28 | this, SLOT(SzRecievedStderr(OProcess *, char *, int))); | 28 | this, SLOT(SzRecievedStderr(OProcess *, char *, int))); |
29 | connect(layer(), SIGNAL(received(QByteArray &)), | 29 | connect(layer(), SIGNAL(received(QByteArray &)), |
30 | this, SLOT(recievedStdin(QByteArray &))); | 30 | this, SLOT(recievedStdin(QByteArray &))); |
diff --git a/noncore/apps/opie-console/sz_transfer.h b/noncore/apps/opie-console/sz_transfer.h index 778d1d3..825680d 100644 --- a/noncore/apps/opie-console/sz_transfer.h +++ b/noncore/apps/opie-console/sz_transfer.h | |||
@@ -1,33 +1,39 @@ | |||
1 | #ifndef OPIE_FL_SZ_H | 1 | #ifndef OPIE_FL_SZ_H |
2 | #define OPIE_FL_SZ_H | 2 | #define OPIE_FL_SZ_H |
3 | 3 | ||
4 | #include "file_layer.h" | 4 | #include "file_layer.h" |
5 | #include <opie/oprocess.h> | 5 | #include <opie/oprocess.h> |
6 | 6 | ||
7 | class SzTransfer : public FileTransferLayer { | 7 | class SzTransfer : public FileTransferLayer { |
8 | 8 | ||
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | 10 | ||
11 | public: | 11 | public: |
12 | enum Type { | ||
13 | SZ=0, | ||
14 | SX, | ||
15 | SY | ||
16 | }; | ||
12 | 17 | ||
13 | SzTransfer( IOLayer * ); | 18 | SzTransfer( Type t, IOLayer * ); |
14 | ~SzTransfer(); | 19 | ~SzTransfer(); |
15 | 20 | ||
16 | public slots: | 21 | public slots: |
17 | /** | 22 | /** |
18 | * send a file over the layer | 23 | * send a file over the layer |
19 | */ | 24 | */ |
20 | void sendFile( const QString& file ) = 0; | 25 | void sendFile( const QString& file ) ; |
21 | void sendFile( const QFile& ) = 0; | 26 | void sendFile( const QFile& ); |
22 | 27 | ||
23 | private slots: | 28 | private slots: |
24 | void SzRecievedStdout(OProcess *, char *, int); | 29 | void SzRecievedStdout(OProcess *, char *, int); |
25 | void SzRecievedStderr(OProcess *, char *, int); | 30 | void SzRecievedStderr(OProcess *, char *, int); |
26 | void recievedStdin(QByteArray &); | 31 | void recievedStdin(QByteArray &); |
27 | 32 | ||
28 | private: | 33 | private: |
29 | OProcess *proc; | 34 | OProcess *proc; |
35 | Type m_t; | ||
30 | 36 | ||
31 | }; | 37 | }; |
32 | 38 | ||
33 | #endif | 39 | #endif |