-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index bded447..2ce6dd3 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -10,64 +10,76 @@ | |||
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | #include "configdlg.h" | 22 | #include "configdlg.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | 26 | ||
27 | #include <qwindowsystem_qws.h> | 27 | #include <qwindowsystem_qws.h> |
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 <qfile.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 | ||
40 | using namespace MultiKey; | 40 | using namespace MultiKey; |
41 | 41 | ||
42 | static const char * const kb_config_xpm[] = { | ||
43 | "13 7 2 1", | ||
44 | " c None", | ||
45 | ". c #000000", | ||
46 | " ", | ||
47 | " . ", | ||
48 | " ... ", | ||
49 | " ..... ", | ||
50 | " . ", | ||
51 | " . ", | ||
52 | " "}; | ||
53 | |||
42 | /* Keyboard::Keyboard {{{1 */ | 54 | /* Keyboard::Keyboard {{{1 */ |
43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 55 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), | 56 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), |
45 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), | 57 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), |
46 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), | 58 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), |
47 | pressedKeyRow(-1), pressedKeyCol(-1), | 59 | pressedKeyRow(-1), pressedKeyCol(-1), |
48 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 60 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
49 | configdlg(0) | 61 | configdlg(0) |
50 | 62 | ||
51 | { | 63 | { |
52 | 64 | ||
53 | // get the default font | 65 | // get the default font |
54 | Config *config = new Config( "qpe" ); | 66 | Config *config = new Config( "qpe" ); |
55 | config->setGroup( "Appearance" ); | 67 | config->setGroup( "Appearance" ); |
56 | QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); | 68 | QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); |
57 | delete config; | 69 | delete config; |
58 | 70 | ||
59 | config = new Config("multikey"); | 71 | config = new Config("multikey"); |
60 | config->setGroup ("general"); | 72 | config->setGroup ("general"); |
61 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed | 73 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed |
62 | useRepeat = config->readBoolEntry ("useRepeat", 1); | 74 | useRepeat = config->readBoolEntry ("useRepeat", 1); |
63 | delete config; | 75 | delete config; |
64 | 76 | ||
65 | 77 | ||
66 | setFont( QFont( familyStr, 10 ) ); | 78 | setFont( QFont( familyStr, 10 ) ); |
67 | 79 | ||
68 | picks = new KeyboardPicks( this ); | 80 | picks = new KeyboardPicks( this ); |
69 | picks->setFont( QFont( familyStr, 10 ) ); | 81 | picks->setFont( QFont( familyStr, 10 ) ); |
70 | picks->initialise(); | 82 | picks->initialise(); |
71 | if (usePicks) { | 83 | if (usePicks) { |
72 | 84 | ||
73 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 85 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
@@ -1493,69 +1505,75 @@ void Keys::setKeysFromFile(const char * filename) { | |||
1493 | 1505 | ||
1494 | buf = t.readLine(); | 1506 | buf = t.readLine(); |
1495 | } | 1507 | } |
1496 | 1508 | ||
1497 | // other variables like lang & title | 1509 | // other variables like lang & title |
1498 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 1510 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
1499 | 1511 | ||
1500 | QTextStream tmp (buf, IO_ReadOnly); | 1512 | QTextStream tmp (buf, IO_ReadOnly); |
1501 | QString name, equals, value; | 1513 | QString name, equals, value; |
1502 | 1514 | ||
1503 | tmp >> name >> equals >> value; | 1515 | tmp >> name >> equals >> value; |
1504 | 1516 | ||
1505 | if (name == "lang") { | 1517 | if (name == "lang") { |
1506 | 1518 | ||
1507 | lang = value; | 1519 | lang = value; |
1508 | 1520 | ||
1509 | } | 1521 | } |
1510 | 1522 | ||
1511 | buf = t.readLine(); | 1523 | buf = t.readLine(); |
1512 | } | 1524 | } |
1513 | // comments | 1525 | // comments |
1514 | else if (buf.contains(QRegExp("^\\s*#"))) { | 1526 | else if (buf.contains(QRegExp("^\\s*#"))) { |
1515 | 1527 | ||
1516 | buf = t.readLine(); | 1528 | buf = t.readLine(); |
1517 | 1529 | ||
1518 | } else { // blank line, or garbage | 1530 | } else { // blank line, or garbage |
1519 | 1531 | ||
1520 | buf = t.readLine(); | 1532 | buf = t.readLine(); |
1521 | 1533 | ||
1522 | } | 1534 | } |
1523 | 1535 | ||
1524 | } | 1536 | } |
1537 | |||
1525 | f.close(); | 1538 | f.close(); |
1539 | } else { | ||
1540 | // We couldnt find the selected keymap, give them a configure button | ||
1541 | QImage * btn = new QImage((const char ** )kb_config_xpm); | ||
1542 | setKey(1, 0x1030, 0, 2, btn); | ||
1526 | } | 1543 | } |
1527 | 1544 | ||
1528 | } | 1545 | } |
1529 | 1546 | ||
1547 | |||
1530 | // Keys::setKey {{{2 | 1548 | // Keys::setKey {{{2 |
1531 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 1549 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
1532 | const int width, QImage *pix) { | 1550 | const int width, QImage *pix) { |
1533 | 1551 | ||
1534 | Key * key; | 1552 | Key * key; |
1535 | key = new Key; | 1553 | key = new Key; |
1536 | key->qcode = qcode; | 1554 | key->qcode = qcode; |
1537 | key->unicode = unicode; | 1555 | key->unicode = unicode; |
1538 | key->width = width; | 1556 | key->width = width; |
1539 | 1557 | ||
1540 | // share key->pressed between same keys | 1558 | // share key->pressed between same keys |
1541 | bool found = 0; | 1559 | bool found = 0; |
1542 | for (int i = 1; i <= 5; i++) { | 1560 | for (int i = 1; i <= 5; i++) { |
1543 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1561 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1544 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1562 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
1545 | 1563 | ||
1546 | key->pressed = keys[i].at(j)->pressed; | 1564 | key->pressed = keys[i].at(j)->pressed; |
1547 | found = 1; | 1565 | found = 1; |
1548 | } | 1566 | } |
1549 | 1567 | ||
1550 | } | 1568 | } |
1551 | if (!found) { | 1569 | if (!found) { |
1552 | 1570 | ||
1553 | key->pressed = new bool; | 1571 | key->pressed = new bool; |
1554 | *(key->pressed) = 0; | 1572 | *(key->pressed) = 0; |
1555 | } | 1573 | } |
1556 | 1574 | ||
1557 | key->pix = pix; | 1575 | key->pix = pix; |
1558 | 1576 | ||
1559 | 1577 | ||
1560 | keys[row].append(key); | 1578 | keys[row].append(key); |
1561 | } | 1579 | } |