summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/common.h2
-rw-r--r--noncore/apps/opie-console/configdialog.cpp10
-rw-r--r--noncore/apps/opie-console/configdialog.h5
-rw-r--r--noncore/apps/opie-console/default.cpp65
-rw-r--r--noncore/apps/opie-console/default.h30
-rw-r--r--noncore/apps/opie-console/io_layer.h2
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp4
-rw-r--r--noncore/apps/opie-console/metafactory.cpp76
-rw-r--r--noncore/apps/opie-console/metafactory.h60
-rw-r--r--noncore/apps/opie-console/opie-console.pro16
-rw-r--r--noncore/apps/opie-console/profile.cpp21
-rw-r--r--noncore/apps/opie-console/profile.h11
-rw-r--r--noncore/apps/opie-console/profiledialogwidget.cpp32
-rw-r--r--noncore/apps/opie-console/profiledialogwidget.h50
-rw-r--r--noncore/apps/opie-console/profileeditordialog.cpp239
-rw-r--r--noncore/apps/opie-console/profileeditordialog.h25
-rw-r--r--noncore/apps/opie-console/profileeditorplugins.h142
-rw-r--r--noncore/apps/opie-console/profilemanager.cpp6
-rw-r--r--noncore/apps/opie-console/sz_transfer.cpp2
-rw-r--r--noncore/apps/opie-console/sz_transfer.h12
20 files changed, 544 insertions, 266 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
@@ -25,9 +25,9 @@
#include <qcolor.h>
#ifndef BOOL
-typedef int BOOL;
+typedef bool BOOL;
#endif
#ifndef FALSE
#define FALSE 0
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
@@ -28,10 +28,11 @@ Profile ConfigListItem::profile()const {
}
/* Dialog */
-ConfigDialog::ConfigDialog( const Profile::ValueList& lis, QWidget* parent )
- : ConfigureBase( parent, 0, TRUE )
+ConfigDialog::ConfigDialog( const Profile::ValueList& lis, MetaFactory* fa,
+ QWidget* parent )
+ : ConfigureBase( parent, 0, TRUE ), m_fact( fa )
{
//init();
{
Profile::ValueList::ConstIterator it;
@@ -70,9 +71,9 @@ void ConfigDialog::slotEdit() {
// Load profile
p = ((ConfigListItem*)lstView->currentItem())->profile();
- ProfileEditorDialog dlg(new MetaFactory(), p);
+ ProfileEditorDialog dlg(m_fact, p);
dlg.setCaption("Edit Connection Profile");
dlg.showMaximized();
int ret = dlg.exec();
@@ -89,9 +90,10 @@ void ConfigDialog::slotEdit() {
}
void ConfigDialog::slotAdd() {
- ProfileEditorDialog dlg(new MetaFactory());
+ qWarning("slotAdd");
+ ProfileEditorDialog dlg(m_fact);
dlg.setCaption("New Connection");
dlg.showMaximized();
int ret = dlg.exec();
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
@@ -5,19 +5,22 @@
#include "configurebase.h"
#include "profile.h"
+class MetaFactory;
class ConfigDialog : public ConfigureBase {
Q_OBJECT
public:
- ConfigDialog( const Profile::ValueList&, QWidget* parent = 0l);
+ ConfigDialog( const Profile::ValueList&, MetaFactory*, QWidget* parent = 0l);
~ConfigDialog();
Profile::ValueList list()const;
protected slots:
void slotRemove();
void slotEdit();
void slotAdd();
+private:
+ MetaFactory* m_fact;
};
#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 @@
+#include "io_serial.h"
+#include "sz_transfer.h"
+
+#include "default.h"
+
+extern "C" {
+ // FILE Transfer Stuff
+ FileTransferLayer* newSZTransfer(IOLayer* lay) {
+ return new SzTransfer( SzTransfer::SZ, lay );
+ }
+ FileTransferLayer* newSYTransfer(IOLayer* lay) {
+ return new SzTransfer( SzTransfer::SY, lay );
+ }
+ FileTransferLayer* newSXTransfer(IOLayer* lay) {
+ return new SzTransfer( SzTransfer::SX, lay );
+ }
+
+ // Layer stuff
+ IOLayer* newSerialLayer( const Profile& prof) {
+ return new IOSerial( prof );
+ }
+ IOLayer* newBTLayer( const Profile& ) {
+ return 0l;
+ }
+ IOLayer* newIrDaLayer( const Profile& ) {
+ return 0l;
+ }
+
+ // Connection Widgets
+ ProfileDialogWidget* newSerialWidget(const QString& str, QWidget* ) {
+ return 0l;
+ }
+ ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid) {
+ return newSerialWidget(str, wid);
+ }
+ ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid) {
+ return newSerialWidget(str, wid );
+ }
+
+ // Terminal Widget(s)
+ ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ) {
+ return 0l;
+ }
+
+};
+
+Default::Default( MetaFactory* fact ) {
+ fact->addFileTransferLayer( "SZ", QObject::tr("Z-Modem"), newSZTransfer );
+ fact->addFileTransferLayer( "SY", QObject::tr("Y-Modem"), newSYTransfer );
+ fact->addFileTransferLayer( "SX", QObject::tr("X-Modem"), newSXTransfer );
+
+ fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer );
+ fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer );
+ fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer );
+
+ fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget );
+ fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget );
+ fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget );
+
+ fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget );
+
+}
+Default::~Default() {
+
+}
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 @@
+#ifndef OPIE_DEFAULT_H
+#define OPIE_DEFAULT_H
+
+#include "metafactory.h"
+
+extern "C" {
+ FileTransferLayer* newSZTransfer(IOLayer*);
+ FileTransferLayer* newSYTransfer(IOLayer*);
+ FileTransferLayer* newSXTransfer(IOLayer*);
+
+ IOLayer* newSerialLayer(const Profile&);
+ IOLayer* newBTLayer(const Profile& );
+ IOLayer* newIrDaLayer(const Profile& );
+
+ ProfileDialogWidget* newSerialWidget(const QString&, QWidget* );
+ ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* );
+ ProfileDialogWidget* newBTWidget (const QString&, QWidget* );
+
+ ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* );
+};
+
+class MetaFactory;
+struct Default {
+public:
+ Default(MetaFactory* );
+ ~Default();
+};
+
+
+#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
@@ -80,8 +80,8 @@ public slots:
/**
* closes and reloads the settings
*/
- virtual void reload( const Config& ) = 0;
+ virtual void reload( const Profile& ) = 0;
};
#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
@@ -5,15 +5,17 @@
#include <qpopupmenu.h>
#include <qtoolbar.h>
#include "configdialog.h"
+#include "default.h"
#include "metafactory.h"
#include "profilemanager.h"
#include "mainwindow.h"
#include "tabwidget.h"
MainWindow::MainWindow() {
m_factory = new MetaFactory();
+ Default def(m_factory);
m_sessions.setAutoDelete( TRUE );
m_curSession = 0;
m_manager = new ProfileManager( m_factory );
m_manager->load();
@@ -155,9 +157,9 @@ void MainWindow::slotTerminate() {
}
void MainWindow::slotConfigure() {
qWarning("configure");
- ConfigDialog conf( manager()->all() );
+ ConfigDialog conf( manager()->all(), factory() );
conf.showMaximized();
int ret = conf.exec();
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
@@ -5,20 +5,30 @@ MetaFactory::MetaFactory() {
}
MetaFactory::~MetaFactory() {
}
-void MetaFactory::addConfigWidgetFactory( const QString& str,
- const QString& name,
- configWidget wid) {
- m_namemap.insert ( str, name );
- m_confFact.insert( str, wid );
+void MetaFactory::addConnectionWidgetFactory( const QCString& name,
+ const QString& str,
+ configWidget wid) {
+ m_strings.insert( str, name );
+ m_conFact.insert( str, wid );
}
-void MetaFactory::addIOLayerFactory( const QString& str,
+void MetaFactory::addTerminalWidgetFactory( const QCString& name,
+ const QString& str,
+ configWidget wid ) {
+ m_strings.insert( str, name );
+ m_termFact.insert( str, wid );
+}
+void MetaFactory::addIOLayerFactory( const QCString& name,
+ const QString& str,
iolayer lay) {
+ m_strings.insert( str, name );
m_layerFact.insert( str, lay );
}
-void MetaFactory::addFileTransferLayer( const QString& str,
+void MetaFactory::addFileTransferLayer( const QCString& name,
+ const QString& str,
filelayer lay) {
+ m_strings.insert(str, name );
m_fileFact.insert( str, lay );
}
QStringList MetaFactory::ioLayers()const {
QStringList list;
@@ -27,12 +37,20 @@ QStringList MetaFactory::ioLayers()const {
list << it.key();
}
return list;
}
-QStringList MetaFactory::configWidgets()const {
+QStringList MetaFactory::connectionWidgets()const {
+ QStringList list;
+ QMap<QString, configWidget>::ConstIterator it;
+ for ( it = m_conFact.begin(); it != m_conFact.end(); ++it ) {
+ list << it.key();
+ }
+ return list;
+}
+QStringList MetaFactory::terminalWidgets()const {
QStringList list;
QMap<QString, configWidget>::ConstIterator it;
- for ( it = m_confFact.begin(); it != m_confFact.end(); ++it ) {
+ for ( it = m_termFact.begin(); it != m_termFact.end(); ++it ) {
list << it.key();
}
return list;
}
@@ -59,18 +77,38 @@ IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
return lay;
}
-ProfileEditorPlugin *MetaFactory::newConfigPlugin ( const QString& str, QWidget *parent, Profile *prof) {
- ProfileEditorPlugin *p = NULL;
- configWidget c;
+ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) {
+ ProfileDialogWidget* wid = 0l;
- c = m_confFact[str];
- if(c) p = c(parent, prof);
-
- return p;
+ QMap<QString, configWidget>::Iterator it;
+ it = m_conFact.find( str );
+ if ( it != m_conFact.end() ) {
+ wid = (*(it.data() ) )(str,parent);
+ }
+ return wid;
}
+ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget *parent) {
+ if (str.isEmpty() )
+ return 0l;
+ ProfileDialogWidget* wid = 0l;
+ qWarning("new terminalPlugin %s %l", str.latin1(), parent );
-QString MetaFactory::name( const QString& str ) {
- return m_namemap[str];
+ QMap<QString, configWidget>::Iterator it;
+ it = m_termFact.find( str );
+ if ( it != m_conFact.end() ) {
+ wid = (*(it.data() ) )(str,parent);
+ }
+ return wid;
+}
+QCString MetaFactory::internal( const QString& str )const {
+ return m_strings[str];
+}
+QString MetaFactory::external( const QCString& str )const {
+ QMap<QString, QCString>::ConstIterator it;
+ for ( it = m_strings.begin(); it != m_strings.end(); ++it ) {
+ if ( it.data() == str )
+ return it.key();
+ }
+ return QString::null;
}
-
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
@@ -13,39 +13,73 @@
#include "io_layer.h"
#include "file_layer.h"
#include "profile.h"
-#include "profileeditorplugins.h"
+#include "profiledialogwidget.h"
class MetaFactory {
public:
- typedef ProfileEditorPlugin* (*configWidget)(QWidget* parent, Profile* prof);
+ typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent);
typedef IOLayer* (*iolayer)(const Profile& );
typedef FileTransferLayer* (*filelayer)(IOLayer*);
MetaFactory();
~MetaFactory();
- void addConfigWidgetFactory( const QString&,
- const QString&,
- configWidget );
- void addIOLayerFactory(const QString&,
- iolayer );
- void addFileTransferLayer( const QString&,
+ /**
+ * add a ProfileDialogWidget to the factory
+ * name is the name shown to the user
+ */
+ void addConnectionWidgetFactory( const QCString& internalName,
+ const QString& uiString,
+ configWidget );
+ void addTerminalWidgetFactory ( const QCString& internalName,
+ const QString& name,
+ configWidget );
+
+ /**
+ * adds an IOLayer factory
+ */
+ void addIOLayerFactory( const QCString&,
+ const QString&,
+ iolayer );
+
+ /**
+ * adds a FileTransfer Layer
+ */
+ void addFileTransferLayer( const QCString& name,
+ const QString&,
filelayer );
+
+ /* translated UI Strings */
QStringList ioLayers()const;
- QStringList configWidgets()const;
+ QStringList connectionWidgets()const;
+ QStringList terminalWidgets()const;
QStringList fileTransferLayers()const;
IOLayer* newIOLayer( const QString&,const Profile& );
- ProfileEditorPlugin *newConfigPlugin ( const QString&, QWidget*, Profile* );
+ ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* );
+ ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* );
+
+ /*
+ * internal takes the maybe translated
+ * public QString and maps it to the internal
+ * not translatable QCString
+ */
+ QCString internal( const QString& )const;
+
+ /*
+ * external takes the internal name
+ * it returns a translated name
+ */
+ QString external( const QCString& )const;
- QString name( const QString& );
private:
- QMap<QString, configWidget> m_confFact;
+ QMap<QString, QCString> m_strings;
+ QMap<QString, configWidget> m_conFact;
+ QMap<QString, configWidget> m_termFact;
QMap<QString, iolayer> m_layerFact;
QMap<QString, filelayer> m_fileFact;
- QMap<QString, QString> m_namemap;
};
#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
@@ -12,41 +12,43 @@ HEADERS = io_layer.h io_serial.h \
profilemanager.h \
configwidget.h \
tabwidget.h \
configdialog.h \
- profileeditordialog.h \
- profileeditorplugins.h \
emulation_layer.h \
widget.h \
vt102emulation.h \
common.h \
history.h \
screen.h \
keytrans.h \
widget_layer.h \
- transferdialog.h
+ transferdialog.h \
+ profiledialogwidget.h \
+ profileeditordialog.h \
+ default.h
SOURCES = io_layer.cpp io_serial.cpp \
file_layer.cpp sz_transfer.cpp \
- main.cpp \
+ main.cpp \
metafactory.cpp \
session.cpp \
mainwindow.cpp \
profile.cpp \
profileconfig.cpp \
profilemanager.cpp \
tabwidget.cpp \
configdialog.cpp \
- profileeditordialog.cpp \
- profileeditorplugins.cpp \
emulation_layer.cpp \
widget.cpp \
vt102emulation.cpp \
history.cpp \
screen.cpp \
keytrans.cpp \
widget_layer.cpp \
- transferdialog.cpp
+ transferdialog.cpp \
+ profiledialogwidget.cpp \
+ profileeditordialog.cpp \
+ default.cpp
INTERFACES = configurebase.ui editbase.ui
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
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
@@ -3,16 +3,16 @@
Profile::Profile() {
}
Profile::Profile( const QString& name,
- const QString& iolayerName,
+ const QCString& iolayerName,
+ const QCString& termName,
int background,
int foreground,
int terminal )
- : m_name( name ), m_ioLayer( iolayerName ), m_back( background ),
- m_fore( foreground ), m_terminal( terminal )
-{
-}
+ : m_name( name ), m_ioLayer( iolayerName ), m_term( termName),
+ m_back( background ), m_fore( foreground ), m_terminal( terminal )
+{}
Profile::Profile( const Profile& prof )
{
(*this) = prof;
}
@@ -27,8 +27,9 @@ Profile &Profile::operator=( const Profile& prof ) {
m_back = prof.m_back;
m_fore = prof.m_fore;
m_terminal = prof.m_terminal;
m_conf = prof.m_conf;
+ m_term = prof.m_term;
return *this;
}
Profile::~Profile() {
@@ -38,11 +39,14 @@ QMap<QString, QString> Profile::conf()const {
}
QString Profile::name()const {
return m_name;
}
-QString Profile::ioLayerName()const {
+QCString Profile::ioLayerName()const {
return m_ioLayer;
}
+QCString Profile::terminalName( )const {
+ return m_term;
+}
int Profile::foreground()const {
return m_fore;
}
int Profile::background()const {
@@ -53,11 +57,14 @@ int Profile::terminal()const {
}
void Profile::setName( const QString& str ) {
m_name = str;
}
-void Profile::setIOLayer( const QString& name ) {
+void Profile::setIOLayer( const QCString& name ) {
m_ioLayer = name;
}
+void Profile::setTerminalName( const QCString& str ) {
+ m_term = str;
+}
void Profile::setBackground( int back ) {
m_back = back;
}
void Profile::setForeground( int fore ) {
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
@@ -21,9 +21,10 @@ public:
enum Terminal {VT102 = 0 };
enum Font { Micro = 0, Small, Medium };
Profile();
Profile( const QString& name,
- const QString& iolayerName,
+ const QCString& iolayerName,
+ const QCString& termName,
int background,
int foreground,
int terminal);
Profile( const Profile& );
@@ -31,9 +32,10 @@ public:
bool operator==( const Profile& prof );
~Profile();
QString name()const;
- QString ioLayerName()const;
+ QCString ioLayerName()const;
+ QCString terminalName()const;
int foreground()const;
int background()const;
int terminal()const;
@@ -50,17 +52,18 @@ public:
int readNumEntry( const QString& key, int = -1 )const;
bool readBoolEntry( const QString& key, bool = FALSE )const;
void setName( const QString& );
- void setIOLayer( const QString& );
+ void setIOLayer( const QCString& );
+ void setTerminalName( const QCString& );
void setBackground( int back );
void setForeground( int fore );
void setTerminal( int term );
void setConf( const QMap<QString, QString>& );
private:
QMap<QString, QString> m_conf;
QString m_name;
- QString m_ioLayer;
+ QCString m_ioLayer, m_term;
int m_back;
int m_fore;
int m_terminal;
};
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 @@
+#include "profiledialogwidget.h"
+
+ProfileDialogWidget::ProfileDialogWidget( const QString&, QWidget* parent,
+ const char* name )
+ : QWidget( parent, name ) {
+}
+ProfileDialogWidget::~ProfileDialogWidget() {
+}
+
+ProfileDialogTerminalWidget::ProfileDialogTerminalWidget( const QString& na,
+ QWidget* parent,
+ const char* name )
+ : ProfileDialogWidget( na, parent, name )
+{
+}
+ProfileDialogTerminalWidget::~ProfileDialogTerminalWidget() {
+}
+ProfileDialogWidget::Type ProfileDialogTerminalWidget::type()const {
+ return Terminal;
+}
+
+ProfileDialogConnectionWidget::ProfileDialogConnectionWidget( const QString& na,
+ QWidget* parent,
+ const char* name )
+ : ProfileDialogWidget(na, parent, name )
+{
+}
+ProfileDialogConnectionWidget::~ProfileDialogConnectionWidget() {
+}
+ProfileDialogWidget::Type ProfileDialogConnectionWidget::type()const {
+ return Connection;
+}
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 @@
+#ifndef OPIE_PROFILE_DIALOG_WIDGET_H
+#define OPIE_PROFILE_DIALOG_WIDGET_H
+
+#include <qwidget.h>
+
+#include "profile.h"
+
+class ProfileDialogWidget : public QWidget {
+ Q_OBJECT
+public:
+ enum Type {
+ Connection,
+ Terminal
+ };
+ ProfileDialogWidget( const QString& name, QWidget* parent, const char* name = 0l);
+ ~ProfileDialogWidget();
+
+ /*
+ * load data from a Profile into
+ * the DialogWidget
+ */
+ virtual void load( const Profile& ) = 0;
+
+ /*
+ * save data into a profile
+ * from the DialogWidget
+ */
+ virtual void save( Profile& ) = 0;
+
+ virtual Type type()const = 0;
+};
+class ProfileDialogTerminalWidget : public ProfileDialogWidget {
+ Q_OBJECT
+public:
+ ProfileDialogTerminalWidget( const QString& name, QWidget* widget,
+ const char* name =0l);
+ ~ProfileDialogTerminalWidget();
+ Type type()const;
+};
+class ProfileDialogConnectionWidget : public ProfileDialogWidget {
+ Q_OBJECT
+public:
+ ProfileDialogConnectionWidget( const QString& name, QWidget* parent,
+ const char* name =0l);
+ ~ProfileDialogConnectionWidget();
+ Type type() const;
+
+};
+
+#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,17 +1,29 @@
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qmessagebox.h>
+#include <qstringlist.h>
+#include <qcombobox.h>
-#include <opie/otabwidget.h>
-#include "profileeditordialog.h"
-#include "qlayout.h"
-#include "qlineedit.h"
-#include "qlabel.h"
-#include "qmessagebox.h"
-#include "qstringlist.h"
-#include "qcombobox.h"
+#include <opie/otabwidget.h>
#include "profileeditorplugins.h"
#include "metafactory.h"
+#include "profileeditordialog.h"
+
+namespace {
+ void setCurrent( const QString& str, QComboBox* bo ) {
+ for (uint i = 0; i < bo->count(); i++ ) {
+ if ( bo->text(i) == str ) {
+ bo->setCurrentItem( i );
+ }
+ }
+ }
+
+
+}
ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
const Profile& prof )
: QDialog(0, 0, TRUE), m_fact( fact ), m_prof( prof )
@@ -26,9 +38,9 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact,
ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact )
: QDialog(0, 0, TRUE), m_fact( fact )
{
// Default profile
- m_prof = Profile(QString::null, "serial", Profile::Black, Profile::White, Profile::VT102);
+ m_prof = Profile("New Profile", "serial", "default", Profile::Black, Profile::White, Profile::VT102);
initUI();
// Apply current profile
@@ -41,149 +53,138 @@ Profile ProfileEditorDialog::profile() const
}
void ProfileEditorDialog::initUI()
{
+ m_con = m_term = 0l;
QVBoxLayout *mainLayout = new QVBoxLayout( this );
OTabWidget *tabWidget = new OTabWidget( this );
mainLayout->add(tabWidget);
- QWidget *tabterm, *tabconn, *tabprof;
-
- tabprof = new QWidget(this);
- tabterm = new QWidget(this);
- tabconn = new QWidget(this);
-
- // for the time being: fake factory
-
- m_fact->addConfigWidgetFactory("serial", QObject::tr("Serial cable"), factory_serial);
- m_fact->addConfigWidgetFactory("irda", QObject::tr("IrDA port"), factory_irda);
- m_fact->addConfigWidgetFactory("modem", QObject::tr("Serial via modem"), factory_modem);
-
- // profile tab
-
- QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
-
- name_line = new QLineEdit(tabprof);
-
- // connection tab, fixed part
-
- QLabel *device = new QLabel(QObject::tr("Device"), tabconn);
-
- device_box = new QComboBox(tabconn);
-
- QStringList w = m_fact->configWidgets();
- for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
- device_box->insertItem(m_fact->name((*it)));
-
- // connection tab, factory part
- plugin_base = new QWidget(tabconn);
- plugin_layout = new QHBoxLayout(plugin_base, 0);
-
- plugin_plugin = m_fact->newConfigPlugin("serial", plugin_base, &m_prof);
- plugin_layout->add(plugin_plugin->widget());
-
- // connection tab, general part
+ QWidget *tabprof;
+
+ /* base tabs */
+ tabprof = new QWidget(this);
+ m_tabTerm = new QWidget(this);
+ m_tabCon = new QWidget(this);
+
+ /* base layout for tabs */
+ m_layCon = new QHBoxLayout( m_tabCon , 2 );
+ m_layTerm = new QHBoxLayout( m_tabTerm, 2 );
+
+ // profile tab
+
+ QLabel *name = new QLabel(QObject::tr("Profile name"), tabprof);
+ m_name = new QLineEdit(tabprof);
+ QLabel *con = new QLabel(tr("Connection"), tabprof );
+ QLabel *term = new QLabel(tr("Terminal"), tabprof );
+ m_conCmb = new QComboBox( tabprof );
+ m_termCmb = new QComboBox( tabprof );
+
+ // layouting
+ QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
+ vbox3->add(name);
+ vbox3->add(m_name);
+ vbox3->add(con );
+ vbox3->add(m_conCmb );
+ vbox3->add(term );
+ vbox3->add(m_termCmb );
+ vbox3->addStretch(1);
+
+ tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
+ tabWidget->addTab(m_tabCon, "", QObject::tr("Connection"));
+ tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal"));
+ tabWidget->setCurrentTab( tabprof );
+
+
+ // fill the comboboxes
+ QStringList list = m_fact->connectionWidgets();
+ QStringList::Iterator it;
+ for (it =list.begin(); it != list.end(); ++it ) {
+ m_conCmb->insertItem( (*it) );
+ }
+ list = m_fact->terminalWidgets();
+ for (it =list.begin(); it != list.end(); ++it ) {
+ m_termCmb->insertItem( (*it) );
+ }
+
+ // load profile values
+ m_name->setText(m_prof.name());
+ slotConActivated( m_fact->external(m_prof.ioLayerName() ) );
+ slotTermActivated( m_fact->external(m_prof.terminalName() ) );
+ setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb );
+ setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb );
+
+ qWarning("Layer: %s %s", m_prof.ioLayerName().data(),
+ m_fact->external(m_prof.ioLayerName() ).latin1() );
+ qWarning("Term: %s %s", m_prof.terminalName().data(),
+ m_fact->external(m_prof.terminalName() ).latin1() );
+
+ // signal and slots
+ connect(m_conCmb, SIGNAL(activated(const QString& ) ),
+ this, SLOT(slotConActivated(const QString&) ) );
+ connect(m_termCmb, SIGNAL(activated(const QString& ) ),
+ this, SLOT(slotTermActivated(const QString& ) ) );
- QWidget *conn_widget = plugin_plugin->connection_widget();
- conn_widget->reparent(tabconn, 0, QPoint(), true);
-
- // terminal tab
-
- QWidget *term_widget = plugin_plugin->terminal_widget();
- term_widget->reparent(tabterm, 0, QPoint(), true);
-
- // layouting
-
- QVBoxLayout *vbox3 = new QVBoxLayout(tabprof, 2);
- vbox3->add(name);
- vbox3->add(name_line);
- vbox3->addStretch(1);
-
- QVBoxLayout *vbox = new QVBoxLayout(tabconn, 2);
- vbox->add(device);
- vbox->add(device_box);
- vbox->add(plugin_base);
- vbox->add(conn_widget);
- vbox->setStretchFactor(device, 1);
- vbox->setStretchFactor(device_box, 1);
- vbox->setStretchFactor(plugin_base, 1);
- vbox->setStretchFactor(conn_widget, 7);
-
- QVBoxLayout *vbox2 = new QVBoxLayout(tabterm, 2);
- vbox2->add(term_widget);
-
- tabWidget->addTab(tabprof, "", QObject::tr("Profile"));
- tabWidget->addTab(tabconn, "", QObject::tr("Connection"));
- tabWidget->addTab(tabterm, "", QObject::tr("Terminal"));
- tabWidget->setCurrentTab( tabprof );
-
- // load profile values
- name_line->setText(m_prof.name());
- for(int i = 0; i < device_box->count(); i++)
- {
- device_box->setCurrentItem(i);
- if(prof_type() == m_prof.ioLayerName())
- {
- slotDevice(i);
- break;
- }
- }
-
- // signals
- connect(device_box, SIGNAL(activated(int)), SLOT(slotDevice(int)));
}
ProfileEditorDialog::~ProfileEditorDialog() {
}
-
-void ProfileEditorDialog::slotDevice(int id)
-{
- delete plugin_plugin;
-
- plugin_plugin = m_fact->newConfigPlugin(prof_type(), plugin_base, &m_prof);
- plugin_layout->add(plugin_plugin->widget());
-
- // Reload profile associated to device, including e.g. conn_device()
- // m_prof = plugin_plugin->profile()
- // or, keeping the profile name: m_prof->reload(plugin_plugin->profile())
-
- //plugin_plugin->show();
- plugin_plugin->widget()->show();
-}
-
void ProfileEditorDialog::accept()
{
- if(prof_name().isEmpty())
+ if(profName().isEmpty())
{
QMessageBox::information(this,
QObject::tr("Invalid profile"),
QObject::tr("Please enter a profile name."));
return;
}
// Save profile and plugin profile
- if(plugin_plugin) plugin_plugin->save();
+ //if(plugin_plugin) plugin_plugin->save();
// Save general values
- m_prof.setName(prof_name());
- m_prof.setIOLayer(prof_type());
+ m_prof.setName(profName());
+ m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) );
+ m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) );
+ qWarning("Term %s %s", m_fact->internal(m_termCmb->currentText() ).data(),
+ m_termCmb->currentText().latin1() );
QDialog::accept();
}
-QString ProfileEditorDialog::prof_name()
+QString ProfileEditorDialog::profName()const
{
- return name_line->text();
+ return m_name->text();
}
-QString ProfileEditorDialog::prof_type()
+QCString ProfileEditorDialog::profType()const
{
- QStringList w = m_fact->configWidgets();
+ /*QStringList w = m_fact->configWidgets();
for(QStringList::Iterator it = w.begin(); it != w.end(); it++)
if(device_box->currentText() == m_fact->name((*it))) return (*it);
-
- return QString::null;
+ */
+ return QCString();
+}
+/*
+ * we need to switch the widget
+ */
+void ProfileEditorDialog::slotConActivated( const QString& str ) {
+ delete m_con;
+ m_con = m_fact->newConnectionPlugin( str, m_tabCon );
+
+ if (m_con )
+ m_layCon->addWidget( m_con );
+}
+/*
+ * we need to switch the widget
+ */
+void ProfileEditorDialog::slotTermActivated( const QString& str ) {
+ delete m_term;
+ m_term = m_fact->newTerminalPlugin( str, 0l );
+ qWarning("past");
+
+ if (m_term)
+ m_layTerm->addWidget( m_term );
}
-
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
@@ -11,40 +11,41 @@ class QTabWidget;
class QHBoxLayout;
class QLineEdit;
class QComboBox;
class QLabel;
-class ProfileEditorPlugin;
+class ProfileDialogWidget;
class ProfileEditorDialog : public QDialog {
Q_OBJECT
public:
ProfileEditorDialog(MetaFactory* fact,
const Profile& prof );
ProfileEditorDialog(MetaFactory* fact );
- ~ProfileEditorDialog();
+ ~ProfileEditorDialog();
Profile profile()const;
- QString prof_name();
- QString prof_type();
+
public slots:
void accept();
- void slotDevice(int id);
+private slots:
+ void slotConActivated(const QString& );
+ void slotTermActivated( const QString& );
private:
void initUI();
+ QString profName()const;
+ QCString profType()const;
MetaFactory* m_fact;
- EditBase* m_base;
- QTabWidget* m_tab;
QHBoxLayout* m_lay;
Profile m_prof;
- QLineEdit *name_line;
- QComboBox *device_box;
+ QLineEdit *m_name;
+ QComboBox *m_conCmb, *m_termCmb;
- QWidget *plugin_base;
- ProfileEditorPlugin *plugin_plugin;
- QHBoxLayout *plugin_layout;
+ QWidget *m_tabCon, *m_tabTerm;
+ ProfileDialogWidget* m_con, *m_term;
+ QHBoxLayout *m_layCon, *m_layTerm;
};
#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
@@ -2,84 +2,84 @@
#define PROFILE_EDITOR_PLUGINS_H
#include "profile.h"
-#include "qobject.h"
+#include <qobject.h>
class QWidget;
class ProfileEditorPlugin : public QObject
{
- Q_OBJECT
- public:
- ProfileEditorPlugin(QWidget *parent, Profile *p);
-
- virtual ~ProfileEditorPlugin();
-
- virtual void save() = 0;
-
- virtual QWidget *widget() = 0;
-
- QWidget *connection_widget();
- QWidget *terminal_widget();
-
- public slots:
- void slotConnFlow(int id);
- void slotConnParity(int id);
- void slotConnSpeed(int id);
- void slotTermTerm(int id);
- void slotTermColour(int id);
- void slotTermFont(int id);
- void slotTermEcho(bool on);
- void slotTermWrap(bool on);
- void slotTermInbound(bool on);
- void slotTermOutbound(bool on);
-
- protected:
- QWidget *m_parent, *m_widget;
- Profile *m_profile;
-
- private:
- enum ParityIds
- {
- id_parity_odd,
- id_parity_even
- };
-
- enum FlowIds
- {
- id_flow_hw,
- id_flow_sw
- };
-
- enum SpeedIds
- {
- id_baud_115200,
- id_baud_57600,
- id_baud_38400,
- id_baud_19200,
- id_baud_9600
- };
-
- enum TermIds
- {
- id_term_vt100,
- id_term_vt220,
- id_term_ansi
- };
-
- enum ColourIds
- {
- id_term_black,
- id_term_white
- };
-
- enum FontIds
- {
- id_size_small,
- id_size_medium,
- id_size_large
- };
+ Q_OBJECT
+public:
+ ProfileEditorPlugin(QWidget *parent);
+
+ virtual ~ProfileEditorPlugin();
+
+ virtual void save() = 0;
+
+ virtual QWidget *widget() = 0;
+
+ QWidget *connection_widget();
+ QWidget *terminal_widget();
+
+public slots:
+ void slotConnFlow(int id);
+ void slotConnParity(int id);
+ void slotConnSpeed(int id);
+ void slotTermTerm(int id);
+ void slotTermColour(int id);
+ void slotTermFont(int id);
+ void slotTermEcho(bool on);
+ void slotTermWrap(bool on);
+ void slotTermInbound(bool on);
+ void slotTermOutbound(bool on);
+
+protected:
+ QWidget *m_parent, *m_widget;
+ Profile *m_profile;
+
+private:
+ enum ParityIds
+ {
+ id_parity_odd,
+ id_parity_even
+ };
+
+ enum FlowIds
+ {
+ id_flow_hw,
+ id_flow_sw
+ };
+
+ enum SpeedIds
+ {
+ id_baud_115200,
+ id_baud_57600,
+ id_baud_38400,
+ id_baud_19200,
+ id_baud_9600
+ };
+
+ enum TermIds
+ {
+ id_term_vt100,
+ id_term_vt220,
+ id_term_ansi
+ };
+
+ enum ColourIds
+ {
+ id_term_black,
+ id_term_white
+ };
+
+ enum FontIds
+ {
+ id_size_small,
+ id_size_medium,
+ id_size_large
+ };
};
//#ifdef __cplusplus
//extern "C" {
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
@@ -27,9 +27,10 @@ void ProfileManager::load() {
qWarning("group " + (*it) );
conf.setGroup( (*it) );
Profile prof;
prof.setName( conf.readEntry("name") );
- prof.setIOLayer( conf.readEntry("iolayer") );
+ prof.setIOLayer( conf.readEntry("iolayer").utf8() );
+ prof.setTerminalName( conf.readEntry("term").utf8() );
prof.setBackground( conf.readNumEntry("back") );
prof.setForeground( conf.readNumEntry("fore") );
prof.setTerminal( conf.readNumEntry("terminal") );
prof.setConf( conf.items( (*it) ) );
@@ -64,9 +65,10 @@ void ProfileManager::save( ) {
Profile::ValueList::Iterator it;
for (it = m_list.begin(); it != m_list.end(); ++it ) {
conf.setGroup( (*it).name() );
conf.writeEntry( "name", (*it).name() );
- conf.writeEntry( "ioplayer", (*it).ioLayerName() );
+ conf.writeEntry( "ioplayer", QString::fromUtf8( (*it).ioLayerName() ) );
+ conf.writeEntry( "term", QString::fromUtf8( (*it).terminalName() ) );
conf.writeEntry( "back", (*it).background() );
conf.writeEntry( "fore", (*it).foreground() );
conf.writeEntry( "terminal", (*it).terminal() );
/* now the config stuff */
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
@@ -2,9 +2,9 @@
#include "sz_transfer.h"
#include <qfile.h>
#include <opie/oprocess.h>
-SzTransfer::SzTransfer(IOLayer *layer) : FileTransferLayer(layer)
+SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t)
{
}
SzTransfer::~SzTransfer() {
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
@@ -8,26 +8,32 @@ class SzTransfer : public FileTransferLayer {
Q_OBJECT
public:
+ enum Type {
+ SZ=0,
+ SX,
+ SY
+ };
- SzTransfer( IOLayer * );
+ SzTransfer( Type t, IOLayer * );
~SzTransfer();
public slots:
/**
* send a file over the layer
*/
- void sendFile( const QString& file ) = 0;
- void sendFile( const QFile& ) = 0;
+ void sendFile( const QString& file ) ;
+ void sendFile( const QFile& );
private slots:
void SzRecievedStdout(OProcess *, char *, int);
void SzRecievedStderr(OProcess *, char *, int);
void recievedStdin(QByteArray &);
private:
OProcess *proc;
+ Type m_t;
};
#endif