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