From bdabd0e055d494c7546de08348e32cf5622c9074 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sat, 03 Jan 2004 16:57:51 +0000 Subject: add multikey patches courtesy Anton Kachalov --- (limited to 'inputmethods/multikey/keyboard.cpp') diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 2ce6dd3..aec0ad3 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include #include #include @@ -94,12 +94,15 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : repeatTimer = new QTimer( this ); connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); + QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this); + connect(kbdChannel, SIGNAL(received(const QCString &, const QByteArray &)), + this, SLOT(receive(const QCString &, const QByteArray &))); } Keyboard::~Keyboard() { if ( configdlg ) { - delete (ConfigDlg *) configdlg; + delete configdlg; configdlg = 0; } @@ -417,7 +420,7 @@ void Keyboard::mousePressEvent(QMouseEvent *e) if ( configdlg ) { - delete (ConfigDlg *) configdlg; + delete configdlg; configdlg = 0; } else { @@ -434,6 +437,8 @@ void Keyboard::mousePressEvent(QMouseEvent *e) this, SLOT(reloadKeyboard())); connect(configdlg, SIGNAL(configDlgClosed()), this, SLOT(cleanupConfigDlg())); + connect(configdlg, SIGNAL(reloadSw()), + this, SLOT(reloadSw())); configdlg->showMaximized(); configdlg->show(); configdlg->raise(); @@ -760,6 +765,17 @@ void Keyboard::mousePressEvent(QMouseEvent *e) } +void Keyboard::receive(const QCString &msg, const QByteArray &data) +{ + if (msg == "setmultikey(QString)") { + QDataStream stream(data, IO_ReadOnly); + QString map; + stream >> map; + setMapToFile(map); + } else if (msg == "getmultikey()") { + reloadSw(); + } +} /* Keyboard::mouseReleaseEvent {{{1 */ void Keyboard::mouseReleaseEvent(QMouseEvent*) @@ -911,11 +927,22 @@ void Keyboard::toggleRepeat(bool on) { void Keyboard::cleanupConfigDlg() { if ( configdlg ) { - delete (ConfigDlg *) configdlg; + delete configdlg; configdlg = 0; } } +void Keyboard::reloadSw() { + QCopEnvelope e("MultiKey/Switcher", "setsw(QString,QString)"); + + Config* config = new Config("multikey"); + config->setGroup("keymaps"); + QString current_map = config->readEntry("current", "en.keymap"); + delete config; + + e << ConfigDlg::loadSw().join("|") << current_map; +} + /* Keyboard::setMapTo ... {{{1 */ void Keyboard::setMapToDefault() { @@ -926,6 +953,11 @@ void Keyboard::setMapToDefault() { QString l = config->readEntry( "Language" , "en" ); delete config; + /* if Language represents as en_US, ru_RU, etc... */ + int d = l.find('_'); + if (d != -1) { + l.remove(d, l.length()-d); + } QString key_map = QPEApplication::qpeDir() + "share/multikey/" + l + ".keymap"; @@ -1506,7 +1538,7 @@ void Keys::setKeysFromFile(const char * filename) { buf = t.readLine(); } - // other variables like lang & title + // other variables like lang & title & sw else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { QTextStream tmp (buf, IO_ReadOnly); -- cgit v0.9.0.2