-rw-r--r-- | noncore/apps/opie-console/default.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/default.h | 1 | ||||
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.cpp | 33 | ||||
-rw-r--r-- | noncore/apps/opie-console/function_keyboard.h | 16 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.cpp | 20 | ||||
-rw-r--r-- | noncore/apps/opie-console/metafactory.h | 5 | ||||
-rw-r--r-- | noncore/apps/opie-console/profiledialogwidget.cpp | 11 | ||||
-rw-r--r-- | noncore/apps/opie-console/profiledialogwidget.h | 11 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.cpp | 20 | ||||
-rw-r--r-- | noncore/apps/opie-console/profileeditordialog.h | 7 |
10 files changed, 123 insertions, 9 deletions
diff --git a/noncore/apps/opie-console/default.cpp b/noncore/apps/opie-console/default.cpp index 8b905e1..0160b56 100644 --- a/noncore/apps/opie-console/default.cpp +++ b/noncore/apps/opie-console/default.cpp @@ -1,113 +1,121 @@ #include "io_serial.h" #include "io_irda.h" #include "io_bt.h" #include "io_modem.h" #include "filetransfer.h" #include "filereceive.h" #include "serialconfigwidget.h" #include "irdaconfigwidget.h" #include "btconfigwidget.h" #include "modemconfigwidget.h" #include "terminalwidget.h" +#include "function_keyboard.h" #include "MyPty.h" #include "default.h" extern "C" { // FILE Transfer Stuff FileTransferLayer* newSZTransfer(IOLayer* lay) { return new FileTransfer( FileTransfer::SZ, lay ); } FileTransferLayer* newSYTransfer(IOLayer* lay) { return new FileTransfer( FileTransfer::SY, lay ); } FileTransferLayer* newSXTransfer(IOLayer* lay) { return new FileTransfer(FileTransfer ::SX, lay ); } // FILE Transfer Receive Stuff ReceiveLayer* newSZReceive(IOLayer* lay) { return new FileReceive( FileReceive::SZ, lay ); } ReceiveLayer* newSYReceive(IOLayer* lay) { return new FileReceive( FileReceive::SY, lay ); } ReceiveLayer* newSXReceive(IOLayer* lay) { return new FileReceive(FileReceive::SX, lay ); } // Layer stuff IOLayer* newSerialLayer( const Profile& prof) { return new IOSerial( prof ); } IOLayer* newBTLayer( const Profile& prof ) { return new IOBt( prof ); } IOLayer* newIrDaLayer( const Profile& prof ) { return new IOIrda( prof ); } IOLayer* newModemLayer( const Profile& prof ) { return new IOModem( prof ); } IOLayer* newConsole( const Profile& prof ) { return new MyPty( prof ); } // Connection Widgets ProfileDialogWidget* newSerialWidget( const QString& str, QWidget* wid ) { return new SerialConfigWidget( str, wid ); } ProfileDialogWidget* newIrDaWidget( const QString& str, QWidget* wid ) { return new IrdaConfigWidget( str, wid ); } ProfileDialogWidget* newModemWidget( const QString& str, QWidget* wid ) { return new ModemConfigWidget(str, wid ); } ProfileDialogWidget* newBTWidget( const QString& str, QWidget* wid ) { return new BTConfigWidget(str, wid ); } ProfileDialogWidget* newConsoleWid( const QString& str, QWidget* wid ) { return 0l; } // Terminal Widget(s) ProfileDialogWidget* newTerminalWidget(const QString& na, QWidget* wid) { return new TerminalWidget(na, wid,0 ); } + // Function Keyboard Widget + ProfileDialogWidget* newKeyboardWidget(const QString& na, QWidget *wid) { + return new FunctionKeyboardConfig(na, wid); + } + /* // VT Emulations EmulationLayer* newVT102( WidgetLayer* wid ) { return new Vt102Emulation( wid ); } */ }; 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->addReceiveLayer( "SZ", QObject::tr("Z-Modem"), newSZReceive ); fact->addReceiveLayer( "SY", QObject::tr("Y-Modem"), newSYReceive ); fact->addReceiveLayer( "SX", QObject::tr("X-Modem"), newSXReceive ); fact->addIOLayerFactory( "serial", QObject::tr("Serial"), newSerialLayer ); fact->addIOLayerFactory( "irda", QObject::tr("Infrared"), newIrDaLayer ); fact->addIOLayerFactory( "bt", QObject::tr("Bluetooth"), newBTLayer ); fact->addIOLayerFactory( "modem", QObject::tr("Modem"), newModemLayer ); fact->addIOLayerFactory( "console", QObject::tr("Console"), newConsole ); fact->addConnectionWidgetFactory( "serial", QObject::tr("Serial"), newSerialWidget ); fact->addConnectionWidgetFactory( "irda", QObject::tr("Infrared"), newIrDaWidget ); fact->addConnectionWidgetFactory( "modem", QObject::tr("Modem"), newModemWidget ); fact->addConnectionWidgetFactory( "bt", QObject::tr("Bluetooth"), newBTWidget ); fact->addConnectionWidgetFactory( "console", QObject::tr("Console"), newConsoleWid ); fact->addTerminalWidgetFactory( "default", QObject::tr("Default Terminal"), newTerminalWidget ); + fact->addKeyboardWidgetFactory( "defaultKeys", QObject::tr("Default Keyboard"), + newKeyboardWidget ); // fact->addEmulationLayer( "default", QObject::tr("Default Terminal"), newVT102 ); } Default::~Default() { } diff --git a/noncore/apps/opie-console/default.h b/noncore/apps/opie-console/default.h index b8cda03..5b542f5 100644 --- a/noncore/apps/opie-console/default.h +++ b/noncore/apps/opie-console/default.h @@ -1,40 +1,41 @@ #ifndef OPIE_DEFAULT_H #define OPIE_DEFAULT_H #include "metafactory.h" class Widget; extern "C" { FileTransferLayer* newSZTransfer(IOLayer*); FileTransferLayer* newSYTransfer(IOLayer*); FileTransferLayer* newSXTransfer(IOLayer*); ReceiveLayer* newSZReceive(IOLayer*); ReceiveLayer* newSYReceive(IOLayer*); ReceiveLayer* newSXReceive(IOLayer*); IOLayer* newSerialLayer(const Profile&); IOLayer* newBTLayer(const Profile& ); IOLayer* newIrDaLayer(const Profile& ); IOLayer* newConsole(const Profile& ); ProfileDialogWidget* newSerialWidget(const QString&, QWidget* ); ProfileDialogWidget* newIrDaWidget (const QString&, QWidget* ); ProfileDialogWidget* newBTWidget (const QString&, QWidget* ); ProfileDialogWidget* newConsoleWid (const QString&, QWidget* ); ProfileDialogWidget* newTerminalWidget(const QString&, QWidget* ); + ProfileDialogWidget* newKeyboardWidget(const QString&, QWidget* ); // EmulationLayer* newVT102( WidgetLayer* ); }; class MetaFactory; struct Default { public: Default(MetaFactory* ); ~Default(); }; #endif diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp index 4119ad4..fd20e99 100644 --- a/noncore/apps/opie-console/function_keyboard.cpp +++ b/noncore/apps/opie-console/function_keyboard.cpp @@ -1,157 +1,182 @@ #include "function_keyboard.h" #include <qsizepolicy.h> #include <qevent.h> #include <qwindowsystem_qws.h> #include <qapplication.h> +#include <qlayout.h> FunctionKeyboard::FunctionKeyboard(QWidget *parent) : QFrame(parent), numRows(2), numCols(11), pressedRow(0), pressedCol(0) { setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); Config conf("opie-console-keys"); conf.setGroup("keys"); - for (int r = 0; r < numRows; r++) - for (int c = 0; c < numCols; c++) { + for (uint r = 0; r < numRows; r++) + for (uint c = 0; c < numCols; c++) { QString handle = "r" + QString::number(r) + "c" + QString::number(c); QStringList value_list = conf.readListEntry( handle, '|'); if (value_list.isEmpty()) continue; keys.insert( handle, FKey (value_list[0], value_list[1].toUShort(), value_list[2].toUShort()) ); } //qWarning("loaded %d keys", keys.count()); if (keys.isEmpty()) loadDefaults(); } FunctionKeyboard::~FunctionKeyboard() { } void FunctionKeyboard::paintEvent(QPaintEvent *e) { QPainter p(this); p.setClipRect(e->rect()); p.fillRect(0, 0, width(), height(), QColor(255,255,255)); p.setPen(QColor(0,0,0)); /* those decimals do count! becomes short if use plain int */ for (double i = 0; i <= width(); i += keyWidth) { p.drawLine((int)i, 0, (int)i, height()); } // sometimes the last line doesnt get drawn p.drawLine(width() -1, 0, width() -1, height()); for (int i = 0; i <= height(); i += keyHeight) { p.drawLine(0, i, width(), i); } - for (int r = 0; r < numRows; r++) { - for (int c = 0; c < numCols; c++) { + for (uint r = 0; r < numRows; r++) { + for (uint c = 0; c < numCols; c++) { QString handle = "r" + QString::number(r) + "c" + QString::number(c); if (keys.contains(handle)) { p.drawText( c * keyWidth + 1, r * keyHeight + 1, keyWidth, keyHeight, Qt::AlignHCenter | Qt::AlignVCenter, keys[handle].getL() ); } } } } void FunctionKeyboard::paintKey(int row, int col) { QPainter p(this); p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1), QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)), (pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255)); p.drawText( col * keyWidth + 1, row * keyHeight + 1, keyWidth, keyHeight, Qt::AlignHCenter | Qt::AlignVCenter, keys["r" + QString::number(row) + "c" + QString::number(col)].getL() ); } void FunctionKeyboard::mousePressEvent(QMouseEvent *e) { pressedRow = e->y() / keyHeight; pressedCol = (int) (e->x() / keyWidth); paintKey(pressedRow, pressedCol); // emit that sucker! FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)]; emit keyPressed(k.getU(), k.getQ(), 0, 1, 0); } void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) { if (pressedRow != -1 && pressedRow != -1) { int row = pressedRow; pressedRow = -1; int col = pressedCol; pressedCol = -1; paintKey(row, col); FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)]; emit keyPressed(k.getU(), k.getQ(), 0, 0, 0); } } void FunctionKeyboard::resizeEvent(QResizeEvent*) { /* set he default font height/width */ QFontMetrics fm=fontMetrics(); keyHeight = fm.lineSpacing() + 2; keyWidth = (double)width()/numCols; } QSize FunctionKeyboard::sizeHint() const { return QSize(width(), keyHeight * numRows + 1); } void FunctionKeyboard::loadDefaults() { /* what keys should be default? */ keys.insert( "r0c0", FKey ("F1", 4144, 0)); keys.insert( "r0c1", FKey ("F2", 4145, 0)); keys.insert( "r0c2", FKey ("F3", 4145, 0)); keys.insert( "r0c3", FKey ("F4", 4146, 0)); keys.insert( "r0c4", FKey ("F5", 4147, 0)); keys.insert( "r0c5", FKey ("F6", 4148, 0)); keys.insert( "r0c6", FKey ("F7", 4149, 0)); keys.insert( "r0c7", FKey ("F8", 4150, 0)); keys.insert( "r0c8", FKey ("F9", 4151, 0)); keys.insert( "r0c9", FKey ("F10", 4152, 0)); keys.insert( "r0c10", FKey ("F11", 4153, 0)); keys.insert( "r1c7", FKey ("Ho", 4112, 0)); keys.insert( "r1c8", FKey ("End", 4113, 0)); keys.insert( "r1c9", FKey ("PU", 4118, 0)); keys.insert( "r1c10", FKey ("PD", 4119, 0)); } + + +FunctionKeyboardConfig::FunctionKeyboardConfig(const QString& name, QWidget* parent) : + ProfileDialogKeyWidget(name, parent) { + + + FunctionKeyboard *kb = new FunctionKeyboard(this); + QGroupBox *dimentions = new QGroupBox(2, Qt::Horizontal, tr("Dimentions"), this); + QGroupBox *editKey = new QGroupBox(2, Qt::Horizontal, tr("Edit"), this); + + QVBoxLayout *root = new QVBoxLayout(this, 2); + root->addWidget(kb); + root->addWidget(dimentions); + root->addWidget(editKey); +} +FunctionKeyboardConfig::~FunctionKeyboardConfig() { + +} +void FunctionKeyboardConfig::load (const Profile& prof) { + +} +void FunctionKeyboardConfig::save (Profile& prof) { + +} diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h index 8d05e2b..2be74b4 100644 --- a/noncore/apps/opie-console/function_keyboard.h +++ b/noncore/apps/opie-console/function_keyboard.h @@ -1,67 +1,83 @@ #ifndef OPIE_FUNCTION_KEYBOARD_H #define OPIE_FUNCTION_KEYBOARD_H #include <qpe/config.h> #include <qframe.h> #include <qpainter.h> +#include <qvbox.h> +#include <qgroupbox.h> #include <qmap.h> +#include "profiledialogwidget.h" class FKey { public: FKey(): qcode(0), unicode(0) {}; FKey(const QString &l, ushort q, ushort u): label(l), qcode(q), unicode(u) {}; QString getL() { return label; } ushort getQ() { return qcode; } ushort getU() { return unicode; } private: QString label; ushort qcode; ushort unicode; }; class FunctionKeyboard : public QFrame { Q_OBJECT public: FunctionKeyboard(QWidget *parent = 0); ~FunctionKeyboard(); void paintEvent(QPaintEvent *); void paintKey(int, int); void mousePressEvent(QMouseEvent*); void mouseReleaseEvent(QMouseEvent*); void resizeEvent(QResizeEvent*); QSize sizeHint() const; signals: void keyPressed(ushort, ushort, bool, bool, bool); private: void loadDefaults(); private: // thie key for the map is the row/col QMap<QString, FKey> keys; uint numRows; uint numCols; uint keyHeight; double keyWidth; // decimal point matters! int pressedRow, pressedCol; QObject *parent; }; +class FunctionKeyboardConfig : public ProfileDialogKeyWidget { + Q_OBJECT +public: + FunctionKeyboardConfig(const QString& name, QWidget *wid); + ~FunctionKeyboardConfig(); + + void load(const Profile&); + void save(Profile&); + +private: + +}; + #endif diff --git a/noncore/apps/opie-console/metafactory.cpp b/noncore/apps/opie-console/metafactory.cpp index 04a5dfa..0b43e17 100644 --- a/noncore/apps/opie-console/metafactory.cpp +++ b/noncore/apps/opie-console/metafactory.cpp @@ -1,68 +1,75 @@ #include <qpe/config.h> #include "metafactory.h" MetaFactory::MetaFactory() { } MetaFactory::~MetaFactory() { } void MetaFactory::addConnectionWidgetFactory( const QCString& name, const QString& str, configWidget wid) { m_strings.insert( str, name ); m_conFact.insert( str, wid ); } void MetaFactory::addTerminalWidgetFactory( const QCString& name, const QString& str, configWidget wid ) { m_strings.insert( str, name ); m_termFact.insert( str, wid ); } +void MetaFactory::addKeyboardWidgetFactory( const QCString& name, + const QString & str, + configWidget wid) { + m_strings.insert( str, name ); + m_keyFact.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 QCString& name, const QString& str, filelayer lay) { m_strings.insert(str, name ); m_fileFact.insert( str, lay ); } void MetaFactory::addReceiveLayer( const QCString& name, const QString& str, receivelayer lay) { m_strings.insert(str, name ); m_receiveFact.insert( str, lay ); } void MetaFactory::addEmulationLayer( const QCString& name, const QString& str, emulationLayer em) { m_strings.insert(str, name ); m_emu.insert( str, em ); } 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::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_termFact.begin(); it != m_termFact.end(); ++it ) { list << it.key(); } return list; } @@ -83,88 +90,101 @@ QStringList MetaFactory::receiveLayers()const { return list; } QStringList MetaFactory::emulationLayers()const { QStringList list; QMap<QString, emulationLayer>::ConstIterator it; for ( it = m_emu.begin(); it != m_emu.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; } ProfileDialogWidget *MetaFactory::newConnectionPlugin ( const QString& str, QWidget *parent) { ProfileDialogWidget* wid = 0l; 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; QMap<QString, configWidget>::Iterator it; it = m_termFact.find( str ); if ( it != m_termFact.end() ) { wid = (*(it.data() ) )(str,parent); } return wid; } +ProfileDialogWidget *MetaFactory::newKeyboardPlugin( const QString& str, QWidget *parent) { + + if (str.isEmpty() ) + return 0l; + ProfileDialogWidget* wid = 0l; + + QMap<QString, configWidget>::Iterator it; + it = m_keyFact.find( str ); + if ( it != m_keyFact.end() ) { + wid = (*(it.data() ) )(str,parent); + } + return wid; +} EmulationLayer* MetaFactory::newEmulationLayer( const QString& str, WidgetLayer* wid) { EmulationLayer* lay = 0l; QMap<QString, emulationLayer>::Iterator it; it = m_emu.find( str ); if ( it != m_emu.end() ) { lay = (*(it.data() ) )(wid); } return lay; } FileTransferLayer* MetaFactory::newFileTransfer(const QString& str, IOLayer* lay ) { FileTransferLayer* file = 0l; QMap<QString, filelayer>::Iterator it; it = m_fileFact.find( str ); if ( it != m_fileFact.end() ) { file = (*(it.data() ) )(lay); } return file; } ReceiveLayer* MetaFactory::newReceive(const QString& str, IOLayer* lay ) { ReceiveLayer* file = 0l; QMap<QString, receivelayer>::Iterator it; it = m_receiveFact.find( str ); if ( it != m_receiveFact.end() ) { file = (*(it.data() ) )(lay); } return file; } 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 d6aa5e2..f89136c 100644 --- a/noncore/apps/opie-console/metafactory.h +++ b/noncore/apps/opie-console/metafactory.h @@ -1,115 +1,120 @@ #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 "receive_layer.h" #include "profile.h" #include "profiledialogwidget.h" #include "emulation_layer.h" class WidgetLayer; class MetaFactory { public: typedef ProfileDialogWidget* (*configWidget)(const QString&, QWidget* parent); typedef IOLayer* (*iolayer)(const Profile& ); typedef FileTransferLayer* (*filelayer)(IOLayer*); typedef ReceiveLayer* (*receivelayer)(IOLayer*); typedef EmulationLayer* (*emulationLayer)(WidgetLayer* ); MetaFactory(); ~MetaFactory(); /** * 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 ); + void addKeyboardWidgetFactory ( 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 ); void addReceiveLayer( const QCString& name, const QString&, receivelayer); /** * adds a Factory for Emulation to the Layer.. */ void addEmulationLayer ( const QCString& name, const QString& uiString, emulationLayer ); /* translated UI Strings */ QStringList ioLayers()const; QStringList connectionWidgets()const; /** * Terminal Configuration widgets */ QStringList terminalWidgets()const; QStringList fileTransferLayers()const; QStringList receiveLayers()const; QStringList emulationLayers()const; /** * the generation... */ IOLayer* newIOLayer( const QString&,const Profile& ); ProfileDialogWidget *newConnectionPlugin ( const QString&, QWidget* ); ProfileDialogWidget* newTerminalPlugin( const QString&, QWidget* ); + ProfileDialogWidget* newKeyboardPlugin( const QString&, QWidget* ); EmulationLayer* newEmulationLayer(const QString&, WidgetLayer* ); FileTransferLayer* newFileTransfer(const QString&, IOLayer* ); ReceiveLayer* newReceive(const QString&, IOLayer* ); /* * 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; private: QMap<QString, QCString> m_strings; QMap<QString, configWidget> m_conFact; QMap<QString, configWidget> m_termFact; + QMap<QString, configWidget> m_keyFact; QMap<QString, iolayer> m_layerFact; QMap<QString, filelayer> m_fileFact; QMap<QString, receivelayer> m_receiveFact; QMap<QString, emulationLayer> m_emu; }; #endif diff --git a/noncore/apps/opie-console/profiledialogwidget.cpp b/noncore/apps/opie-console/profiledialogwidget.cpp index 24d59bf..caad998 100644 --- a/noncore/apps/opie-console/profiledialogwidget.cpp +++ b/noncore/apps/opie-console/profiledialogwidget.cpp @@ -1,32 +1,43 @@ #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; } +ProfileDialogKeyWidget::ProfileDialogKeyWidget( const QString &na, + QWidget *parent, + const char *name) + : ProfileDialogWidget(na, parent, name ) +{ +} +ProfileDialogKeyWidget::~ProfileDialogKeyWidget() { +} +ProfileDialogWidget::Type ProfileDialogKeyWidget::type() const{ + return Keyboard; +} diff --git a/noncore/apps/opie-console/profiledialogwidget.h b/noncore/apps/opie-console/profiledialogwidget.h index 5d279e6..9d2d5ec 100644 --- a/noncore/apps/opie-console/profiledialogwidget.h +++ b/noncore/apps/opie-console/profiledialogwidget.h @@ -1,50 +1,59 @@ #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 + Terminal, + Keyboard }; 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; }; +class ProfileDialogKeyWidget : public ProfileDialogWidget { + Q_OBJECT +public: + ProfileDialogKeyWidget( const QString &name, QWidget* parent, + const char *name =0l); + ~ProfileDialogKeyWidget(); + Type type() const; +}; #endif diff --git a/noncore/apps/opie-console/profileeditordialog.cpp b/noncore/apps/opie-console/profileeditordialog.cpp index d124067..2dfc0fd 100644 --- a/noncore/apps/opie-console/profileeditordialog.cpp +++ b/noncore/apps/opie-console/profileeditordialog.cpp @@ -8,197 +8,215 @@ //#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("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; + m_con = m_term = m_key = 0l; QVBoxLayout *mainLayout = new QVBoxLayout( this ); tabWidget = new OTabWidget( this ); tabWidget->setTabStyle(OTabWidget::TextTab); mainLayout->add(tabWidget); /* base tabs */ tabprof = new QWidget(this); m_tabTerm = new QWidget(this); m_tabCon = new QWidget(this); + m_tabKey = new QWidget(this); /* base layout for tabs */ m_layCon = new QHBoxLayout( m_tabCon , 2 ); m_layTerm = new QHBoxLayout( m_tabTerm, 2 ); + m_layKey = new QHBoxLayout( m_tabKey, 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 ); m_autoConnect = new QCheckBox(tr("Auto connect after load"), 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->add(m_autoConnect); vbox3->addStretch(1); m_showconntab = 0; tabWidget->addTab(tabprof, "", QObject::tr("Profile")); //tabWidget->addTab(m_tabCon, "", QObject::tr("Connection")); tabWidget->addTab(m_tabTerm, "", QObject::tr("Terminal")); + tabWidget->addTab(m_tabKey, "", QObject::tr("Special Keys")); 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() ) ); + slotKeyActivated( "Default Keyboard" ); setCurrent( m_fact->external(m_prof.ioLayerName() ), m_conCmb ); setCurrent( m_fact->external(m_prof.terminalName() ), m_termCmb ); m_autoConnect->setChecked(m_prof.autoConnect()); // 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& ) ) ); } ProfileEditorDialog::~ProfileEditorDialog() { } void ProfileEditorDialog::accept() { 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(); // Save general values m_prof.setName(profName()); m_prof.setIOLayer( m_fact->internal(m_conCmb ->currentText() ) ); m_prof.setTerminalName( m_fact->internal(m_termCmb->currentText() ) ); m_prof.setAutoConnect( m_autoConnect->isChecked() ); if (m_con ) m_con->save( m_prof ); if (m_term ) m_term->save( m_prof ); + if (m_key) + m_key->save( m_prof ); QDialog::accept(); } QString ProfileEditorDialog::profName()const { return m_name->text(); } QCString ProfileEditorDialog::profType()const { /*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 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_con->load( m_prof ); m_layCon->addWidget( m_con ); + if(!m_showconntab) { tabWidget->addTab( m_tabCon, "", QObject::tr("Connection") ); tabWidget->setCurrentTab( tabprof ); m_showconntab = 1; } } else { tabWidget->removePage( m_tabCon ); m_showconntab = 0; } } /* * we need to switch the widget */ void ProfileEditorDialog::slotTermActivated( const QString& str ) { delete m_term; m_term = m_fact->newTerminalPlugin( str, m_tabTerm ); if (m_term) { m_term->load(m_prof ); m_layTerm->addWidget( m_term ); } } +void ProfileEditorDialog::slotKeyActivated(const QString &str) { + delete m_key; + m_key = m_fact->newKeyboardPlugin( str, m_tabKey ); + + if (m_key) { + + m_key->load(m_prof); + m_layKey->addWidget(m_key); + } + +} diff --git a/noncore/apps/opie-console/profileeditordialog.h b/noncore/apps/opie-console/profileeditordialog.h index cbda689..6216660 100644 --- a/noncore/apps/opie-console/profileeditordialog.h +++ b/noncore/apps/opie-console/profileeditordialog.h @@ -1,57 +1,58 @@ #ifndef PROFILE_EDITOR_DIALOG #define PROFILE_EDITOR_DIALOG #include <qdialog.h> #include <opie/otabwidget.h> #include "profile.h" class MetaFactory; class EditBase; class QTabWidget; class QHBoxLayout; class QLineEdit; class QComboBox; class QCheckBox; class QLabel; class ProfileDialogWidget; class ProfileEditorDialog : public QDialog { Q_OBJECT public: ProfileEditorDialog(MetaFactory* fact, const Profile& prof ); ProfileEditorDialog(MetaFactory* fact ); ~ProfileEditorDialog(); Profile profile()const; public slots: void accept(); private slots: void slotConActivated(const QString& ); void slotTermActivated( const QString& ); + void slotKeyActivated(const QString&); private: void initUI(); QString profName()const; QCString profType()const; MetaFactory* m_fact; QHBoxLayout* m_lay; Profile m_prof; QLineEdit *m_name; QComboBox *m_conCmb, *m_termCmb; QCheckBox *m_autoConnect; - QWidget *m_tabCon, *m_tabTerm; - ProfileDialogWidget* m_con, *m_term; - QHBoxLayout *m_layCon, *m_layTerm; + QWidget *m_tabCon, *m_tabTerm, *m_tabKey; + ProfileDialogWidget* m_con, *m_term, *m_key; + QHBoxLayout *m_layCon, *m_layTerm, *m_layKey; OTabWidget *tabWidget; QWidget *tabprof; int m_showconntab; }; #endif |