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) (unidiff)
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) (show 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 @@
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qfontmetrics.h> 29#include <qfontmetrics.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <ctype.h> 33#include <ctype.h>
34#include <qfile.h> 34#include <qdir.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40using namespace MultiKey; 40using namespace MultiKey;
@@ -91,18 +91,21 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
91 91
92 keys = new Keys(); 92 keys = new Keys();
93 93
94 repeatTimer = new QTimer( this ); 94 repeatTimer = new QTimer( this );
95 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 95 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
96 96
97 QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this);
98 connect(kbdChannel, SIGNAL(received(const QCString &, const QByteArray &)),
99 this, SLOT(receive(const QCString &, const QByteArray &)));
97} 100}
98 101
99Keyboard::~Keyboard() { 102Keyboard::~Keyboard() {
100 103
101 if ( configdlg ) { 104 if ( configdlg ) {
102 delete (ConfigDlg *) configdlg; 105 delete configdlg;
103 configdlg = 0; 106 configdlg = 0;
104 } 107 }
105 108
106} 109}
107 110
108/* Keyboard::resizeEvent {{{1 */ 111/* Keyboard::resizeEvent {{{1 */
@@ -414,13 +417,13 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
414 if (unicode == 0) { // either Qt char, or nothing 417 if (unicode == 0) { // either Qt char, or nothing
415 418
416 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 419 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
417 420
418 if ( configdlg ) { 421 if ( configdlg ) {
419 422
420 delete (ConfigDlg *) configdlg; 423 delete configdlg;
421 configdlg = 0; 424 configdlg = 0;
422 } 425 }
423 else { 426 else {
424 configdlg = new ConfigDlg (); 427 configdlg = new ConfigDlg ();
425 connect(configdlg, SIGNAL(setMapToDefault()), 428 connect(configdlg, SIGNAL(setMapToDefault()),
426 this, SLOT(setMapToDefault())); 429 this, SLOT(setMapToDefault()));
@@ -431,12 +434,14 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
431 connect(configdlg, SIGNAL(repeatToggled(bool)), 434 connect(configdlg, SIGNAL(repeatToggled(bool)),
432 this, SLOT(toggleRepeat(bool))); 435 this, SLOT(toggleRepeat(bool)));
433 connect(configdlg, SIGNAL(reloadKeyboard()), 436 connect(configdlg, SIGNAL(reloadKeyboard()),
434 this, SLOT(reloadKeyboard())); 437 this, SLOT(reloadKeyboard()));
435 connect(configdlg, SIGNAL(configDlgClosed()), 438 connect(configdlg, SIGNAL(configDlgClosed()),
436 this, SLOT(cleanupConfigDlg())); 439 this, SLOT(cleanupConfigDlg()));
440 connect(configdlg, SIGNAL(reloadSw()),
441 this, SLOT(reloadSw()));
437 configdlg->showMaximized(); 442 configdlg->showMaximized();
438 configdlg->show(); 443 configdlg->show();
439 configdlg->raise(); 444 configdlg->raise();
440 } 445 }
441 446
442 } else if (qkeycode == Qt::Key_Control) { 447 } else if (qkeycode == Qt::Key_Control) {
@@ -757,12 +762,23 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
757 762
758 if (useRepeat) repeatTimer->start( 800 ); 763 if (useRepeat) repeatTimer->start( 800 );
759 //pressTid = startTimer(80); 764 //pressTid = startTimer(80);
760 765
761} 766}
762 767
768void Keyboard::receive(const QCString &msg, const QByteArray &data)
769{
770 if (msg == "setmultikey(QString)") {
771 QDataStream stream(data, IO_ReadOnly);
772 QString map;
773 stream >> map;
774 setMapToFile(map);
775 } else if (msg == "getmultikey()") {
776 reloadSw();
777 }
778}
763 779
764/* Keyboard::mouseReleaseEvent {{{1 */ 780/* Keyboard::mouseReleaseEvent {{{1 */
765void Keyboard::mouseReleaseEvent(QMouseEvent*) 781void Keyboard::mouseReleaseEvent(QMouseEvent*)
766{ 782{
767 pressed = FALSE; 783 pressed = FALSE;
768 //if ( pressTid == 0 ) 784 //if ( pressTid == 0 )
@@ -908,27 +924,43 @@ void Keyboard::toggleRepeat(bool on) {
908 //cout << "setting useRepeat to: " << useRepeat << "\n"; 924 //cout << "setting useRepeat to: " << useRepeat << "\n";
909} 925}
910 926
911void Keyboard::cleanupConfigDlg() { 927void Keyboard::cleanupConfigDlg() {
912 928
913 if ( configdlg ) { 929 if ( configdlg ) {
914 delete (ConfigDlg *) configdlg; 930 delete configdlg;
915 configdlg = 0; 931 configdlg = 0;
916 } 932 }
917} 933}
918 934
935void Keyboard::reloadSw() {
936 QCopEnvelope e("MultiKey/Switcher", "setsw(QString,QString)");
937
938 Config* config = new Config("multikey");
939 config->setGroup("keymaps");
940 QString current_map = config->readEntry("current", "en.keymap");
941 delete config;
942
943 e << ConfigDlg::loadSw().join("|") << current_map;
944}
945
919/* Keyboard::setMapTo ... {{{1 */ 946/* Keyboard::setMapTo ... {{{1 */
920void Keyboard::setMapToDefault() { 947void Keyboard::setMapToDefault() {
921 948
922 949
923 /* load current locale language map */ 950 /* load current locale language map */
924 Config *config = new Config("locale"); 951 Config *config = new Config("locale");
925 config->setGroup( "Language" ); 952 config->setGroup( "Language" );
926 QString l = config->readEntry( "Language" , "en" ); 953 QString l = config->readEntry( "Language" , "en" );
927 delete config; 954 delete config;
928 955
956 /* if Language represents as en_US, ru_RU, etc... */
957 int d = l.find('_');
958 if (d != -1) {
959 l.remove(d, l.length()-d);
960 }
929 QString key_map = QPEApplication::qpeDir() + "share/multikey/" 961 QString key_map = QPEApplication::qpeDir() + "share/multikey/"
930 + l + ".keymap"; 962 + l + ".keymap";
931 963
932 /* save change to multikey config file */ 964 /* save change to multikey config file */
933 config = new Config("multikey"); 965 config = new Config("multikey");
934 config->setGroup ("keymaps"); 966 config->setGroup ("keymaps");
@@ -1503,13 +1535,13 @@ void Keys::setKeysFromFile(const char * filename) {
1503 1535
1504 accentMap.insert(lower, shift); 1536 accentMap.insert(lower, shift);
1505 1537
1506 buf = t.readLine(); 1538 buf = t.readLine();
1507 } 1539 }
1508 1540
1509 // other variables like lang & title 1541 // other variables like lang & title & sw
1510 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1542 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1511 1543
1512 QTextStream tmp (buf, IO_ReadOnly); 1544 QTextStream tmp (buf, IO_ReadOnly);
1513 QString name, equals, value; 1545 QString name, equals, value;
1514 1546
1515 tmp >> name >> equals >> value; 1547 tmp >> name >> equals >> value;