-rw-r--r-- | inputmethods/multikey/configdlg.cpp | 60 | ||||
-rw-r--r-- | inputmethods/multikey/configdlg.h | 9 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 10 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 1 |
4 files changed, 56 insertions, 24 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp index f23bf1c..7bea589 100644 --- a/inputmethods/multikey/configdlg.cpp +++ b/inputmethods/multikey/configdlg.cpp | |||
@@ -1,123 +1,143 @@ | |||
1 | /* | 1 | /* |
2 | * TODO | 2 | * TODO |
3 | * make a font selection thing | 3 | * make a font selection thing (size too) |
4 | * | 4 | * |
5 | * FIXME | ||
6 | * if you open the config dialog and close it from the little (x) button on the title bar, | ||
7 | * you have to hit the button on the keyboard twice for it to open the next time | ||
8 | * | 5 | * |
9 | * | 6 | * |
10 | */ | 7 | */ |
11 | 8 | ||
12 | #include <qpe/qpeapplication.h> | 9 | #include <qpe/qpeapplication.h> |
13 | #include <qpe/config.h> | 10 | #include <qpe/config.h> |
14 | 11 | ||
15 | #include <qwidget.h> | 12 | #include <qwidget.h> |
16 | #include <qdialog.h> | 13 | #include <qdialog.h> |
17 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
18 | #include <qvbox.h> | 15 | #include <qvbox.h> |
19 | #include <qgrid.h> | 16 | #include <qgrid.h> |
20 | #include <qgroupbox.h> | 17 | #include <qgroupbox.h> |
21 | #include <qlabel.h> | 18 | #include <qlabel.h> |
22 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
23 | #include <qsizepolicy.h> | 20 | #include <qsizepolicy.h> |
24 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
25 | #include <qcombobox.h> | 22 | #include <qlistbox.h> |
26 | #include "configdlg.h" | 23 | #include "configdlg.h" |
27 | #include "keyboard.h" | 24 | #include "keyboard.h" |
28 | 25 | ||
29 | ConfigDlg::ConfigDlg () : QTabWidget () | 26 | ConfigDlg::ConfigDlg () : QTabWidget () |
30 | { | 27 | { |
31 | setCaption( tr("Multikey Configuration") ); | 28 | setCaption( tr("Multikey Configuration") ); |
32 | 29 | ||
33 | /* | 30 | /* |
34 | * 'general config' tab | 31 | * 'general config' tab |
35 | */ | 32 | */ |
36 | 33 | ||
37 | QVBox *gen_box = new QVBox (this); | 34 | QVBox *gen_box = new QVBox (this); |
38 | gen_box->setMargin(3); | 35 | gen_box->setMargin(3); |
39 | addTab(gen_box, tr("General Settings")); | 36 | addTab(gen_box, tr("General Settings")); |
40 | 37 | ||
41 | QGroupBox *map_group = new QGroupBox (2, Qt::Horizontal, tr("Keymap File"), gen_box); | 38 | QGroupBox *map_group = new QGroupBox (2, Qt::Vertical, tr("Keymap File"), gen_box); |
42 | 39 | ||
43 | map_combo = new QComboBox ((bool)0, map_group); | 40 | keymaps = new QListBox (map_group); |
44 | map_combo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 41 | keymaps->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
42 | //keymaps->setMaximumHeight(150); | ||
45 | 43 | ||
46 | QString cur(tr("Current Language")); | 44 | QString cur(tr("Current Language")); |
47 | map_combo->insertItem(cur); | 45 | keymaps->insertItem(cur); |
48 | connect(map_combo, SIGNAL(activated(int)), SLOT(setMap(int))); | 46 | connect(keymaps, SIGNAL(highlighted(int)), SLOT(setMap(int))); |
49 | 47 | ||
50 | QString ko(tr(QPEApplication::qpeDir() + "/share/multikey/ko.keymap")); | 48 | QString ko(QPEApplication::qpeDir() + "/share/multikey/ko.keymap"); |
51 | map_combo->insertItem(ko); | 49 | keymaps->insertItem(ko); |
52 | 50 | ||
53 | QString en(tr(QPEApplication::qpeDir() + "/share/multikey/en.keymap")); | 51 | QString en(QPEApplication::qpeDir() + "/share/multikey/en.keymap"); |
54 | map_combo->insertItem(en); | 52 | keymaps->insertItem(en); |
55 | 53 | ||
56 | QString de(tr(QPEApplication::qpeDir() + "/share/multikey/de.keymap")); | 54 | QString de(QPEApplication::qpeDir() + "/share/multikey/de.keymap"); |
57 | map_combo->insertItem(de); | 55 | keymaps->insertItem(de); |
58 | 56 | ||
59 | QPushButton *button = new QPushButton(tr("Browse..."), map_group); | 57 | QGrid *add_remove_grid = new QGrid(2, map_group); |
60 | button->setFlat((bool)1); | 58 | add_remove_grid->setMargin(3); |
59 | add_remove_grid->setSpacing(3); | ||
60 | |||
61 | add_button = new QPushButton(tr("Add"), add_remove_grid); | ||
62 | add_button->setFlat((bool)1); | ||
63 | |||
64 | remove_button = new QPushButton(tr("Remove"), add_remove_grid); | ||
65 | remove_button->setFlat((bool)1); | ||
61 | 66 | ||
62 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); | 67 | pick_button = new QCheckBox(tr("Pickboard"), gen_box); |
63 | 68 | ||
64 | Config config ("multikey"); | 69 | Config config ("multikey"); |
65 | config.setGroup ("pickboard"); | 70 | config.setGroup ("pickboard"); |
66 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed | 71 | bool pick_open = config.readBoolEntry ("open", "0"); // default closed |
67 | if (pick_open) { | 72 | if (pick_open) { |
68 | 73 | ||
69 | pick_button->setChecked(true); | 74 | pick_button->setChecked(true); |
70 | } | 75 | } |
71 | 76 | ||
72 | // by connecting it after checking it, the signal isn't emmited | 77 | // by connecting it after checking it, the signal isn't emmited |
73 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); | 78 | connect (pick_button, SIGNAL(clicked()), this, SLOT(pickTog())); |
74 | 79 | ||
75 | /* | 80 | /* |
76 | * 'color' tab | 81 | * 'color' tab |
77 | */ | 82 | */ |
78 | 83 | ||
79 | QGrid *color_box = new QGrid(2, this); | 84 | QGrid *color_box = new QGrid(2, this); |
80 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); | 85 | color_box->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); |
81 | color_box->setMargin(3); | 86 | color_box->setMargin(3); |
87 | color_box->setSpacing(3); | ||
82 | addTab(color_box, tr("Colors")); | 88 | addTab(color_box, tr("Colors")); |
83 | 89 | ||
84 | QLabel *label; | 90 | QLabel *label; |
85 | 91 | ||
86 | label = new QLabel(tr("Key Color"), color_box); | 92 | label = new QLabel(tr("Key Color"), color_box); |
87 | button = new QPushButton(color_box); | 93 | QPushButton *button = new QPushButton(color_box); |
88 | button->setFlat((bool)1); | 94 | button->setFlat((bool)1); |
89 | label = new QLabel(tr("Key Pressed Color"), color_box); | 95 | label = new QLabel(tr("Key Pressed Color"), color_box); |
90 | button = new QPushButton(color_box); | 96 | button = new QPushButton(color_box); |
91 | button->setFlat((bool)1); | 97 | button->setFlat((bool)1); |
92 | label = new QLabel(tr("Line Color"), color_box); | 98 | label = new QLabel(tr("Line Color"), color_box); |
93 | button = new QPushButton(color_box); | 99 | button = new QPushButton(color_box); |
94 | button->setFlat((bool)1); | 100 | button->setFlat((bool)1); |
95 | label = new QLabel(tr("Text Color"), color_box); | 101 | label = new QLabel(tr("Text Color"), color_box); |
96 | button = new QPushButton(color_box); | 102 | button = new QPushButton(color_box); |
97 | button->setFlat((bool)1); | 103 | button->setFlat((bool)1); |
98 | 104 | ||
99 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand | 105 | label = new QLabel("", color_box); // a spacer so the above buttons dont expand |
100 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 106 | label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
101 | 107 | ||
102 | } | 108 | } |
103 | 109 | ||
104 | void ConfigDlg::pickTog() { | 110 | void ConfigDlg::pickTog() { |
105 | 111 | ||
106 | Config config ("multikey"); | 112 | Config config ("multikey"); |
107 | config.setGroup ("pickboard"); | 113 | config.setGroup ("pickboard"); |
108 | config.writeEntry ("open", pick_button->isChecked()); // default closed | 114 | config.writeEntry ("open", pick_button->isChecked()); // default closed |
109 | 115 | ||
110 | emit pickboardToggled(pick_button->isChecked()); | 116 | emit pickboardToggled(pick_button->isChecked()); |
111 | } | 117 | } |
112 | 118 | ||
113 | void ConfigDlg::setMap(int index) { | 119 | void ConfigDlg::setMap(int index) { |
114 | 120 | ||
115 | if (index == 0) { | 121 | if (index == 0) { |
116 | 122 | ||
123 | if (remove_button->isEnabled()) | ||
124 | remove_button->setDisabled(true); | ||
125 | |||
117 | emit setMapToDefault(); | 126 | emit setMapToDefault(); |
118 | } | 127 | } |
119 | else { | 128 | else { |
120 | 129 | ||
121 | emit setMapToFile(map_combo->text(index)); | 130 | if (!remove_button->isEnabled()) |
131 | remove_button->setEnabled(true); | ||
132 | |||
133 | emit setMapToFile(keymaps->text(index)); | ||
122 | } | 134 | } |
123 | } | 135 | } |
136 | |||
137 | void ConfigDlg::addMap() { | ||
138 | |||
139 | } | ||
140 | |||
141 | void ConfigDlg::removeMap(int index) { | ||
142 | |||
143 | } | ||
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h index 54127a0..1a64764 100644 --- a/inputmethods/multikey/configdlg.h +++ b/inputmethods/multikey/configdlg.h | |||
@@ -1,31 +1,36 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <qtabwidget.h> | 2 | #include <qtabwidget.h> |
3 | #include <qcheckbox.h> | 3 | #include <qcheckbox.h> |
4 | #include <qcombobox.h> | 4 | #include <qlistbox.h> |
5 | #include <qpushbutton.h> | ||
5 | 6 | ||
6 | #ifndef CONFIGDLG_H | 7 | #ifndef CONFIGDLG_H |
7 | #define CONFIGDLG_H | 8 | #define CONFIGDLG_H |
8 | 9 | ||
9 | class ConfigDlg : public QTabWidget | 10 | class ConfigDlg : public QTabWidget |
10 | { | 11 | { |
11 | Q_OBJECT | 12 | Q_OBJECT |
12 | 13 | ||
13 | public: | 14 | public: |
14 | ConfigDlg (); | 15 | ConfigDlg (); |
15 | 16 | ||
16 | signals: | 17 | signals: |
17 | void pickboardToggled(bool on_off); | 18 | void pickboardToggled(bool on_off); |
18 | void setMapToDefault(); | 19 | void setMapToDefault(); |
19 | void setMapToFile(QString file); | 20 | void setMapToFile(QString file); |
20 | 21 | ||
21 | private slots: | 22 | private slots: |
22 | void pickTog(); | 23 | void pickTog(); |
23 | void setMap(int index); | 24 | void setMap(int index); |
25 | void addMap(); | ||
26 | void removeMap(int index); | ||
24 | 27 | ||
25 | private: | 28 | private: |
26 | QCheckBox *pick_button; | 29 | QCheckBox *pick_button; |
27 | QComboBox *map_combo; | 30 | QListBox *keymaps; |
31 | QPushButton *add_button; | ||
32 | QPushButton *remove_button; | ||
28 | 33 | ||
29 | }; | 34 | }; |
30 | 35 | ||
31 | #endif | 36 | #endif |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 2a80f1e..b71f929 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,1065 +1,1071 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
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 <iostream.h> | ||
37 | 36 | ||
38 | #include <sys/utsname.h> | 37 | #include <sys/utsname.h> |
39 | 38 | ||
40 | 39 | ||
41 | #define USE_SMALL_BACKSPACE | 40 | #define USE_SMALL_BACKSPACE |
42 | 41 | ||
43 | /* Keyboard::Keyboard {{{1 */ | 42 | /* Keyboard::Keyboard {{{1 */ |
44 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
45 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), |
46 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), | 45 | alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), |
47 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 46 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
48 | configdlg(0) | 47 | configdlg(0) |
49 | 48 | ||
50 | { | 49 | { |
51 | // get the default font | 50 | // get the default font |
52 | Config *config = new Config( "qpe" ); | 51 | Config *config = new Config( "qpe" ); |
53 | config->setGroup( "Appearance" ); | 52 | config->setGroup( "Appearance" ); |
54 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); | 53 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); |
55 | delete config; | 54 | delete config; |
56 | 55 | ||
57 | config = new Config("multikey"); | 56 | config = new Config("multikey"); |
58 | config->setGroup ("pickboard"); | 57 | config->setGroup ("pickboard"); |
59 | usePicks = config->readBoolEntry ("open", "0"); // default closed | 58 | usePicks = config->readBoolEntry ("open", "0"); // default closed |
60 | delete config; | 59 | delete config; |
61 | 60 | ||
62 | setFont( QFont( familyStr, 10 ) ); | 61 | setFont( QFont( familyStr, 10 ) ); |
63 | 62 | ||
64 | picks = new KeyboardPicks( this ); | 63 | picks = new KeyboardPicks( this ); |
65 | picks->setFont( QFont( familyStr, 10 ) ); | 64 | picks->setFont( QFont( familyStr, 10 ) ); |
66 | picks->initialise(); | 65 | picks->initialise(); |
67 | if (usePicks) { | 66 | if (usePicks) { |
68 | 67 | ||
69 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 68 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
70 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 69 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
71 | 70 | ||
72 | } else picks->hide(); | 71 | } else picks->hide(); |
73 | 72 | ||
74 | keys = new Keys(); | 73 | keys = new Keys(); |
75 | 74 | ||
76 | repeatTimer = new QTimer( this ); | 75 | repeatTimer = new QTimer( this ); |
77 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 76 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
78 | 77 | ||
79 | } | 78 | } |
79 | Keyboard::~Keyboard() { | ||
80 | |||
81 | if ( configdlg ) { | ||
82 | delete (ConfigDlg *) configdlg; | ||
83 | configdlg = 0; | ||
84 | } | ||
85 | |||
86 | } | ||
80 | 87 | ||
81 | /* Keyboard::resizeEvent {{{1 */ | 88 | /* Keyboard::resizeEvent {{{1 */ |
82 | void Keyboard::resizeEvent(QResizeEvent*) | 89 | void Keyboard::resizeEvent(QResizeEvent*) |
83 | { | 90 | { |
84 | int ph = picks->sizeHint().height(); | 91 | int ph = picks->sizeHint().height(); |
85 | picks->setGeometry( 0, 0, width(), ph ); | 92 | picks->setGeometry( 0, 0, width(), ph ); |
86 | keyHeight = (height()-(usePicks ? ph : 0))/5; | 93 | keyHeight = (height()-(usePicks ? ph : 0))/5; |
87 | 94 | ||
88 | int nk; // number of keys? | 95 | int nk; // number of keys? |
89 | if ( useLargeKeys ) { | 96 | if ( useLargeKeys ) { |
90 | nk = 15; | 97 | nk = 15; |
91 | } else { | 98 | } else { |
92 | nk = 19; | 99 | nk = 19; |
93 | } | 100 | } |
94 | defaultKeyWidth = (width()/nk)/2; | 101 | defaultKeyWidth = (width()/nk)/2; |
95 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 102 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
96 | 103 | ||
97 | } | 104 | } |
98 | 105 | ||
99 | /* KeyboardPicks::initialize {{{1 */ | 106 | /* KeyboardPicks::initialize {{{1 */ |
100 | void KeyboardPicks::initialise() | 107 | void KeyboardPicks::initialise() |
101 | { | 108 | { |
102 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 109 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
103 | mode = 0; | 110 | mode = 0; |
104 | dc = new KeyboardConfig(this); | 111 | dc = new KeyboardConfig(this); |
105 | configs.append(dc); | 112 | configs.append(dc); |
106 | } | 113 | } |
107 | 114 | ||
108 | /* KeyboardPicks::sizeHint {{{1 */ | 115 | /* KeyboardPicks::sizeHint {{{1 */ |
109 | QSize KeyboardPicks::sizeHint() const | 116 | QSize KeyboardPicks::sizeHint() const |
110 | { | 117 | { |
111 | return QSize(240,fontMetrics().lineSpacing()); | 118 | return QSize(240,fontMetrics().lineSpacing()); |
112 | } | 119 | } |
113 | 120 | ||
114 | 121 | ||
115 | /* KeyboardConfig::generateText {{{1 */ | 122 | /* KeyboardConfig::generateText {{{1 */ |
116 | void KeyboardConfig::generateText(const QString &s) | 123 | void KeyboardConfig::generateText(const QString &s) |
117 | { | 124 | { |
118 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 125 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
119 | for (int i=0; i<(int)backspaces; i++) { | 126 | for (int i=0; i<(int)backspaces; i++) { |
120 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 127 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
121 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 128 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
122 | } | 129 | } |
123 | for (int i=0; i<(int)s.length(); i++) { | 130 | for (int i=0; i<(int)s.length(); i++) { |
124 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 131 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
125 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 132 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
126 | } | 133 | } |
127 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 134 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
128 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 135 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
129 | backspaces = 0; | 136 | backspaces = 0; |
130 | #endif | 137 | #endif |
131 | } | 138 | } |
132 | 139 | ||
133 | 140 | ||
134 | 141 | ||
135 | 142 | ||
136 | /* Keyboard::paintEvent {{{1 */ | 143 | /* Keyboard::paintEvent {{{1 */ |
137 | void Keyboard::paintEvent(QPaintEvent* e) | 144 | void Keyboard::paintEvent(QPaintEvent* e) |
138 | { | 145 | { |
139 | QPainter painter(this); | 146 | QPainter painter(this); |
140 | painter.setClipRect(e->rect()); | 147 | painter.setClipRect(e->rect()); |
141 | drawKeyboard( painter ); | 148 | drawKeyboard( painter ); |
142 | picks->dc->draw( &painter ); | 149 | picks->dc->draw( &painter ); |
143 | } | 150 | } |
144 | 151 | ||
145 | 152 | ||
146 | /* Keyboard::drawKeyboard {{{1 */ | 153 | /* Keyboard::drawKeyboard {{{1 */ |
147 | 154 | ||
148 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 155 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
149 | { | 156 | { |
150 | QColor keycolor = | 157 | QColor keycolor = |
151 | QColor(240,240,240); | 158 | QColor(240,240,240); |
152 | QColor keycolor_pressed = QColor(171,183,198); | 159 | QColor keycolor_pressed = QColor(171,183,198); |
153 | QColor keycolor_lines = QColor(138,148,160); | 160 | QColor keycolor_lines = QColor(138,148,160); |
154 | QColor textcolor = QColor(43,54,68); | 161 | QColor textcolor = QColor(43,54,68); |
155 | 162 | ||
156 | 163 | ||
157 | if (row != -1 && col != -1) { //just redraw one key | 164 | if (row != -1 && col != -1) { //just redraw one key |
158 | 165 | ||
159 | int x = 0; | 166 | int x = 0; |
160 | for (int i = 0; i < col; i++) { | 167 | for (int i = 0; i < col; i++) { |
161 | 168 | ||
162 | x += keys->width(row, i) * defaultKeyWidth; | 169 | x += keys->width(row, i) * defaultKeyWidth; |
163 | } | 170 | } |
164 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 171 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
165 | 172 | ||
166 | int keyWidth = keys->width(row, col); | 173 | int keyWidth = keys->width(row, col); |
167 | 174 | ||
168 | p.fillRect(x + 1, y + 1, | 175 | p.fillRect(x + 1, y + 1, |
169 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 176 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
170 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 177 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
171 | 178 | ||
172 | QPixmap *pix = keys->pix(row,col); | 179 | QPixmap *pix = keys->pix(row,col); |
173 | 180 | ||
174 | ushort c = keys->uni(row, col); | 181 | ushort c = keys->uni(row, col); |
175 | 182 | ||
176 | if (!pix) { | 183 | if (!pix) { |
177 | p.setPen(textcolor); | 184 | p.setPen(textcolor); |
178 | p.drawText(x, y, | 185 | p.drawText(x, y, |
179 | defaultKeyWidth * keyWidth, keyHeight, | 186 | defaultKeyWidth * keyWidth, keyHeight, |
180 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); | 187 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); |
181 | } | 188 | } |
182 | else | 189 | else |
183 | // center the image in the middle of the key | 190 | // center the image in the middle of the key |
184 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, | 191 | p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, |
185 | y + (keyHeight - pix->height())/2 + 1, | 192 | y + (keyHeight - pix->height())/2 + 1, |
186 | *pix ); | 193 | *pix ); |
187 | 194 | ||
188 | // this fixes the problem that the very right end of the board's vertical line | 195 | // this fixes the problem that the very right end of the board's vertical line |
189 | // gets painted over, because it's one pixel shorter than all other keys | 196 | // gets painted over, because it's one pixel shorter than all other keys |
190 | p.setPen(keycolor_lines); | 197 | p.setPen(keycolor_lines); |
191 | p.drawLine(width() - 1, 0, width() - 1, height()); | 198 | p.drawLine(width() - 1, 0, width() - 1, height()); |
192 | 199 | ||
193 | } else { | 200 | } else { |
194 | 201 | ||
195 | 202 | ||
196 | p.fillRect(0, 0, width(), height(), keycolor); | 203 | p.fillRect(0, 0, width(), height(), keycolor); |
197 | 204 | ||
198 | for (row = 1; row <= 5; row++) { | 205 | for (row = 1; row <= 5; row++) { |
199 | 206 | ||
200 | int x = 0; | 207 | int x = 0; |
201 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 208 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
202 | 209 | ||
203 | p.setPen(keycolor_lines); | 210 | p.setPen(keycolor_lines); |
204 | p.drawLine(x, y, x + width(), y); | 211 | p.drawLine(x, y, x + width(), y); |
205 | 212 | ||
206 | for (int col = 0; col < keys->numKeys(row); col++) { | 213 | for (int col = 0; col < keys->numKeys(row); col++) { |
207 | 214 | ||
208 | QPixmap *pix = keys->pix(row, col); | 215 | QPixmap *pix = keys->pix(row, col); |
209 | int keyWidth = keys->width(row, col); | 216 | int keyWidth = keys->width(row, col); |
210 | 217 | ||
211 | 218 | ||
212 | int keyWidthPix = defaultKeyWidth * keyWidth; | 219 | int keyWidthPix = defaultKeyWidth * keyWidth; |
213 | 220 | ||
214 | if (keys->pressed(row, col)) | 221 | if (keys->pressed(row, col)) |
215 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 222 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
216 | keyHeight - 1, keycolor_pressed); | 223 | keyHeight - 1, keycolor_pressed); |
217 | 224 | ||
218 | ushort c = keys->uni(row, col); | 225 | ushort c = keys->uni(row, col); |
219 | 226 | ||
220 | if (!pix) { | 227 | if (!pix) { |
221 | p.setPen(textcolor); | 228 | p.setPen(textcolor); |
222 | p.drawText(x, y, | 229 | p.drawText(x, y, |
223 | keyWidthPix, keyHeight, | 230 | keyWidthPix, keyHeight, |
224 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); | 231 | AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); |
225 | } | 232 | } |
226 | else { | 233 | else { |
227 | // center the image in the middle of the key | 234 | // center the image in the middle of the key |
228 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, | 235 | p.drawPixmap( x + (keyWidthPix - pix->width())/2, |
229 | y + (keyHeight - pix->height())/2 + 1, | 236 | y + (keyHeight - pix->height())/2 + 1, |
230 | QPixmap(*pix) ); | 237 | QPixmap(*pix) ); |
231 | } | 238 | } |
232 | 239 | ||
233 | p.setPen(keycolor_lines); | 240 | p.setPen(keycolor_lines); |
234 | p.drawLine(x, y, x, y + keyHeight); | 241 | p.drawLine(x, y, x, y + keyHeight); |
235 | 242 | ||
236 | x += keyWidthPix; | 243 | x += keyWidthPix; |
237 | } | 244 | } |
238 | 245 | ||
239 | 246 | ||
240 | } | 247 | } |
241 | p.drawLine(0, height() - 1, width(), height() - 1); | 248 | p.drawLine(0, height() - 1, width(), height() - 1); |
242 | p.drawLine(width() - 1, 0, width() - 1, height()); | 249 | p.drawLine(width() - 1, 0, width() - 1, height()); |
243 | } | 250 | } |
244 | 251 | ||
245 | } | 252 | } |
246 | 253 | ||
247 | 254 | ||
248 | /* Keyboard::mousePressEvent {{{1 */ | 255 | /* Keyboard::mousePressEvent {{{1 */ |
249 | void Keyboard::mousePressEvent(QMouseEvent *e) | 256 | void Keyboard::mousePressEvent(QMouseEvent *e) |
250 | { | 257 | { |
251 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 258 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
252 | if (row > 5) row = 5; | 259 | if (row > 5) row = 5; |
253 | 260 | ||
254 | // figure out the column | 261 | // figure out the column |
255 | int col = 0; | 262 | int col = 0; |
256 | for (int w = 0; e->x() >= w; col++) | 263 | for (int w = 0; e->x() >= w; col++) |
257 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 264 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
258 | w += keys->width(row,col) * defaultKeyWidth; | 265 | w += keys->width(row,col) * defaultKeyWidth; |
259 | else break; | 266 | else break; |
260 | 267 | ||
261 | col --; // rewind one... | 268 | col --; // rewind one... |
262 | 269 | ||
263 | qkeycode = keys->qcode(row, col); | 270 | qkeycode = keys->qcode(row, col); |
264 | unicode = keys->uni(row, col); | 271 | unicode = keys->uni(row, col); |
265 | 272 | ||
266 | // might need to repaint if two or more of the same keys. | 273 | // might need to repaint if two or more of the same keys. |
267 | // should be faster if just paint one key even though multiple keys exist. | 274 | // should be faster if just paint one key even though multiple keys exist. |
268 | bool need_repaint = FALSE; | 275 | bool need_repaint = FALSE; |
269 | 276 | ||
270 | if (unicode == 0) { // either Qt char, or nothing | 277 | if (unicode == 0) { // either Qt char, or nothing |
271 | 278 | ||
272 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 279 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
273 | 280 | ||
274 | if ( configdlg ) { | 281 | if ( configdlg ) { |
275 | delete (ConfigDlg *) configdlg; | 282 | delete (ConfigDlg *) configdlg; |
276 | configdlg = 0; | 283 | configdlg = 0; |
277 | } | 284 | } |
278 | else { | 285 | else { |
279 | configdlg = new ConfigDlg (); | 286 | configdlg = new ConfigDlg (); |
280 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 287 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
281 | this, SLOT(togglePickboard(bool))); | 288 | this, SLOT(togglePickboard(bool))); |
282 | connect(configdlg, SIGNAL(setMapToDefault()), | 289 | connect(configdlg, SIGNAL(setMapToDefault()), |
283 | this, SLOT(setMapToDefault())); | 290 | this, SLOT(setMapToDefault())); |
284 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 291 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
285 | this, SLOT(setMapToFile(QString))); | 292 | this, SLOT(setMapToFile(QString))); |
286 | configdlg->showMaximized(); | 293 | configdlg->showMaximized(); |
287 | configdlg->show(); | 294 | configdlg->show(); |
288 | configdlg->raise(); | 295 | configdlg->raise(); |
289 | } | 296 | } |
290 | 297 | ||
291 | } else if (qkeycode == Qt::Key_Control) { | 298 | } else if (qkeycode == Qt::Key_Control) { |
292 | ctrl = keys->pressedPtr(row, col); | 299 | ctrl = keys->pressedPtr(row, col); |
293 | need_repaint = TRUE; | 300 | need_repaint = TRUE; |
294 | *ctrl = !keys->pressed(row, col); | 301 | *ctrl = !keys->pressed(row, col); |
295 | 302 | ||
296 | } else if (qkeycode == Qt::Key_Alt) { | 303 | } else if (qkeycode == Qt::Key_Alt) { |
297 | alt = keys->pressedPtr(row, col); | 304 | alt = keys->pressedPtr(row, col); |
298 | need_repaint = TRUE; | 305 | need_repaint = TRUE; |
299 | *alt = !keys->pressed(row, col); | 306 | *alt = !keys->pressed(row, col); |
300 | 307 | ||
301 | } else if (qkeycode == Qt::Key_Shift) { | 308 | } else if (qkeycode == Qt::Key_Shift) { |
302 | need_repaint = TRUE; | 309 | need_repaint = TRUE; |
303 | 310 | ||
304 | if (shift) { | 311 | if (shift) { |
305 | *shift = 0; | 312 | *shift = 0; |
306 | shift = 0; | 313 | shift = 0; |
307 | } | 314 | } |
308 | else { | 315 | else { |
309 | shift = keys->pressedPtr(row, col); | 316 | shift = keys->pressedPtr(row, col); |
310 | *shift = 1; | 317 | *shift = 1; |
311 | if (lock) { | 318 | if (lock) { |
312 | *lock = 0; | 319 | *lock = 0; |
313 | lock = 0; | 320 | lock = 0; |
314 | } | 321 | } |
315 | } | 322 | } |
316 | 323 | ||
317 | } else if (qkeycode == Qt::Key_CapsLock) { | 324 | } else if (qkeycode == Qt::Key_CapsLock) { |
318 | need_repaint = TRUE; | 325 | need_repaint = TRUE; |
319 | 326 | ||
320 | if (lock) { | 327 | if (lock) { |
321 | *lock = 0; | 328 | *lock = 0; |
322 | lock = 0; | 329 | lock = 0; |
323 | } | 330 | } |
324 | else { | 331 | else { |
325 | lock = keys->pressedPtr(row, col);; | 332 | lock = keys->pressedPtr(row, col);; |
326 | *lock = 1; | 333 | *lock = 1; |
327 | if (shift) { | 334 | if (shift) { |
328 | *shift = 0; | 335 | *shift = 0; |
329 | shift = 0; | 336 | shift = 0; |
330 | } | 337 | } |
331 | } | 338 | } |
332 | 339 | ||
333 | } | 340 | } |
334 | 341 | ||
335 | } | 342 | } |
336 | else { // normal char | 343 | else { // normal char |
337 | if ((shift || lock) && keys->shift(unicode)) { | 344 | if ((shift || lock) && keys->shift(unicode)) { |
338 | unicode = keys->shift(unicode); | 345 | unicode = keys->shift(unicode); |
339 | } | 346 | } |
340 | } | 347 | } |
341 | 348 | ||
342 | // korean parsing | 349 | // korean parsing |
343 | if (keys->lang == "ko") { | 350 | if (keys->lang == "ko") { |
344 | 351 | ||
345 | unicode = parseKoreanInput(unicode); | 352 | unicode = parseKoreanInput(unicode); |
346 | } | 353 | } |
347 | 354 | ||
348 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 355 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
349 | 356 | ||
350 | emit key(unicode, qkeycode, modifiers, true, false); | 357 | emit key(unicode, qkeycode, modifiers, true, false); |
351 | 358 | ||
352 | // pickboard stuff | 359 | // pickboard stuff |
353 | if (usePicks) { | 360 | if (usePicks) { |
354 | 361 | ||
355 | KeyboardConfig *dc = picks->dc; | 362 | KeyboardConfig *dc = picks->dc; |
356 | 363 | ||
357 | if (dc) { | 364 | if (dc) { |
358 | if (qkeycode == Qt::Key_Backspace) { | 365 | if (qkeycode == Qt::Key_Backspace) { |
359 | dc->input.remove(dc->input.last()); // remove last input | 366 | dc->input.remove(dc->input.last()); // remove last input |
360 | dc->decBackspaces(); | 367 | dc->decBackspaces(); |
361 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 368 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
362 | dc->input.clear(); | 369 | dc->input.clear(); |
363 | dc->resetBackspaces(); | 370 | dc->resetBackspaces(); |
364 | } else { | 371 | } else { |
365 | dc->add(QString(QChar(unicode))); | 372 | dc->add(QString(QChar(unicode))); |
366 | dc->incBackspaces(); | 373 | dc->incBackspaces(); |
367 | } | 374 | } |
368 | } | 375 | } |
369 | picks->repaint(); | 376 | picks->repaint(); |
370 | } | 377 | } |
371 | 378 | ||
372 | 379 | ||
373 | // painting | 380 | // painting |
374 | pressed = TRUE; | 381 | pressed = TRUE; |
375 | 382 | ||
376 | pressedKeyRow = row; | 383 | pressedKeyRow = row; |
377 | pressedKeyCol = col; | 384 | pressedKeyCol = col; |
378 | 385 | ||
379 | if (need_repaint) repaint(FALSE); | 386 | if (need_repaint) repaint(FALSE); |
380 | else { // just paint the one key pressed | 387 | else { // just paint the one key pressed |
381 | 388 | ||
382 | 389 | ||
383 | 390 | ||
384 | QPainter p(this); | 391 | QPainter p(this); |
385 | drawKeyboard(p, row, col); | 392 | drawKeyboard(p, row, col); |
386 | 393 | ||
387 | } | 394 | } |
388 | 395 | ||
389 | pressTid = startTimer(80); | 396 | pressTid = startTimer(80); |
390 | 397 | ||
391 | } | 398 | } |
392 | 399 | ||
393 | 400 | ||
394 | /* Keyboard::mouseReleaseEvent {{{1 */ | 401 | /* Keyboard::mouseReleaseEvent {{{1 */ |
395 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 402 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
396 | { | 403 | { |
397 | pressed = FALSE; | 404 | pressed = FALSE; |
398 | if ( pressTid == 0 ) | 405 | if ( pressTid == 0 ) |
399 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 406 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
400 | if ( unicode != -1 ) { | 407 | if ( unicode != -1 ) { |
401 | emit key( unicode, qkeycode, modifiers, false, false ); | 408 | emit key( unicode, qkeycode, modifiers, false, false ); |
402 | repeatTimer->stop(); | 409 | repeatTimer->stop(); |
403 | } | 410 | } |
404 | #endif | 411 | #endif |
405 | if (shift && unicode != 0) { | 412 | if (shift && unicode != 0) { |
406 | 413 | ||
407 | 414 | ||
408 | *shift = 0; // unpress shift key | 415 | *shift = 0; // unpress shift key |
409 | shift = 0; // reset the shift pointer | 416 | shift = 0; // reset the shift pointer |
410 | repaint(FALSE); | 417 | repaint(FALSE); |
411 | 418 | ||
412 | } | 419 | } |
413 | else | 420 | else |
414 | 421 | ||
415 | clearHighlight(); | 422 | clearHighlight(); |
416 | } | 423 | } |
417 | 424 | ||
418 | /* Keyboard::timerEvent {{{1 */ | 425 | /* Keyboard::timerEvent {{{1 */ |
419 | /* | 426 | /* |
420 | void Keyboard::timerEvent(QTimerEvent* e) | 427 | void Keyboard::timerEvent(QTimerEvent* e) |
421 | { | 428 | { |
422 | if ( e->timerId() == pressTid ) { | 429 | if ( e->timerId() == pressTid ) { |
423 | killTimer(pressTid); | 430 | killTimer(pressTid); |
424 | pressTid = 0; | 431 | pressTid = 0; |
425 | if ( !pressed ) | 432 | if ( !pressed ) |
426 | cout << "calling clearHighlight from timerEvent\n"; | 433 | cout << "calling clearHighlight from timerEvent\n"; |
427 | clearHighlight(); | 434 | clearHighlight(); |
428 | } | 435 | } |
429 | } | 436 | } |
430 | */ | 437 | */ |
431 | 438 | ||
432 | void Keyboard::repeat() | 439 | void Keyboard::repeat() |
433 | { | 440 | { |
434 | 441 | ||
435 | repeatTimer->start( 200 ); | 442 | repeatTimer->start( 200 ); |
436 | emit key( unicode, 0, modifiers, true, true ); | 443 | emit key( unicode, 0, modifiers, true, true ); |
437 | } | 444 | } |
438 | 445 | ||
439 | void Keyboard::clearHighlight() | 446 | void Keyboard::clearHighlight() |
440 | { | 447 | { |
441 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 448 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
442 | int tmpRow = pressedKeyRow; | 449 | int tmpRow = pressedKeyRow; |
443 | int tmpCol = pressedKeyCol; | 450 | int tmpCol = pressedKeyCol; |
444 | 451 | ||
445 | pressedKeyRow = -1; | 452 | pressedKeyRow = -1; |
446 | pressedKeyCol = -1; | 453 | pressedKeyCol = -1; |
447 | 454 | ||
448 | QPainter p(this); | 455 | QPainter p(this); |
449 | drawKeyboard(p, tmpRow, tmpCol); | 456 | drawKeyboard(p, tmpRow, tmpCol); |
450 | } | 457 | } |
451 | } | 458 | } |
452 | 459 | ||
453 | 460 | ||
454 | /* Keyboard::sizeHint {{{1 */ | 461 | /* Keyboard::sizeHint {{{1 */ |
455 | QSize Keyboard::sizeHint() const | 462 | QSize Keyboard::sizeHint() const |
456 | { | 463 | { |
457 | QFontMetrics fm=fontMetrics(); | 464 | QFontMetrics fm=fontMetrics(); |
458 | int keyHeight = fm.lineSpacing() + 2; | 465 | int keyHeight = fm.lineSpacing() + 2; |
459 | 466 | ||
460 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); | 467 | return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); |
461 | } | 468 | } |
462 | 469 | ||
463 | 470 | ||
464 | void Keyboard::resetState() | 471 | void Keyboard::resetState() |
465 | { | 472 | { |
466 | schar = mchar = echar = 0; | 473 | schar = mchar = echar = 0; |
467 | picks->resetState(); | 474 | picks->resetState(); |
468 | } | 475 | } |
469 | 476 | ||
470 | /* Keyboard::togglePickboard {{{1 */ | 477 | /* Keyboard::togglePickboard {{{1 */ |
471 | void Keyboard::togglePickboard(bool on_off) | 478 | void Keyboard::togglePickboard(bool on_off) |
472 | { | 479 | { |
473 | usePicks = on_off; | 480 | usePicks = on_off; |
474 | if (usePicks) { | 481 | if (usePicks) { |
475 | picks->show(); | 482 | picks->show(); |
476 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 483 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
477 | //adjustSize(); | 484 | //adjustSize(); |
478 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 485 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
479 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 486 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
480 | } else { | 487 | } else { |
481 | 488 | ||
482 | picks->hide(); | 489 | picks->hide(); |
483 | picks->resetState(); | 490 | picks->resetState(); |
484 | //move(x(), y() + picks->height()); | 491 | //move(x(), y() + picks->height()); |
485 | //adjustSize(); | 492 | //adjustSize(); |
486 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 493 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
487 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 494 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
488 | 495 | ||
489 | } | 496 | } |
490 | /* | 497 | /* |
491 | * this closes && opens the input method | 498 | * this closes && opens the input method |
492 | */ | 499 | */ |
493 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 500 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
494 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 501 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
495 | } | 502 | } |
496 | 503 | ||
497 | /* Keyboard::setMapTo ... {{{1 */ | 504 | /* Keyboard::setMapTo ... {{{1 */ |
498 | void Keyboard::setMapToDefault() { | 505 | void Keyboard::setMapToDefault() { |
499 | 506 | ||
500 | 507 | ||
501 | /* load current locale language map */ | 508 | /* load current locale language map */ |
502 | Config *config = new Config("locale"); | 509 | Config *config = new Config("locale"); |
503 | config->setGroup( "Language" ); | 510 | config->setGroup( "Language" ); |
504 | QString l = config->readEntry( "Language" , "en" ); | 511 | QString l = config->readEntry( "Language" , "en" ); |
505 | delete config; | 512 | delete config; |
506 | 513 | ||
507 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" | 514 | QString key_map = QPEApplication::qpeDir() + "/share/multikey/" |
508 | + l + ".keymap"; | 515 | + l + ".keymap"; |
509 | 516 | ||
510 | /* save change to multikey config file */ | 517 | /* save change to multikey config file */ |
511 | config = new Config("multikey"); | 518 | config = new Config("multikey"); |
512 | config->setGroup ("keymaps"); | 519 | config->setGroup ("keymaps"); |
513 | config->writeEntry ("current", key_map); // default closed | 520 | config->writeEntry ("current", key_map); // default closed |
514 | delete config; | 521 | delete config; |
515 | 522 | ||
516 | delete keys; | 523 | delete keys; |
517 | keys = new Keys(key_map); | 524 | keys = new Keys(key_map); |
518 | 525 | ||
519 | // have to repaint the keyboard | 526 | // have to repaint the keyboard |
520 | repaint(FALSE); | 527 | repaint(FALSE); |
521 | } | 528 | } |
522 | 529 | ||
523 | void Keyboard::setMapToFile(QString file) { | 530 | void Keyboard::setMapToFile(QString file) { |
524 | 531 | ||
525 | /* save change to multikey config file */ | 532 | /* save change to multikey config file */ |
526 | Config *config = new Config("multikey"); | 533 | Config *config = new Config("multikey"); |
527 | config->setGroup ("keymaps"); | 534 | config->setGroup ("keymaps"); |
528 | config->writeEntry ("current", file); // default closed | 535 | config->writeEntry ("current", file); // default closed |
529 | delete config; | 536 | delete config; |
530 | 537 | ||
531 | delete keys; | 538 | delete keys; |
532 | keys = new Keys(file); | 539 | keys = new Keys(file); |
533 | repaint(FALSE); | 540 | repaint(FALSE); |
534 | 541 | ||
535 | } | 542 | } |
536 | 543 | ||
537 | /* korean input functions {{{1 | 544 | /* korean input functions {{{1 |
538 | * | 545 | * |
539 | * TODO | 546 | * TODO |
540 | * one major problem with this implementation is that you can't move the | 547 | * one major problem with this implementation is that you can't move the |
541 | * cursor after inputing korean chars, otherwise it will eat up and replace | 548 | * cursor after inputing korean chars, otherwise it will eat up and replace |
542 | * the char before the cursor you move to. fix that | 549 | * the char before the cursor you move to. fix that |
543 | * | 550 | * |
544 | * make backspace delete one single char, not the whole thing if still | 551 | * make backspace delete one single char, not the whole thing if still |
545 | * editing. | 552 | * editing. |
546 | * | 553 | * |
547 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 554 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
548 | * | 555 | * |
549 | * how korean input works | 556 | * how korean input works |
550 | * | 557 | * |
551 | * all following chars means unicode char value and are in hex | 558 | * all following chars means unicode char value and are in hex |
552 | * | 559 | * |
553 | * ÃÊÀ½ = schar (start char) | 560 | * ÃÊÀ½ = schar (start char) |
554 | * ÁßÀ½ = mchar (middle char) | 561 | * ÁßÀ½ = mchar (middle char) |
555 | * ³¡À½ = echar (end char) | 562 | * ³¡À½ = echar (end char) |
556 | * | 563 | * |
557 | * there are 19 schars. unicode position is at 1100 - 1112 | 564 | * there are 19 schars. unicode position is at 1100 - 1112 |
558 | * there are 21 mchars. unicode position is at 1161 - 1175 | 565 | * there are 21 mchars. unicode position is at 1161 - 1175 |
559 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 566 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
560 | * | 567 | * |
561 | * the map with everything combined is at ac00 - d7a3 | 568 | * the map with everything combined is at ac00 - d7a3 |
562 | * | 569 | * |
563 | */ | 570 | */ |
564 | 571 | ||
565 | ushort Keyboard::parseKoreanInput (ushort c) { | 572 | ushort Keyboard::parseKoreanInput (ushort c) { |
566 | 573 | ||
567 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) | 574 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) |
568 | || | 575 | || |
569 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode | 576 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode |
570 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { | 577 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { |
571 | 578 | ||
572 | schar = 0, mchar = 0, echar = 0; | 579 | schar = 0, mchar = 0, echar = 0; |
573 | return c; | 580 | return c; |
574 | } | 581 | } |
575 | 582 | ||
576 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input | 583 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input |
577 | 584 | ||
578 | if (schar == 0 || (schar != 0 && mchar == 0)) { | 585 | if (schar == 0 || (schar != 0 && mchar == 0)) { |
579 | schar = c; mchar = 0; echar = 0; | 586 | schar = c; mchar = 0; echar = 0; |
580 | return c; | 587 | return c; |
581 | } | 588 | } |
582 | else if (mchar != 0) { | 589 | else if (mchar != 0) { |
583 | 590 | ||
584 | if (echar == 0) { | 591 | if (echar == 0) { |
585 | 592 | ||
586 | if (!(echar = constoe(c))) { | 593 | if (!(echar = constoe(c))) { |
587 | 594 | ||
588 | schar = c; mchar = 0; echar = 0; | 595 | schar = c; mchar = 0; echar = 0; |
589 | return c; | 596 | return c; |
590 | } | 597 | } |
591 | 598 | ||
592 | } | 599 | } |
593 | else { // must figure out what the echar is | 600 | else { // must figure out what the echar is |
594 | 601 | ||
595 | if (echar == 0x11a8) { // ¤¡ | 602 | if (echar == 0x11a8) { // ¤¡ |
596 | 603 | ||
597 | if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ | 604 | if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ |
598 | else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ | 605 | else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ |
599 | else { | 606 | else { |
600 | schar = c; mchar = 0; echar = 0; | 607 | schar = c; mchar = 0; echar = 0; |
601 | return c; | 608 | return c; |
602 | } | 609 | } |
603 | 610 | ||
604 | } else if (echar == 0x11ab) { // ¤¤ | 611 | } else if (echar == 0x11ab) { // ¤¤ |
605 | 612 | ||
606 | if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ | 613 | if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ |
607 | else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ | 614 | else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ |
608 | else { | 615 | else { |
609 | schar = c; mchar = 0; echar = 0; | 616 | schar = c; mchar = 0; echar = 0; |
610 | return c; | 617 | return c; |
611 | } | 618 | } |
612 | 619 | ||
613 | } else if (echar == 0x11af) { // ¤© | 620 | } else if (echar == 0x11af) { // ¤© |
614 | 621 | ||
615 | if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ | 622 | if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ |
616 | else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± | 623 | else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± |
617 | else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² | 624 | else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² |
618 | else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ | 625 | else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ |
619 | else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ | 626 | else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ |
620 | else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ | 627 | else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ |
621 | else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ | 628 | else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ |
622 | else { | 629 | else { |
623 | schar = c; mchar = 0; echar = 0; | 630 | schar = c; mchar = 0; echar = 0; |
624 | return c; | 631 | return c; |
625 | } | 632 | } |
626 | 633 | ||
627 | } else if (echar == 0x11b8) { // ¤² | 634 | } else if (echar == 0x11b8) { // ¤² |
628 | 635 | ||
629 | if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ | 636 | if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ |
630 | else { | 637 | else { |
631 | schar = c; mchar = 0; echar = 0; | 638 | schar = c; mchar = 0; echar = 0; |
632 | return c; | 639 | return c; |
633 | } | 640 | } |
634 | 641 | ||
635 | } else if (echar == 0x11ba) { // ¤µ | 642 | } else if (echar == 0x11ba) { // ¤µ |
636 | 643 | ||
637 | if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ | 644 | if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ |
638 | else { | 645 | else { |
639 | schar = c; mchar = 0; echar = 0; | 646 | schar = c; mchar = 0; echar = 0; |
640 | return c; | 647 | return c; |
641 | } | 648 | } |
642 | 649 | ||
643 | } else { // if any other char, cannot combine chars | 650 | } else { // if any other char, cannot combine chars |
644 | 651 | ||
645 | schar = c; mchar = 0; echar = 0; | 652 | schar = c; mchar = 0; echar = 0; |
646 | return c; | 653 | return c; |
647 | } | 654 | } |
648 | 655 | ||
649 | unicode = echar; | 656 | unicode = echar; |
650 | } | 657 | } |
651 | } | 658 | } |
652 | 659 | ||
653 | } | 660 | } |
654 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input | 661 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input |
655 | 662 | ||
656 | if (schar != 0 && mchar == 0) { mchar = c; } | 663 | if (schar != 0 && mchar == 0) { mchar = c; } |
657 | 664 | ||
658 | else if (schar != 0 && mchar != 0 && echar == 0) { | 665 | else if (schar != 0 && mchar != 0 && echar == 0) { |
659 | 666 | ||
660 | switch (mchar) { | 667 | switch (mchar) { |
661 | case 0x1169: | 668 | case 0x1169: |
662 | if (c == 0x1161) mchar = 0x116a; | 669 | if (c == 0x1161) mchar = 0x116a; |
663 | else if (c == 0x1162) mchar = 0x116b; | 670 | else if (c == 0x1162) mchar = 0x116b; |
664 | else if (c == 0x1175) mchar = 0x116c; | 671 | else if (c == 0x1175) mchar = 0x116c; |
665 | else { | 672 | else { |
666 | schar = 0; mchar = 0; echar = 0; | 673 | schar = 0; mchar = 0; echar = 0; |
667 | return c; | 674 | return c; |
668 | } | 675 | } |
669 | break; | 676 | break; |
670 | case 0x116e: | 677 | case 0x116e: |
671 | if (c == 0x1165) mchar = 0x116f; | 678 | if (c == 0x1165) mchar = 0x116f; |
672 | else if (c == 0x1166) mchar = 0x1170; | 679 | else if (c == 0x1166) mchar = 0x1170; |
673 | else if (c == 0x1175) mchar = 0x1171; | 680 | else if (c == 0x1175) mchar = 0x1171; |
674 | else { | 681 | else { |
675 | schar = 0; mchar = 0; echar = 0; | 682 | schar = 0; mchar = 0; echar = 0; |
676 | return c; | 683 | return c; |
677 | } | 684 | } |
678 | break; | 685 | break; |
679 | case 0x1173: | 686 | case 0x1173: |
680 | if (c == 0x1175) mchar = 0x1174; | 687 | if (c == 0x1175) mchar = 0x1174; |
681 | else { | 688 | else { |
682 | schar = 0; mchar = 0; echar = 0; | 689 | schar = 0; mchar = 0; echar = 0; |
683 | return c; | 690 | return c; |
684 | } | 691 | } |
685 | break; | 692 | break; |
686 | default: | 693 | default: |
687 | schar = 0; mchar = 0; echar = 0; | 694 | schar = 0; mchar = 0; echar = 0; |
688 | return c; | 695 | return c; |
689 | } | 696 | } |
690 | } | 697 | } |
691 | else if (schar != 0 && mchar != 0 && echar != 0) { | 698 | else if (schar != 0 && mchar != 0 && echar != 0) { |
692 | 699 | ||
693 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 700 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
694 | 701 | ||
695 | ushort prev = 0; | 702 | ushort prev = 0; |
696 | switch (echar) { | 703 | switch (echar) { |
697 | /* | 704 | /* |
698 | case 0x11a9: | 705 | case 0x11a9: |
699 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 706 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
700 | schar = 0x1100; | 707 | schar = 0x1100; |
701 | break; | 708 | break; |
702 | */ | 709 | */ |
703 | case 0x11aa: | 710 | case 0x11aa: |
704 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 711 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
705 | schar = 0x1109; | 712 | schar = 0x1109; |
706 | break; | 713 | break; |
707 | case 0x11ac: | 714 | case 0x11ac: |
708 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 715 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
709 | schar = 0x110c; | 716 | schar = 0x110c; |
710 | break; | 717 | break; |
711 | case 0x11ad: | 718 | case 0x11ad: |
712 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 719 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
713 | schar = 0x1112; | 720 | schar = 0x1112; |
714 | break; | 721 | break; |
715 | case 0x11b0: | 722 | case 0x11b0: |
716 | prev = combineKoreanChars(schar, mchar, 0x11af); | 723 | prev = combineKoreanChars(schar, mchar, 0x11af); |
717 | schar = 0x1100; | 724 | schar = 0x1100; |
718 | break; | 725 | break; |
719 | case 0x11b1: | 726 | case 0x11b1: |
720 | prev = combineKoreanChars(schar, mchar, 0x11af); | 727 | prev = combineKoreanChars(schar, mchar, 0x11af); |
721 | schar = 0x1106; | 728 | schar = 0x1106; |
722 | break; | 729 | break; |
723 | case 0x11b2: | 730 | case 0x11b2: |
724 | prev = combineKoreanChars(schar, mchar, 0x11af); | 731 | prev = combineKoreanChars(schar, mchar, 0x11af); |
725 | schar = 0x1107; | 732 | schar = 0x1107; |
726 | break; | 733 | break; |
727 | case 0x11b3: | 734 | case 0x11b3: |
728 | prev = combineKoreanChars(schar, mchar, 0x11af); | 735 | prev = combineKoreanChars(schar, mchar, 0x11af); |
729 | schar = 0x1109; | 736 | schar = 0x1109; |
730 | break; | 737 | break; |
731 | case 0x11b4: | 738 | case 0x11b4: |
732 | prev = combineKoreanChars(schar, mchar, 0x11af); | 739 | prev = combineKoreanChars(schar, mchar, 0x11af); |
733 | schar = 0x1110; | 740 | schar = 0x1110; |
734 | break; | 741 | break; |
735 | case 0x11b9: | 742 | case 0x11b9: |
736 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 743 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
737 | schar = 0x1109; | 744 | schar = 0x1109; |
738 | break; | 745 | break; |
739 | /* | 746 | /* |
740 | case 0x11bb: | 747 | case 0x11bb: |
741 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 748 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
742 | schar = 0x1109; | 749 | schar = 0x1109; |
743 | break; | 750 | break; |
744 | */ | 751 | */ |
745 | default: | 752 | default: |
746 | 753 | ||
747 | if (constoe(echar)) { | 754 | if (constoe(echar)) { |
748 | 755 | ||
749 | prev = combineKoreanChars(schar, mchar, 0); | 756 | prev = combineKoreanChars(schar, mchar, 0); |
750 | schar = constoe(echar); | 757 | schar = constoe(echar); |
751 | } | 758 | } |
752 | break; | 759 | break; |
753 | } | 760 | } |
754 | 761 | ||
755 | emit key( prev, prev, 0, true, false ); | 762 | emit key( prev, prev, 0, true, false ); |
756 | 763 | ||
757 | mchar = c; echar = 0; | 764 | mchar = c; echar = 0; |
758 | 765 | ||
759 | return combineKoreanChars(schar, mchar, 0); | 766 | return combineKoreanChars(schar, mchar, 0); |
760 | 767 | ||
761 | } | 768 | } |
762 | else { | 769 | else { |
763 | schar = 0; mchar = 0; echar = 0; | 770 | schar = 0; mchar = 0; echar = 0; |
764 | return c; | 771 | return c; |
765 | } | 772 | } |
766 | 773 | ||
767 | } | 774 | } |
768 | else /*if (c == ' ')*/ return c; | 775 | else /*if (c == ' ')*/ return c; |
769 | 776 | ||
770 | 777 | ||
771 | // and now... finally delete previous char, and return new char | 778 | // and now... finally delete previous char, and return new char |
772 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 779 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
773 | 780 | ||
774 | 781 | ||
775 | return combineKoreanChars( schar, mchar, echar); | 782 | return combineKoreanChars( schar, mchar, echar); |
776 | 783 | ||
777 | } | 784 | } |
778 | 785 | ||
779 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 786 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
780 | 787 | ||
781 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 788 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
782 | 789 | ||
783 | } | 790 | } |
784 | 791 | ||
785 | ushort Keyboard::constoe(const ushort c) { | 792 | ushort Keyboard::constoe(const ushort c) { |
786 | 793 | ||
787 | // converts schars to echars if possible | 794 | // converts schars to echars if possible |
788 | 795 | ||
789 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 796 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
790 | 797 | ||
791 | switch (c) { | 798 | switch (c) { |
792 | case 0x1100: return 0x11a8; | 799 | case 0x1100: return 0x11a8; |
793 | case 0x1101: return 0x11a9; | 800 | case 0x1101: return 0x11a9; |
794 | case 0x1102: return 0x11ab; | 801 | case 0x1102: return 0x11ab; |
795 | case 0x1103: return 0x11ae; | 802 | case 0x1103: return 0x11ae; |
796 | case 0x1105: return 0x11af; | 803 | case 0x1105: return 0x11af; |
797 | case 0x1106: return 0x11b7; | 804 | case 0x1106: return 0x11b7; |
798 | case 0x1107: return 0x11b8; | 805 | case 0x1107: return 0x11b8; |
799 | case 0x1109: return 0x11ba; | 806 | case 0x1109: return 0x11ba; |
800 | case 0x110a: return 0x11bb; | 807 | case 0x110a: return 0x11bb; |
801 | case 0x110b: return 0x11bc; | 808 | case 0x110b: return 0x11bc; |
802 | case 0x110c: return 0x11bd; | 809 | case 0x110c: return 0x11bd; |
803 | case 0x110e: return 0x11be; | 810 | case 0x110e: return 0x11be; |
804 | case 0x110f: return 0x11bf; | 811 | case 0x110f: return 0x11bf; |
805 | case 0x1110: return 0x11c0; | 812 | case 0x1110: return 0x11c0; |
806 | case 0x1111: return 0x11c1; | 813 | case 0x1111: return 0x11c1; |
807 | case 0x1112: return 0x11c2; | 814 | case 0x1112: return 0x11c2; |
808 | default: return 0; | 815 | default: return 0; |
809 | 816 | ||
810 | } | 817 | } |
811 | 818 | ||
812 | } else { //echar to schar | 819 | } else { //echar to schar |
813 | 820 | ||
814 | switch (c) { | 821 | switch (c) { |
815 | case 0x11a8: return 0x1100; | 822 | case 0x11a8: return 0x1100; |
816 | case 0x11a9: return 0x1101; | 823 | case 0x11a9: return 0x1101; |
817 | case 0x11ab: return 0x1102; | 824 | case 0x11ab: return 0x1102; |
818 | case 0x11ae: return 0x1103; | 825 | case 0x11ae: return 0x1103; |
819 | case 0x11af: return 0x1105; | 826 | case 0x11af: return 0x1105; |
820 | case 0x11b7: return 0x1106; | 827 | case 0x11b7: return 0x1106; |
821 | case 0x11b8: return 0x1107; | 828 | case 0x11b8: return 0x1107; |
822 | case 0x11ba: return 0x1109; | 829 | case 0x11ba: return 0x1109; |
823 | case 0x11bb: return 0x110a; | 830 | case 0x11bb: return 0x110a; |
824 | case 0x11bc: return 0x110b; | 831 | case 0x11bc: return 0x110b; |
825 | case 0x11bd: return 0x110c; | 832 | case 0x11bd: return 0x110c; |
826 | case 0x11be: return 0x110e; | 833 | case 0x11be: return 0x110e; |
827 | case 0x11bf: return 0x110f; | 834 | case 0x11bf: return 0x110f; |
828 | case 0x11c0: return 0x1110; | 835 | case 0x11c0: return 0x1110; |
829 | case 0x11c1: return 0x1111; | 836 | case 0x11c1: return 0x1111; |
830 | case 0x11c2: return 0x1112; | 837 | case 0x11c2: return 0x1112; |
831 | default: return 0; | 838 | default: return 0; |
832 | 839 | ||
833 | } | 840 | } |
834 | 841 | ||
835 | } | 842 | } |
836 | } | 843 | } |
837 | 844 | ||
838 | 845 | ||
839 | // Keys::Keys {{{1 | 846 | // Keys::Keys {{{1 |
840 | 847 | ||
841 | Keys::Keys() { | 848 | Keys::Keys() { |
842 | 849 | ||
843 | Config *config = new Config ("multikey"); | 850 | Config *config = new Config ("multikey"); |
844 | config->setGroup( "keymaps" ); | 851 | config->setGroup( "keymaps" ); |
845 | QString key_map = config->readEntry( "current" ); | 852 | QString key_map = config->readEntry( "current" ); |
846 | delete config; | 853 | delete config; |
847 | 854 | ||
848 | if (key_map.isNull()) { | 855 | if (key_map.isNull()) { |
849 | 856 | ||
850 | Config *config = new Config("locale"); | 857 | Config *config = new Config("locale"); |
851 | config->setGroup( "Language" ); | 858 | config->setGroup( "Language" ); |
852 | QString l = config->readEntry( "Language" , "en" ); | 859 | QString l = config->readEntry( "Language" , "en" ); |
853 | delete config; | 860 | delete config; |
854 | 861 | ||
855 | key_map = QPEApplication::qpeDir() + "/share/multikey/" | 862 | key_map = QPEApplication::qpeDir() + "/share/multikey/" |
856 | + l + ".keymap"; | 863 | + l + ".keymap"; |
857 | 864 | ||
858 | } | 865 | } |
859 | 866 | ||
860 | 867 | ||
861 | setKeysFromFile(key_map); | 868 | setKeysFromFile(key_map); |
862 | } | 869 | } |
863 | 870 | ||
864 | Keys::Keys(const char * filename) { | 871 | Keys::Keys(const char * filename) { |
865 | 872 | ||
866 | setKeysFromFile(filename); | 873 | setKeysFromFile(filename); |
867 | } | 874 | } |
868 | 875 | ||
869 | // Keys::setKeysFromFile {{{2 | 876 | // Keys::setKeysFromFile {{{2 |
870 | void Keys::setKeysFromFile(const char * filename) { | 877 | void Keys::setKeysFromFile(const char * filename) { |
871 | 878 | ||
872 | QFile f(filename); | 879 | QFile f(filename); |
873 | 880 | ||
874 | if (f.open(IO_ReadOnly)) { | 881 | if (f.open(IO_ReadOnly)) { |
875 | 882 | ||
876 | QTextStream t(&f); | 883 | QTextStream t(&f); |
877 | int row; | 884 | int row; |
878 | int qcode; | 885 | int qcode; |
879 | ushort unicode; | 886 | ushort unicode; |
880 | int width; | 887 | int width; |
881 | QString buf; | 888 | QString buf; |
882 | QString comment; | 889 | QString comment; |
883 | char * xpm[256]; //couldnt be larger than that... could it? | 890 | char * xpm[256]; //couldnt be larger than that... could it? |
884 | QPixmap *xpm2pix = 0; | 891 | QPixmap *xpm2pix = 0; |
885 | 892 | ||
886 | buf = t.readLine(); | 893 | buf = t.readLine(); |
887 | while (buf) { | 894 | while (buf) { |
888 | 895 | ||
889 | // key definition | 896 | // key definition |
890 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 897 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
891 | // no $1 type referencing!!! this implementation of regexp sucks | 898 | // no $1 type referencing!!! this implementation of regexp sucks |
892 | 899 | ||
893 | // dont know of any sscanf() type funcs in Qt lib | 900 | // dont know of any sscanf() type funcs in Qt lib |
894 | QTextStream tmp (buf, IO_ReadOnly); | 901 | QTextStream tmp (buf, IO_ReadOnly); |
895 | tmp >> row >> qcode >> unicode >> width >> comment; | 902 | tmp >> row >> qcode >> unicode >> width >> comment; |
896 | 903 | ||
897 | buf = t.readLine(); | 904 | buf = t.readLine(); |
898 | int xpmLineCount = 0; | 905 | int xpmLineCount = 0; |
899 | xpm2pix = 0; | 906 | xpm2pix = 0; |
900 | 907 | ||
901 | // erase blank space | 908 | // erase blank space |
902 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 909 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
903 | 910 | ||
904 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 911 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
905 | 912 | ||
906 | QString xpmBuf = buf.stripWhiteSpace(); | 913 | QString xpmBuf = buf.stripWhiteSpace(); |
907 | 914 | ||
908 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 915 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |
909 | 916 | ||
910 | int j = 0; | 917 | int j = 0; |
911 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 918 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
912 | if (xpmBuf[i].latin1() != '"') { | 919 | if (xpmBuf[i].latin1() != '"') { |
913 | 920 | ||
914 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 921 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
915 | j++; | 922 | j++; |
916 | } | 923 | } |
917 | 924 | ||
918 | } | 925 | } |
919 | // have to close that facker up | 926 | // have to close that facker up |
920 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 927 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
921 | 928 | ||
922 | xpmLineCount++; | 929 | xpmLineCount++; |
923 | buf = t.readLine(); | 930 | buf = t.readLine(); |
924 | } | 931 | } |
925 | if (xpmLineCount) { | 932 | if (xpmLineCount) { |
926 | 933 | ||
927 | xpm2pix = new QPixmap((const char **)xpm); | 934 | xpm2pix = new QPixmap((const char **)xpm); |
928 | for (int i = 0; i < xpmLineCount; i++) | 935 | for (int i = 0; i < xpmLineCount; i++) |
929 | 936 | ||
930 | delete [] (xpm[i]); | 937 | delete [] (xpm[i]); |
931 | 938 | ||
932 | } | 939 | } |
933 | setKey(row, qcode, unicode, width, xpm2pix); | 940 | setKey(row, qcode, unicode, width, xpm2pix); |
934 | } | 941 | } |
935 | 942 | ||
936 | // shift map | 943 | // shift map |
937 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 944 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
938 | 945 | ||
939 | QTextStream tmp (buf, IO_ReadOnly); | 946 | QTextStream tmp (buf, IO_ReadOnly); |
940 | ushort lower, shift; | 947 | ushort lower, shift; |
941 | tmp >> lower >> shift; | 948 | tmp >> lower >> shift; |
942 | 949 | ||
943 | shiftMap.insert(lower, shift); | 950 | shiftMap.insert(lower, shift); |
944 | 951 | ||
945 | buf = t.readLine(); | 952 | buf = t.readLine(); |
946 | } | 953 | } |
947 | 954 | ||
948 | // other variables like lang & title | 955 | // other variables like lang & title |
949 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 956 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
950 | 957 | ||
951 | QTextStream tmp (buf, IO_ReadOnly); | 958 | QTextStream tmp (buf, IO_ReadOnly); |
952 | QString name, equals, value; | 959 | QString name, equals, value; |
953 | 960 | ||
954 | tmp >> name >> equals >> value; | 961 | tmp >> name >> equals >> value; |
955 | 962 | ||
956 | if (name == "lang") { | 963 | if (name == "lang") { |
957 | 964 | ||
958 | lang = value; | 965 | lang = value; |
959 | 966 | ||
960 | } | 967 | } |
961 | 968 | ||
962 | cout << name << " = " << value << "\n"; | ||
963 | buf = t.readLine(); | 969 | buf = t.readLine(); |
964 | } | 970 | } |
965 | // comments | 971 | // comments |
966 | else if (buf.contains(QRegExp("^\\s*#"))) { | 972 | else if (buf.contains(QRegExp("^\\s*#"))) { |
967 | 973 | ||
968 | buf = t.readLine(); | 974 | buf = t.readLine(); |
969 | 975 | ||
970 | } else { // blank line, or garbage | 976 | } else { // blank line, or garbage |
971 | 977 | ||
972 | buf = t.readLine(); | 978 | buf = t.readLine(); |
973 | 979 | ||
974 | } | 980 | } |
975 | 981 | ||
976 | } | 982 | } |
977 | f.close(); | 983 | f.close(); |
978 | } | 984 | } |
979 | 985 | ||
980 | } | 986 | } |
981 | 987 | ||
982 | // Keys::setKey {{{2 | 988 | // Keys::setKey {{{2 |
983 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 989 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
984 | const int width, QPixmap *pix) { | 990 | const int width, QPixmap *pix) { |
985 | 991 | ||
986 | Key * key; | 992 | Key * key; |
987 | key = new Key; | 993 | key = new Key; |
988 | key->qcode = qcode; | 994 | key->qcode = qcode; |
989 | key->unicode = unicode; | 995 | key->unicode = unicode; |
990 | key->width = width; | 996 | key->width = width; |
991 | 997 | ||
992 | // share key->pressed between same keys | 998 | // share key->pressed between same keys |
993 | bool found = 0; | 999 | bool found = 0; |
994 | for (int i = 1; i <= 5; i++) { | 1000 | for (int i = 1; i <= 5; i++) { |
995 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1001 | for (unsigned int j = 0; j < keys[i].count(); j++) |
996 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1002 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
997 | 1003 | ||
998 | key->pressed = keys[i].at(j)->pressed; | 1004 | key->pressed = keys[i].at(j)->pressed; |
999 | found = 1; | 1005 | found = 1; |
1000 | } | 1006 | } |
1001 | 1007 | ||
1002 | } | 1008 | } |
1003 | if (!found) { | 1009 | if (!found) { |
1004 | 1010 | ||
1005 | key->pressed = new bool; | 1011 | key->pressed = new bool; |
1006 | *(key->pressed) = 0; | 1012 | *(key->pressed) = 0; |
1007 | } | 1013 | } |
1008 | 1014 | ||
1009 | key->pix = pix; | 1015 | key->pix = pix; |
1010 | 1016 | ||
1011 | 1017 | ||
1012 | keys[row].append(key); | 1018 | keys[row].append(key); |
1013 | } | 1019 | } |
1014 | // Keys:: other functions {{{2 | 1020 | // Keys:: other functions {{{2 |
1015 | int Keys::width(const int row, const int col) { | 1021 | int Keys::width(const int row, const int col) { |
1016 | 1022 | ||
1017 | return keys[row].at(col)->width; | 1023 | return keys[row].at(col)->width; |
1018 | 1024 | ||
1019 | } | 1025 | } |
1020 | ushort Keys::uni(const int row, const int col) { | 1026 | ushort Keys::uni(const int row, const int col) { |
1021 | 1027 | ||
1022 | return keys[row].at(col)->unicode; | 1028 | return keys[row].at(col)->unicode; |
1023 | 1029 | ||
1024 | } | 1030 | } |
1025 | 1031 | ||
1026 | int Keys::qcode(const int row, const int col) { | 1032 | int Keys::qcode(const int row, const int col) { |
1027 | 1033 | ||
1028 | return keys[row].at(col)->qcode; | 1034 | return keys[row].at(col)->qcode; |
1029 | } | 1035 | } |
1030 | 1036 | ||
1031 | QPixmap *Keys::pix(const int row, const int col) { | 1037 | QPixmap *Keys::pix(const int row, const int col) { |
1032 | 1038 | ||
1033 | return keys[row].at(col)->pix; | 1039 | return keys[row].at(col)->pix; |
1034 | 1040 | ||
1035 | } | 1041 | } |
1036 | bool Keys::pressed(const int row, const int col) { | 1042 | bool Keys::pressed(const int row, const int col) { |
1037 | 1043 | ||
1038 | return *(keys[row].at(col)->pressed); | 1044 | return *(keys[row].at(col)->pressed); |
1039 | } | 1045 | } |
1040 | 1046 | ||
1041 | int Keys::numKeys(const int row) { | 1047 | int Keys::numKeys(const int row) { |
1042 | 1048 | ||
1043 | return keys[row].count(); | 1049 | return keys[row].count(); |
1044 | } | 1050 | } |
1045 | 1051 | ||
1046 | void Keys::setPressed(const int row, const int col, const bool pressed) { | 1052 | void Keys::setPressed(const int row, const int col, const bool pressed) { |
1047 | 1053 | ||
1048 | *(keys[row].at(col)->pressed) = pressed; | 1054 | *(keys[row].at(col)->pressed) = pressed; |
1049 | } | 1055 | } |
1050 | 1056 | ||
1051 | ushort Keys::shift(const ushort uni) { | 1057 | ushort Keys::shift(const ushort uni) { |
1052 | 1058 | ||
1053 | if (shiftMap[uni]) { | 1059 | if (shiftMap[uni]) { |
1054 | 1060 | ||
1055 | return shiftMap[uni]; | 1061 | return shiftMap[uni]; |
1056 | } | 1062 | } |
1057 | else | 1063 | else |
1058 | return 0; | 1064 | return 0; |
1059 | 1065 | ||
1060 | } | 1066 | } |
1061 | 1067 | ||
1062 | bool *Keys::pressedPtr(const int row, const int col) { | 1068 | bool *Keys::pressedPtr(const int row, const int col) { |
1063 | 1069 | ||
1064 | return keys[row].at(col)->pressed; | 1070 | return keys[row].at(col)->pressed; |
1065 | } | 1071 | } |
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index c2efe10..8ca50ea 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -1,156 +1,157 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
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 | #include <qframe.h> | 20 | #include <qframe.h> |
21 | #include <qmap.h> | 21 | #include <qmap.h> |
22 | #include "../pickboard/pickboardcfg.h" | 22 | #include "../pickboard/pickboardcfg.h" |
23 | #include "../pickboard/pickboardpicks.h" | 23 | #include "../pickboard/pickboardpicks.h" |
24 | #include "configdlg.h" | 24 | #include "configdlg.h" |
25 | 25 | ||
26 | class QTimer; | 26 | class QTimer; |
27 | 27 | ||
28 | class KeyboardConfig : public DictFilterConfig | 28 | class KeyboardConfig : public DictFilterConfig |
29 | { | 29 | { |
30 | public: | 30 | public: |
31 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } | 31 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } |
32 | virtual void generateText(const QString &s); | 32 | virtual void generateText(const QString &s); |
33 | void decBackspaces() { if (backspaces) backspaces--; } | 33 | void decBackspaces() { if (backspaces) backspaces--; } |
34 | void incBackspaces() { backspaces++; } | 34 | void incBackspaces() { backspaces++; } |
35 | void resetBackspaces() { backspaces = 0; } | 35 | void resetBackspaces() { backspaces = 0; } |
36 | private: | 36 | private: |
37 | int backspaces; | 37 | int backspaces; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | 40 | ||
41 | class KeyboardPicks : public PickboardPicks | 41 | class KeyboardPicks : public PickboardPicks |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) | 45 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) |
46 | : PickboardPicks(parent, name, f) { } | 46 | : PickboardPicks(parent, name, f) { } |
47 | void initialise(); | 47 | void initialise(); |
48 | virtual QSize sizeHint() const; | 48 | virtual QSize sizeHint() const; |
49 | KeyboardConfig *dc; | 49 | KeyboardConfig *dc; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | 52 | ||
53 | class Keys { | 53 | class Keys { |
54 | public: | 54 | public: |
55 | 55 | ||
56 | Keys(); | 56 | Keys(); |
57 | Keys(const char * filename); | 57 | Keys(const char * filename); |
58 | ushort uni(const int row, const int col); | 58 | ushort uni(const int row, const int col); |
59 | int qcode(const int row, const int col); | 59 | int qcode(const int row, const int col); |
60 | int width(const int row, const int col); | 60 | int width(const int row, const int col); |
61 | bool pressed(const int row, const int col); | 61 | bool pressed(const int row, const int col); |
62 | bool *pressedPtr(const int row, const int col); | 62 | bool *pressedPtr(const int row, const int col); |
63 | ushort shift(const ushort); | 63 | ushort shift(const ushort); |
64 | QPixmap *pix(const int row, const int col); | 64 | QPixmap *pix(const int row, const int col); |
65 | int numKeys(const int row); | 65 | int numKeys(const int row); |
66 | void setKeysFromFile(const char *filename); | 66 | void setKeysFromFile(const char *filename); |
67 | void setKey(const int row, const int qcode, const ushort unicode, | 67 | void setKey(const int row, const int qcode, const ushort unicode, |
68 | const int width, QPixmap *pix); | 68 | const int width, QPixmap *pix); |
69 | void setPressed(const int row, const int col, const bool pressed); | 69 | void setPressed(const int row, const int col, const bool pressed); |
70 | QString lang; | 70 | QString lang; |
71 | QString title; | 71 | QString title; |
72 | 72 | ||
73 | private: | 73 | private: |
74 | 74 | ||
75 | typedef struct Key { | 75 | typedef struct Key { |
76 | int qcode; // are qt key codes just unicode values? | 76 | int qcode; // are qt key codes just unicode values? |
77 | ushort unicode; | 77 | ushort unicode; |
78 | int width; // not pixels but relative key width. normal key is 2 | 78 | int width; // not pixels but relative key width. normal key is 2 |
79 | 79 | ||
80 | // only needed for keys like ctrl that can have multiple keys pressed at once | 80 | // only needed for keys like ctrl that can have multiple keys pressed at once |
81 | bool *pressed; | 81 | bool *pressed; |
82 | QPixmap *pix; | 82 | QPixmap *pix; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | QList<Key> keys[6]; | 85 | QList<Key> keys[6]; |
86 | QMap<ushort,ushort> shiftMap; | 86 | QMap<ushort,ushort> shiftMap; |
87 | 87 | ||
88 | }; | 88 | }; |
89 | 89 | ||
90 | class Keyboard : public QFrame | 90 | class Keyboard : public QFrame |
91 | { | 91 | { |
92 | Q_OBJECT | 92 | Q_OBJECT |
93 | public: | 93 | public: |
94 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 94 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
95 | ~Keyboard(); | ||
95 | 96 | ||
96 | void resetState(); | 97 | void resetState(); |
97 | 98 | ||
98 | void mousePressEvent(QMouseEvent*); | 99 | void mousePressEvent(QMouseEvent*); |
99 | void mouseReleaseEvent(QMouseEvent*); | 100 | void mouseReleaseEvent(QMouseEvent*); |
100 | void resizeEvent(QResizeEvent*); | 101 | void resizeEvent(QResizeEvent*); |
101 | void paintEvent(QPaintEvent* e); | 102 | void paintEvent(QPaintEvent* e); |
102 | //void timerEvent(QTimerEvent* e); | 103 | //void timerEvent(QTimerEvent* e); |
103 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); | 104 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); |
104 | 105 | ||
105 | QSize sizeHint() const; | 106 | QSize sizeHint() const; |
106 | 107 | ||
107 | signals: | 108 | signals: |
108 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 109 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
109 | 110 | ||
110 | private slots: | 111 | private slots: |
111 | void repeat(); | 112 | void repeat(); |
112 | void togglePickboard(bool on_off); | 113 | void togglePickboard(bool on_off); |
113 | void setMapToDefault(); | 114 | void setMapToDefault(); |
114 | void setMapToFile(QString file); | 115 | void setMapToFile(QString file); |
115 | 116 | ||
116 | private: | 117 | private: |
117 | int getKey( int &w, int j = -1 ); | 118 | int getKey( int &w, int j = -1 ); |
118 | void clearHighlight(); | 119 | void clearHighlight(); |
119 | 120 | ||
120 | bool *shift; | 121 | bool *shift; |
121 | bool *lock; | 122 | bool *lock; |
122 | bool *ctrl; | 123 | bool *ctrl; |
123 | bool *alt; | 124 | bool *alt; |
124 | uint useLargeKeys:1; | 125 | uint useLargeKeys:1; |
125 | uint usePicks:1; | 126 | uint usePicks:1; |
126 | 127 | ||
127 | int pressedKeyRow; | 128 | int pressedKeyRow; |
128 | int pressedKeyCol; | 129 | int pressedKeyCol; |
129 | 130 | ||
130 | KeyboardPicks *picks; | 131 | KeyboardPicks *picks; |
131 | 132 | ||
132 | int keyHeight; | 133 | int keyHeight; |
133 | int defaultKeyWidth; | 134 | int defaultKeyWidth; |
134 | int xoffs; | 135 | int xoffs; |
135 | 136 | ||
136 | int unicode; | 137 | int unicode; |
137 | int qkeycode; | 138 | int qkeycode; |
138 | int modifiers; | 139 | int modifiers; |
139 | 140 | ||
140 | int pressTid; | 141 | int pressTid; |
141 | bool pressed; | 142 | bool pressed; |
142 | 143 | ||
143 | Keys *keys; | 144 | Keys *keys; |
144 | 145 | ||
145 | /* for korean input */ | 146 | /* for korean input */ |
146 | ushort schar, mchar, echar; | 147 | ushort schar, mchar, echar; |
147 | ushort parseKoreanInput(ushort c); | 148 | ushort parseKoreanInput(ushort c); |
148 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); | 149 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); |
149 | ushort constoe(const ushort c); | 150 | ushort constoe(const ushort c); |
150 | 151 | ||
151 | QTimer *repeatTimer; | 152 | QTimer *repeatTimer; |
152 | 153 | ||
153 | ConfigDlg *configdlg; | 154 | ConfigDlg *configdlg; |
154 | }; | 155 | }; |
155 | 156 | ||
156 | 157 | ||