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
@@ -1,114 +1,114 @@
/* -------------------------------------------------------------------------- */
/* */
/* [TECommon.h] Common Definitions */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Copyright (c) 1997,1998 by Lars Doelle <lars.doelle@on-line.de> */
/* */
/* This file is part of Konsole - an X terminal for KDE */
/* */
/* -------------------------------------------------------------------------- */
/* */
/* Ported Konsole to Qt/Embedded */
/* */
/* Copyright (C) 2000 by John Ryland <jryland@trolltech.com> */
/* */
/* -------------------------------------------------------------------------- */
/*! \file TECommon.h
\brief Definitions shared between TEScreen and TEWidget.
*/
#ifndef TECOMMON_H
#define TECOMMON_H
#include <qcolor.h>
#ifndef BOOL
-typedef int BOOL;
+typedef bool BOOL;
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef UINT8
typedef unsigned char UINT8;
#endif
#ifndef UINT16
typedef unsigned short UINT16;
#endif
// Attributed Character Representations ///////////////////////////////
// Colors
#define BASE_COLORS (2+8)
#define INTENSITIES 2
#define TABLE_COLORS (INTENSITIES*BASE_COLORS)
#define DEFAULT_FORE_COLOR 0
#define DEFAULT_BACK_COLOR 1
#define DEFAULT_RENDITION 0
#define RE_BOLD (1 << 0)
#define RE_BLINK (1 << 1)
#define RE_UNDERLINE (1 << 2)
#define RE_REVERSE (1 << 3) // Screen only
#define RE_INTENSIVE (1 << 3) // Widget only
/*! \class Character
* \brief a character with rendition attributes.
*/
class Character
{
public:
inline Character(UINT16 _c = ' ',
UINT8 _f = DEFAULT_FORE_COLOR,
UINT8 _b = DEFAULT_BACK_COLOR,
UINT8 _r = DEFAULT_RENDITION)
: c(_c), f(_f), b(_b), r(_r) {}
public:
UINT16 c; // character
UINT8 f; // foreground color
UINT8 b; // background color
UINT8 r; // rendition
public:
friend BOOL operator == (Character a, Character b);
friend BOOL operator != (Character a, Character b);
};
inline BOOL operator == (Character a, Character b)
{
return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r;
}
inline BOOL operator != (Character a, Character b)
{
return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r;
}
/*!
*/
struct ColorEntry
{
ColorEntry(QColor c, bool tr, bool b) : color(c), transparent(tr), bold(b) {}
ColorEntry() : transparent(false), bold(false) {} // default constructors
void operator=(const ColorEntry& rhs) {
color = rhs.color;
transparent = rhs.transparent;
bold = rhs.bold;
}
QColor color;
bool transparent; // if used on bg
bool bold; // if used on fg
};
#endif // TECOMMON_H
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
@@ -1,112 +1,114 @@
#include "profile.h"
#include "qlistview.h"
#include "configdialog.h"
#include "profileeditordialog.h"
#include "metafactory.h"
#include "qdialog.h"
class ConfigListItem : public QListViewItem {
public:
ConfigListItem( QListView* item, const Profile& );
~ConfigListItem();
Profile profile()const;
private:
Profile m_prof;
};
ConfigListItem::ConfigListItem( QListView* item, const Profile& prof )
: QListViewItem( item ), m_prof( prof )
{
setText(0, prof.name() );
}
ConfigListItem::~ConfigListItem() {
}
Profile ConfigListItem::profile()const {
return m_prof;
}
/* 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;
for (it = lis.begin(); it != lis.end(); ++it ) {
new ConfigListItem( lstView, (*it) );
}
}
}
ConfigDialog::~ConfigDialog() {
}
Profile::ValueList ConfigDialog::list()const {
/* iterate over the list */
Profile::ValueList lst;
QListViewItemIterator it(lstView);
for ( ; it.current(); ++it ) {
ConfigListItem* item = (ConfigListItem*)it.current();
lst.append( item->profile() );
}
return lst;
}
/* our slots */
void ConfigDialog::slotRemove() {
ConfigListItem* item = (ConfigListItem*)lstView->currentItem();
if (!item )
return;
lstView->takeItem( item );
delete item;
}
void ConfigDialog::slotEdit() {
Profile p;
if(!lstView->currentItem()) return;
// 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();
if(ret == QDialog::Accepted)
{
if(lstView->currentItem()) delete lstView->currentItem();
// use dlg.terminal()!
Profile p = dlg.profile();
new ConfigListItem(lstView, p);
}
}
void ConfigDialog::slotAdd() {
- ProfileEditorDialog dlg(new MetaFactory());
+ qWarning("slotAdd");
+ ProfileEditorDialog dlg(m_fact);
dlg.setCaption("New Connection");
dlg.showMaximized();
int ret = dlg.exec();
if(ret == QDialog::Accepted)
{
// TODO: Move into general profile save part
// assignments
//QString type = dlg.term_type();
//if(type == "VT102") profile = Profile::VT102;
// get profile from editor
Profile p = dlg.profile();
new ConfigListItem(lstView, p);
}
}
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 @@
#ifndef OPIE_CONFIG_DIALOG_H
#define OPIE_CONFIG_DIALOG_H
#include <qdialog.h>
#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
@@ -1,87 +1,87 @@
#ifndef OPIE_IO_LAYER_H
#define OPIE_IO_LAYER_H
#include <qobject.h>
#include <qpe/config.h>
#include "profile.h"
/**
* This is the base class for IO Layers
* It will used to sent and recv data( QByteArray )
* it
*/
class IOLayer : public QObject {
Q_OBJECT
public:
enum Error {
NoError = -1,
Refuse = 0,
CouldNotOpen =1,
ClosedUnexpected =2,
ClosedError =3,
Terminate = 4
/* add more errors here */
};
/**
* a small c'tor
*/
IOLayer();
/**
* create an IOLayer instance from a config file
* the currently set group stores the profile/session
* information
*/
IOLayer( const Profile& );
/**
* destructor
*/
virtual ~IOLayer();
/**
* a small internal identifier
*/
virtual QString identifier() const = 0;
/**
* a short name
*/
virtual QString name() const = 0;
signals:
/**
* received input as QCString
*/
virtual void received( const QByteArray& ) = 0;
/**
* an error occured
* int for the error number
* and QString for a text
*/
virtual void error( int, const QString& ) = 0;
public slots:
/**
* send a QCString to the device
*/
virtual void send( const QByteArray& ) = 0;
/**
* bool open
*/
virtual bool open() = 0;
/**
* close the io
*/
virtual void close() = 0;
/**
* 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
@@ -1,176 +1,178 @@
#include <qaction.h>
#include <qmenubar.h>
#include <qlabel.h>
#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();
initUI();
populateProfiles();
}
void MainWindow::initUI() {
setToolBarsMovable( FALSE );
m_tool = new QToolBar( this );
m_tool->setHorizontalStretchable( TRUE );
m_bar = new QMenuBar( m_tool );
m_console = new QPopupMenu( this );
m_sessionsPop= new QPopupMenu( this );
m_settings = new QPopupMenu( this );
/*
* new Action for new sessions
*/
QAction* a = new QAction();
a->setText( tr("New Connection") );
a->addTo( m_console );
connect(a, SIGNAL(activated() ),
this, SLOT(slotNew() ) );
/*
* connect action
*/
m_connect = new QAction();
m_connect->setText( tr("Connect") );
m_connect->addTo( m_console );
connect(m_connect, SIGNAL(activated() ),
this, SLOT(slotConnect() ) );
/*
* disconnect action
*/
m_disconnect = new QAction();
m_disconnect->setText( tr("Disconnect") );
m_disconnect->addTo( m_console );
connect(m_disconnect, SIGNAL(activated() ),
this, SLOT(slotDisconnect() ) );
/*
* terminate action
*/
m_terminate = new QAction();
m_terminate->setText( tr("Terminate") );
m_terminate->addTo( m_console );
connect(m_disconnect, SIGNAL(activated() ),
this, SLOT(slotTerminate() ) );
a = new QAction();
a->setText( tr("Close Window") );
a->addTo( m_console );
connect(a, SIGNAL(activated() ),
this, SLOT(slotClose() ) );
/*
* the settings action
*/
m_setProfiles = new QAction();
m_setProfiles->setText( tr("Configure Profiles") );
m_setProfiles->addTo( m_settings );
connect( m_setProfiles, SIGNAL(activated() ),
this, SLOT(slotConfigure() ) );
/* insert the submenu */
m_console->insertItem(tr("New from Profile"), m_sessionsPop,
-1, 0);
/* insert the connection menu */
m_bar->insertItem( tr("Connection"), m_console );
/* the settings menu */
m_bar->insertItem( tr("Settings"), m_settings );
/*
* connect to the menu activation
*/
connect( m_sessionsPop, SIGNAL(activated( int ) ),
this, SLOT(slotProfile( int ) ) );
m_consoleWindow = new TabWidget( this, "blah");
setCentralWidget( m_consoleWindow );
}
ProfileManager* MainWindow::manager() {
return m_manager;
}
void MainWindow::populateProfiles() {
m_sessionsPop->clear();
Profile::ValueList list = manager()->all();
for (Profile::ValueList::Iterator it = list.begin(); it != list.end(); ++it ) {
m_sessionsPop->insertItem( (*it).name() );
}
}
MainWindow::~MainWindow() {
delete m_factory;
}
MetaFactory* MainWindow::factory() {
return m_factory;
}
Session* MainWindow::currentSession() {
return m_curSession;
}
QList<Session> MainWindow::sessions() {
return m_sessions;
}
void MainWindow::slotNew() {
qWarning("New Connection");
}
void MainWindow::slotConnect() {
if ( currentSession() )
currentSession()->layer()->open();
}
void MainWindow::slotDisconnect() {
if ( currentSession() )
currentSession()->layer()->close();
}
void MainWindow::slotTerminate() {
if ( currentSession() )
currentSession()->layer()->close();
delete m_curSession;
m_curSession = 0l;
/* FIXME move to the next session */
}
void MainWindow::slotConfigure() {
qWarning("configure");
- ConfigDialog conf( manager()->all() );
+ ConfigDialog conf( manager()->all(), factory() );
conf.showMaximized();
int ret = conf.exec();
if ( QDialog::Accepted == ret ) {
manager()->setProfiles( conf.list() );
populateProfiles();
}
}
void MainWindow::slotClose() {
}
void MainWindow::slotProfile( int ) {
}
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 @@
#include <qpe/config.h>
#include "metafactory.h"
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;
QMap<QString, iolayer>::ConstIterator it;
for (it = m_layerFact.begin(); it != m_layerFact.end(); ++it ) {
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;
}
QStringList MetaFactory::fileTransferLayers()const {
QStringList list;
QMap<QString, filelayer>::ConstIterator it;
for ( it = m_fileFact.begin(); it != m_fileFact.end(); ++it ) {
list << it.key();
}
return list;
}
IOLayer* MetaFactory::newIOLayer( const QString& str,const Profile& prof ) {
IOLayer* lay = 0l;
QMap<QString, iolayer>::Iterator it;
it = m_layerFact.find( str );
if ( it != m_layerFact.end() ) {
lay = (*(it.data()))(prof);
/*
iolayer laye = it.data();
lay = (*laye )(conf);*/
}
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
@@ -1,51 +1,85 @@
#ifndef OPIE_META_FACTORY_H
#define OPIE_META_FACTORY_H
/**
* The MetaFactory is used to keep track of all IOLayers, FileTransferLayers and ConfigWidgets
* and to instantiate these implementations on demand
*/
#include <qwidget.h>
#include <qmap.h>
#include <qpe/config.h>
#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
@@ -1,55 +1,57 @@
TEMPLATE = app
#CONFIG = qt warn_on release
CONFIG = qt debug
DESTDIR = $(OPIEDIR)/bin
HEADERS = io_layer.h io_serial.h \
file_layer.h sz_transfer.h \
metafactory.h \
session.h \
mainwindow.h \
profile.h \
profileconfig.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
LIBS += -lqpe -lopie
TARGET = opie-console
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,112 +1,119 @@
#include "profile.h"
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;
}
bool Profile::operator==( const Profile& prof ) {
if ( m_name == prof.m_name ) return true;
return false;
}
Profile &Profile::operator=( const Profile& prof ) {
m_name = prof.m_name;
m_ioLayer = prof.m_ioLayer;
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() {
}
QMap<QString, QString> Profile::conf()const {
return m_conf;
}
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 {
return m_back;
}
int Profile::terminal()const {
return m_terminal;
}
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 ) {
m_fore = fore;
}
void Profile::setTerminal( int term ) {
m_terminal = term;
}
/* config stuff */
void Profile::clearConf() {
m_conf.clear();
}
void Profile::writeEntry( const QString& key, const QString& value ) {
m_conf.replace( key, value );
}
void Profile::writeEntry( const QString& key, int num ) {
writeEntry( key, QString::number( num ) );
}
void Profile::writeEntry( const QString& key, bool b ) {
writeEntry( key, QString::number(b) );
}
void Profile::writeEntry( const QString& key, const QStringList& lis, const QChar& sep ) {
writeEntry( key, lis.join(sep) );
}
QString Profile::readEntry( const QString& key, const QString& deflt )const {
QMap<QString, QString>::ConstIterator it;
it = m_conf.find( key );
if ( it != m_conf.end() )
return it.data();
return deflt;
}
int Profile::readNumEntry( const QString& key, int def )const {
QMap<QString, QString>::ConstIterator it;
it = m_conf.find( key );
if ( it != m_conf.end() ) {
bool ok;
int val = it.data().toInt(&ok);
if (ok)
return val;
}
return def;
}
bool Profile::readBoolEntry( const QString& key, bool def )const {
return readNumEntry( key, def );
}
void Profile::setConf( const QMap<QString, QString>& conf ) {
m_conf = conf;
};
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 @@
#ifndef OPIE_PROFILE_H
#define OPIE_PROFILE_H
#include <qmap.h>
#include <qstring.h>
#include <qstringlist.h>
#include <qvaluelist.h>
/**
* A session will be generated from a saved
* profile. A profile contains the iolayername
* a name.
* We can generate a Session from a Profile
* Configuration is contained here too
*/
class Profile {
public:
typedef QValueList<Profile> ValueList;
enum Color { Black = 0,
White,
Gray };
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& );
Profile &operator=( const Profile& );
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;
/*
* config stuff
*/
QMap<QString, QString> conf()const;
void clearConf();
void writeEntry( const QString& key, const QString& value );
void writeEntry( const QString& key, int num );
void writeEntry( const QString& key, bool b );
void writeEntry( const QString& key, const QStringList&, const QChar& );
QString readEntry( const QString& key, const QString& deflt = QString::null)const;
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;
};
#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 @@
+#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,189 +1,190 @@
+#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 )
{
initUI();
// Apply current profile
// plugin_plugin->load(profile);
// ... (reset profile name line edit etc.)
}
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
// plugin_plugin->load(profile);
}
Profile ProfileEditorDialog::profile() const
{
return m_prof;
}
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
@@ -1,50 +1,51 @@
#ifndef PROFILE_EDITOR_DIALOG
#define PROFILE_EDITOR_DIALOG
#include <qdialog.h>
#include "profile.h"
class MetaFactory;
class EditBase;
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
@@ -1,97 +1,97 @@
#ifndef PROFILE_EDITOR_PLUGINS_H
#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" {
//#endif
ProfileEditorPlugin *factory_serial(QWidget *parent, Profile *p);
ProfileEditorPlugin *factory_irda(QWidget *parent, Profile *p);
ProfileEditorPlugin *factory_modem(QWidget *parent, Profile *p);
//#ifdef __cplusplus
//}
//#endif
#endif
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
@@ -1,93 +1,95 @@
#include <qpe/config.h>
#include "metafactory.h"
#include "profileconfig.h"
#include "profilemanager.h"
ProfileManager::ProfileManager( MetaFactory* fact )
: m_fact( fact )
{
}
ProfileManager::~ProfileManager() {
}
void ProfileManager::load() {
m_list.clear();
qWarning("load");
ProfileConfig conf("opie-console-profiles");
QStringList groups = conf.groups();
QStringList::Iterator it;
/*
* for each profile
*/
for ( it = groups.begin(); it != groups.end(); ++it ) {
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) ) );
/* now add it */
m_list.append( prof );
}
}
void ProfileManager::clear() {
m_list.clear();
}
Profile::ValueList ProfileManager::all()const {
return m_list;
}
Session* ProfileManager::fromProfile( const Profile& prof) {
Session* session = new Session();
session->setName( prof.name() );
session->setIOLayer(m_fact->newIOLayer(prof.ioLayerName(),
prof) );
/*
* FIXME
* load emulation
* load widget?
* set colors + fonts
*/
return session;
}
void ProfileManager::save( ) {
ProfileConfig conf("opie-console-profiles");
conf.clearAll();
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 */
QMap<QString, QString> map = (*it).conf();
QMap<QString, QString>::Iterator it;
for ( it = map.begin(); it != map.end(); ++it ) {
conf.writeEntry( it.key(), it.data() );
}
}
}
void ProfileManager::setProfiles( const Profile::ValueList& list ) {
m_list = list;
};
Profile ProfileManager::profile( const QString& name )const {
Profile prof;
Profile::ValueList::ConstIterator it;
for ( it = m_list.begin(); it != m_list.end(); ++it ) {
if ( name == (*it).name() ) {
prof = (*it);
break;
}
}
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,54 +1,54 @@
#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() {
}
void SzTransfer::sendFile(const QFile& file) {
sendFile(file.name());
}
void SzTransfer::sendFile(const QString& file) {
proc = new OProcess;
*proc << "sz";
*proc << "-vv" << file;
connect(proc, SIGNAL(processExited(OProcess *)),
this, SLOT(sent()));
connect(proc, SIGNAL(processRecievedStdout(OProcess *, char *, int)),
this, SLOT(SzRecievedStdout(OProcess *, char *, int)));
connect(proc, SIGNAL(processRecievedStderr(OProcess *, char *, int)),
this, SLOT(SzRecievedStderr(OProcess *, char *, int)));
connect(layer(), SIGNAL(received(QByteArray &)),
this, SLOT(recievedStdin(QByteArray &)));
proc->start(OProcess::NotifyOnExit, OProcess::All);
}
void SzTransfer::SzRecievedStdout(OProcess *, char *buffer, int buflen) {
QByteArray data(buflen);
data.fill(*buffer, buflen);
// send out through the io layer
(layer())->send(data);
}
void SzTransfer::SzRecievedStderr(OProcess *, char *, int) {
// parse and show data in a progress dialog/widget
}
void SzTransfer::recievedStdin(QByteArray &data) {
// recieved data from the io layer goes to sz
proc->writeStdin(data.data(), data.size());
}
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 @@
#ifndef OPIE_FL_SZ_H
#define OPIE_FL_SZ_H
#include "file_layer.h"
#include <opie/oprocess.h>
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