summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp42
1 files changed, 37 insertions, 5 deletions
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
@@ -32,5 +32,5 @@
#include <qpe/config.h>
#include <ctype.h>
-#include <qfile.h>
+#include <qdir.h>
#include <qtextstream.h>
#include <qstringlist.h>
@@ -95,4 +95,7 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
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 &)));
}
@@ -100,5 +103,5 @@ Keyboard::~Keyboard() {
if ( configdlg ) {
- delete (ConfigDlg *) configdlg;
+ delete configdlg;
configdlg = 0;
}
@@ -418,5 +421,5 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
if ( configdlg ) {
- delete (ConfigDlg *) configdlg;
+ delete configdlg;
configdlg = 0;
}
@@ -435,4 +438,6 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
connect(configdlg, SIGNAL(configDlgClosed()),
this, SLOT(cleanupConfigDlg()));
+ connect(configdlg, SIGNAL(reloadSw()),
+ this, SLOT(reloadSw()));
configdlg->showMaximized();
configdlg->show();
@@ -761,4 +766,15 @@ 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 */
@@ -912,9 +928,20 @@ 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() {
@@ -927,4 +954,9 @@ void Keyboard::setMapToDefault() {
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";
@@ -1507,5 +1539,5 @@ void Keys::setKeysFromFile(const char * filename) {
}
- // 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))) {