author | hash <hash> | 2002-10-20 14:04:33 (UTC) |
---|---|---|
committer | hash <hash> | 2002-10-20 14:04:33 (UTC) |
commit | 6924185b50abfa448daa16a9f7cb6e532ec77ff9 (patch) (side-by-side diff) | |
tree | cd00862fc27c3739e7658e6dfaa39624197d8452 /noncore | |
parent | 97be4ef8e0579791095b2383e942cc53dd1e7fba (diff) | |
download | opie-6924185b50abfa448daa16a9f7cb6e532ec77ff9.zip opie-6924185b50abfa448daa16a9f7cb6e532ec77ff9.tar.gz opie-6924185b50abfa448daa16a9f7cb6e532ec77ff9.tar.bz2 |
added preliminary support for configuring the keyboard for each profile.
-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 @@ -4,16 +4,17 @@ #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 ); @@ -71,16 +72,21 @@ extern "C" { } // 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 ) { @@ -100,14 +106,16 @@ Default::Default( MetaFactory* fact ) { 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 @@ -20,16 +20,17 @@ extern "C" { 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* ); 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,24 +1,25 @@ #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( @@ -54,18 +55,18 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) { // 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, @@ -150,8 +151,32 @@ void FunctionKeyboard::loadDefaults() { 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,15 +1,18 @@ #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) {}; @@ -59,9 +62,22 @@ private: 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 @@ -13,16 +13,23 @@ void MetaFactory::addConnectionWidgetFactory( const QCString& 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, @@ -123,16 +130,29 @@ ProfileDialogWidget *MetaFactory::newTerminalPlugin( const QString& str, QWidget 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); } 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 @@ -35,16 +35,19 @@ public: * 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 ); @@ -78,16 +81,17 @@ public: 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 @@ -100,16 +104,17 @@ public: */ 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 @@ -25,8 +25,19 @@ ProfileDialogConnectionWidget::ProfileDialogConnectionWidget( const QString& na, : 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 @@ -5,17 +5,18 @@ #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 */ @@ -41,10 +42,18 @@ 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 @@ -48,31 +48,33 @@ ProfileEditorDialog::ProfileEditorDialog( MetaFactory* fact ) 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 ); @@ -89,16 +91,17 @@ void ProfileEditorDialog::initUI() 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) ); @@ -107,16 +110,17 @@ void ProfileEditorDialog::initUI() 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&) ) ); @@ -145,16 +149,18 @@ void ProfileEditorDialog::accept() 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(); @@ -173,16 +179,17 @@ QCString ProfileEditorDialog::profType()const */ 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 ); @@ -197,8 +204,19 @@ void ProfileEditorDialog::slotTermActivated( const QString& str ) { 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 @@ -28,30 +28,31 @@ public: 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 |