summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
authormickeyl <mickeyl>2004-01-03 16:57:51 (UTC)
committer mickeyl <mickeyl>2004-01-03 16:57:51 (UTC)
commitbdabd0e055d494c7546de08348e32cf5622c9074 (patch) (side-by-side diff)
tree97346f3ef40158d31c2e649390a941135890a39b /inputmethods/multikey/keyboard.cpp
parent4f7bf49ba4c0466aa9cea618c9317ac965a1118f (diff)
downloadopie-bdabd0e055d494c7546de08348e32cf5622c9074.zip
opie-bdabd0e055d494c7546de08348e32cf5622c9074.tar.gz
opie-bdabd0e055d494c7546de08348e32cf5622c9074.tar.bz2
add multikey patches courtesy Anton Kachalov <mouse@altlinux.ru>
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
@@ -28,13 +28,13 @@
#include <qpainter.h>
#include <qfontmetrics.h>
#include <qtimer.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <ctype.h>
-#include <qfile.h>
+#include <qdir.h>
#include <qtextstream.h>
#include <qstringlist.h>
#include <sys/utsname.h>
using namespace MultiKey;
@@ -91,18 +91,21 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
keys = new Keys();
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;
}
}
/* Keyboard::resizeEvent {{{1 */
@@ -414,13 +417,13 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
if (unicode == 0) { // either Qt char, or nothing
if (qkeycode == Qt::Key_F1) { // toggle the pickboard
if ( configdlg ) {
- delete (ConfigDlg *) configdlg;
+ delete configdlg;
configdlg = 0;
}
else {
configdlg = new ConfigDlg ();
connect(configdlg, SIGNAL(setMapToDefault()),
this, SLOT(setMapToDefault()));
@@ -431,12 +434,14 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
connect(configdlg, SIGNAL(repeatToggled(bool)),
this, SLOT(toggleRepeat(bool)));
connect(configdlg, SIGNAL(reloadKeyboard()),
this, SLOT(reloadKeyboard()));
connect(configdlg, SIGNAL(configDlgClosed()),
this, SLOT(cleanupConfigDlg()));
+ connect(configdlg, SIGNAL(reloadSw()),
+ this, SLOT(reloadSw()));
configdlg->showMaximized();
configdlg->show();
configdlg->raise();
}
} else if (qkeycode == Qt::Key_Control) {
@@ -757,12 +762,23 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
if (useRepeat) repeatTimer->start( 800 );
//pressTid = startTimer(80);
}
+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*)
{
pressed = FALSE;
//if ( pressTid == 0 )
@@ -908,27 +924,43 @@ void Keyboard::toggleRepeat(bool on) {
//cout << "setting useRepeat to: " << useRepeat << "\n";
}
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() {
/* load current locale language map */
Config *config = new Config("locale");
config->setGroup( "Language" );
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";
/* save change to multikey config file */
config = new Config("multikey");
config->setGroup ("keymaps");
@@ -1503,13 +1535,13 @@ void Keys::setKeysFromFile(const char * filename) {
accentMap.insert(lower, shift);
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);
QString name, equals, value;
tmp >> name >> equals >> value;