-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index de3aa52..08318bd 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -175,1470 +175,1479 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col) | |||
175 | int keyWidth = keys->width(row, col); | 175 | int keyWidth = keys->width(row, col); |
176 | 176 | ||
177 | p.fillRect(x + 1, y + 1, | 177 | p.fillRect(x + 1, y + 1, |
178 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 178 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
179 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 179 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
180 | 180 | ||
181 | QImage *pix = keys->pix(row,col); | 181 | QImage *pix = keys->pix(row,col); |
182 | 182 | ||
183 | ushort c = keys->uni(row, col); | 183 | ushort c = keys->uni(row, col); |
184 | 184 | ||
185 | p.setPen(textcolor); | 185 | p.setPen(textcolor); |
186 | if (!pix) { | 186 | if (!pix) { |
187 | if ((shift || lock) && keys->shift(c)) | 187 | if ((shift || lock) && keys->shift(c)) |
188 | 188 | ||
189 | if (circumflex && keys->circumflex(keys->shift(c))) | 189 | if (circumflex && keys->circumflex(keys->shift(c))) |
190 | c = keys->circumflex(keys->shift(c)); | 190 | c = keys->circumflex(keys->shift(c)); |
191 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 191 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
192 | c = keys->diaeresis(keys->shift(c)); | 192 | c = keys->diaeresis(keys->shift(c)); |
193 | else if (baccent && keys->baccent(keys->shift(c))) | 193 | else if (baccent && keys->baccent(keys->shift(c))) |
194 | c = keys->baccent(keys->shift(c)); | 194 | c = keys->baccent(keys->shift(c)); |
195 | else if (accent && keys->accent(keys->shift(c))) | 195 | else if (accent && keys->accent(keys->shift(c))) |
196 | c = keys->accent(keys->shift(c)); | 196 | c = keys->accent(keys->shift(c)); |
197 | else if (meta && keys->meta(keys->shift(c))) | 197 | else if (meta && keys->meta(keys->shift(c))) |
198 | c = keys->meta(keys->shift(c)); | 198 | c = keys->meta(keys->shift(c)); |
199 | else | 199 | else |
200 | c = keys->shift(c); | 200 | c = keys->shift(c); |
201 | 201 | ||
202 | else if (meta && keys->meta(c)) | 202 | else if (meta && keys->meta(c)) |
203 | c = keys->meta(c); | 203 | c = keys->meta(c); |
204 | else if (circumflex && keys->circumflex(c)) | 204 | else if (circumflex && keys->circumflex(c)) |
205 | c = keys->circumflex(c); | 205 | c = keys->circumflex(c); |
206 | else if (baccent && keys->baccent(c)) | 206 | else if (baccent && keys->baccent(c)) |
207 | c = keys->baccent(c); | 207 | c = keys->baccent(c); |
208 | else if (accent && keys->accent(c)) | 208 | else if (accent && keys->accent(c)) |
209 | c = keys->accent(c); | 209 | c = keys->accent(c); |
210 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 210 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
211 | 211 | ||
212 | // the diaeresis key itself has to be in the diaeresisMap, | 212 | // the diaeresis key itself has to be in the diaeresisMap, |
213 | // or just do this to make it display the diaeresis char. | 213 | // or just do this to make it display the diaeresis char. |
214 | 214 | ||
215 | if (c == 0x2c6) | 215 | if (c == 0x2c6) |
216 | c = 0xa8; | 216 | c = 0xa8; |
217 | else | 217 | else |
218 | c = keys->diaeresis(c); | 218 | c = keys->diaeresis(c); |
219 | } | 219 | } |
220 | 220 | ||
221 | p.drawText(x, y, | 221 | p.drawText(x, y, |
222 | defaultKeyWidth * keyWidth + 3, keyHeight, | 222 | defaultKeyWidth * keyWidth + 3, keyHeight, |
223 | AlignCenter, (QChar)c); | 223 | AlignCenter, (QChar)c); |
224 | } | 224 | } |
225 | else | 225 | else |
226 | // center the image in the middle of the key | 226 | // center the image in the middle of the key |
227 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, | 227 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, |
228 | y + (keyHeight - pix->height())/2 + 1, | 228 | y + (keyHeight - pix->height())/2 + 1, |
229 | *pix ); | 229 | *pix ); |
230 | 230 | ||
231 | // this fixes the problem that the very right end of the board's vertical line | 231 | // this fixes the problem that the very right end of the board's vertical line |
232 | // gets painted over, because it's one pixel shorter than all other keys | 232 | // gets painted over, because it's one pixel shorter than all other keys |
233 | p.setPen(keycolor_lines); | 233 | p.setPen(keycolor_lines); |
234 | p.drawLine(width() - 1, 0, width() - 1, height()); | 234 | p.drawLine(width() - 1, 0, width() - 1, height()); |
235 | 235 | ||
236 | } else { | 236 | } else { |
237 | 237 | ||
238 | 238 | ||
239 | p.fillRect(0, 0, width(), height(), keycolor); | 239 | p.fillRect(0, 0, width(), height(), keycolor); |
240 | 240 | ||
241 | for (row = 1; row <= keys->rows(); row++) { | 241 | for (row = 1; row <= keys->rows(); row++) { |
242 | 242 | ||
243 | int x = 0; | 243 | int x = 0; |
244 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 244 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
245 | 245 | ||
246 | p.setPen(keycolor_lines); | 246 | p.setPen(keycolor_lines); |
247 | p.drawLine(x, y, x + width(), y); | 247 | p.drawLine(x, y, x + width(), y); |
248 | 248 | ||
249 | for (int col = 0; col < keys->numKeys(row); col++) { | 249 | for (int col = 0; col < keys->numKeys(row); col++) { |
250 | 250 | ||
251 | QImage *pix = keys->pix(row, col); | 251 | QImage *pix = keys->pix(row, col); |
252 | int keyWidth = keys->width(row, col); | 252 | int keyWidth = keys->width(row, col); |
253 | 253 | ||
254 | 254 | ||
255 | int keyWidthPix = defaultKeyWidth * keyWidth; | 255 | int keyWidthPix = defaultKeyWidth * keyWidth; |
256 | 256 | ||
257 | if (keys->pressed(row, col)) | 257 | if (keys->pressed(row, col)) |
258 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 258 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
259 | keyHeight - 1, keycolor_pressed); | 259 | keyHeight - 1, keycolor_pressed); |
260 | 260 | ||
261 | ushort c = keys->uni(row, col); | 261 | ushort c = keys->uni(row, col); |
262 | 262 | ||
263 | p.setPen(textcolor); | 263 | p.setPen(textcolor); |
264 | if (!pix) { | 264 | if (!pix) { |
265 | if ((shift || lock) && keys->shift(c)) | 265 | if ((shift || lock) && keys->shift(c)) |
266 | 266 | ||
267 | if (circumflex && keys->circumflex(keys->shift(c))) | 267 | if (circumflex && keys->circumflex(keys->shift(c))) |
268 | c = keys->circumflex(keys->shift(c)); | 268 | c = keys->circumflex(keys->shift(c)); |
269 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 269 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
270 | c = keys->diaeresis(keys->shift(c)); | 270 | c = keys->diaeresis(keys->shift(c)); |
271 | else if (baccent && keys->baccent(keys->shift(c))) | 271 | else if (baccent && keys->baccent(keys->shift(c))) |
272 | c = keys->baccent(keys->shift(c)); | 272 | c = keys->baccent(keys->shift(c)); |
273 | else if (accent && keys->accent(keys->shift(c))) | 273 | else if (accent && keys->accent(keys->shift(c))) |
274 | c = keys->accent(keys->shift(c)); | 274 | c = keys->accent(keys->shift(c)); |
275 | else if (meta && keys->meta(keys->shift(c))) | 275 | else if (meta && keys->meta(keys->shift(c))) |
276 | c = keys->meta(keys->shift(c)); | 276 | c = keys->meta(keys->shift(c)); |
277 | else | 277 | else |
278 | c = keys->shift(c); | 278 | c = keys->shift(c); |
279 | 279 | ||
280 | else if (meta && keys->meta(c)) | 280 | else if (meta && keys->meta(c)) |
281 | c = keys->meta(c); | 281 | c = keys->meta(c); |
282 | else if (circumflex && keys->circumflex(c)) | 282 | else if (circumflex && keys->circumflex(c)) |
283 | c = keys->circumflex(c); | 283 | c = keys->circumflex(c); |
284 | else if (baccent && keys->baccent(c)) | 284 | else if (baccent && keys->baccent(c)) |
285 | c = keys->baccent(c); | 285 | c = keys->baccent(c); |
286 | else if (accent && keys->accent(c)) | 286 | else if (accent && keys->accent(c)) |
287 | c = keys->accent(c); | 287 | c = keys->accent(c); |
288 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 288 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
289 | 289 | ||
290 | if (c == 0x2c6) | 290 | if (c == 0x2c6) |
291 | c = 0xa8; | 291 | c = 0xa8; |
292 | else | 292 | else |
293 | c = keys->diaeresis(c); | 293 | c = keys->diaeresis(c); |
294 | } | 294 | } |
295 | 295 | ||
296 | p.drawText(x, y, | 296 | p.drawText(x, y, |
297 | keyWidthPix + 3, keyHeight, | 297 | keyWidthPix + 3, keyHeight, |
298 | AlignCenter, (QChar)c); | 298 | AlignCenter, (QChar)c); |
299 | } | 299 | } |
300 | else { | 300 | else { |
301 | // center the image in the middle of the key | 301 | // center the image in the middle of the key |
302 | pix->setColor(1, textcolor.rgb()); | 302 | pix->setColor(1, textcolor.rgb()); |
303 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, | 303 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, |
304 | y + (keyHeight - pix->height())/2 + 1, | 304 | y + (keyHeight - pix->height())/2 + 1, |
305 | QImage(*pix) ); | 305 | QImage(*pix) ); |
306 | } | 306 | } |
307 | 307 | ||
308 | p.setPen(keycolor_lines); | 308 | p.setPen(keycolor_lines); |
309 | p.drawLine(x, y, x, y + keyHeight); | 309 | p.drawLine(x, y, x, y + keyHeight); |
310 | 310 | ||
311 | x += keyWidthPix; | 311 | x += keyWidthPix; |
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
315 | } | 315 | } |
316 | p.setPen(keycolor_lines); | 316 | p.setPen(keycolor_lines); |
317 | p.drawLine(0, height() - 1, width(), height() - 1); | 317 | p.drawLine(0, height() - 1, width(), height() - 1); |
318 | p.drawLine(width() - 1, 0, width() - 1, height()); | 318 | p.drawLine(width() - 1, 0, width() - 1, height()); |
319 | } | 319 | } |
320 | 320 | ||
321 | } | 321 | } |
322 | 322 | ||
323 | 323 | ||
324 | /* Keyboard::mousePressEvent {{{1 */ | 324 | /* Keyboard::mousePressEvent {{{1 */ |
325 | void Keyboard::mousePressEvent(QMouseEvent *e) | 325 | void Keyboard::mousePressEvent(QMouseEvent *e) |
326 | { | 326 | { |
327 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 327 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
328 | if (row > 5) row = 5; | 328 | if (row > 5) row = 5; |
329 | 329 | ||
330 | // figure out the column | 330 | // figure out the column |
331 | int col = 0; | 331 | int col = 0; |
332 | for (int w = 0; e->x() >= w; col++) | 332 | for (int w = 0; e->x() >= w; col++) |
333 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 333 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
334 | w += keys->width(row,col) * defaultKeyWidth; | 334 | w += keys->width(row,col) * defaultKeyWidth; |
335 | else break; | 335 | else break; |
336 | 336 | ||
337 | if (col <= 0) return; | 337 | if (col <= 0) return; |
338 | 338 | ||
339 | col --; // rewind one... | 339 | col --; // rewind one... |
340 | 340 | ||
341 | qkeycode = keys->qcode(row, col); | 341 | qkeycode = keys->qcode(row, col); |
342 | unicode = keys->uni(row, col); | 342 | unicode = keys->uni(row, col); |
343 | 343 | ||
344 | // might need to repaint if two or more of the same keys. | 344 | // might need to repaint if two or more of the same keys. |
345 | // should be faster if just paint one key even though multiple keys exist. | 345 | // should be faster if just paint one key even though multiple keys exist. |
346 | bool need_repaint = FALSE; | 346 | bool need_repaint = FALSE; |
347 | 347 | ||
348 | // circumflex and diaeresis support | 348 | // circumflex and diaeresis support |
349 | // messy to have this here, but too hard to implement any other method | 349 | // messy to have this here, but too hard to implement any other method |
350 | if (unicode == 0x2c6) { | 350 | if (unicode == 0x2c6) { |
351 | 351 | ||
352 | unicode = 0; | 352 | unicode = 0; |
353 | if (shift || lock) { | 353 | if (shift || lock) { |
354 | 354 | ||
355 | // diaeresis | 355 | // diaeresis |
356 | qkeycode = 0x2001; | 356 | qkeycode = 0x2001; |
357 | } | 357 | } |
358 | else { | 358 | else { |
359 | 359 | ||
360 | // circumflex | 360 | // circumflex |
361 | qkeycode = 0x2000; | 361 | qkeycode = 0x2000; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | // Back accent character support | 365 | // Back accent character support |
366 | 366 | ||
367 | if (unicode == 0x60) { | 367 | //if (unicode == 0x60) { // the keys from 2c6 ~ 2cf should be used instead of the ascii one |
368 | if (unicode == 0x2cb) { | ||
368 | 369 | ||
369 | unicode = 0; | 370 | unicode = 0; |
370 | if (shift || lock) { | 371 | if (shift || lock) { |
371 | 372 | ||
372 | // circumblex | 373 | // circumblex |
373 | qkeycode = 0x2000; | 374 | qkeycode = 0x2000; |
374 | } | 375 | } |
375 | else { | 376 | else { |
376 | 377 | ||
377 | // back accent | 378 | // back accent |
378 | qkeycode = 0x2002; | 379 | qkeycode = 0x2002; |
379 | } | 380 | } |
380 | } | 381 | } |
381 | 382 | ||
382 | // Accent character support | 383 | // Accent character support |
383 | 384 | ||
384 | if (unicode == 0xb4) { | 385 | //if (unicode == 0xb4) { |
386 | if (unicode == 0x2ca) { | ||
385 | 387 | ||
386 | unicode = 0; | 388 | unicode = 0; |
387 | if (shift || lock) { | 389 | if (shift || lock) { |
388 | 390 | ||
389 | // diaeresis | 391 | // diaeresis |
390 | qkeycode = 0x2001; | 392 | qkeycode = 0x2001; |
391 | } | 393 | } |
392 | else { | 394 | else { |
393 | 395 | ||
394 | // accent | 396 | // accent |
395 | qkeycode = 0x2003; | 397 | qkeycode = 0x2003; |
396 | } | 398 | } |
397 | } | 399 | } |
398 | 400 | ||
399 | 401 | ||
400 | if (unicode == 0) { // either Qt char, or nothing | 402 | if (unicode == 0) { // either Qt char, or nothing |
401 | 403 | ||
402 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 404 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
403 | 405 | ||
404 | if ( configdlg ) { | 406 | if ( configdlg ) { |
405 | 407 | ||
406 | delete (ConfigDlg *) configdlg; | 408 | delete (ConfigDlg *) configdlg; |
407 | configdlg = 0; | 409 | configdlg = 0; |
408 | } | 410 | } |
409 | else { | 411 | else { |
410 | configdlg = new ConfigDlg (); | 412 | configdlg = new ConfigDlg (); |
411 | connect(configdlg, SIGNAL(setMapToDefault()), | 413 | connect(configdlg, SIGNAL(setMapToDefault()), |
412 | this, SLOT(setMapToDefault())); | 414 | this, SLOT(setMapToDefault())); |
413 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 415 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
414 | this, SLOT(setMapToFile(QString))); | 416 | this, SLOT(setMapToFile(QString))); |
415 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 417 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
416 | this, SLOT(togglePickboard(bool))); | 418 | this, SLOT(togglePickboard(bool))); |
417 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 419 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
418 | this, SLOT(toggleRepeat(bool))); | 420 | this, SLOT(toggleRepeat(bool))); |
419 | connect(configdlg, SIGNAL(reloadKeyboard()), | 421 | connect(configdlg, SIGNAL(reloadKeyboard()), |
420 | this, SLOT(reloadKeyboard())); | 422 | this, SLOT(reloadKeyboard())); |
421 | connect(configdlg, SIGNAL(configDlgClosed()), | 423 | connect(configdlg, SIGNAL(configDlgClosed()), |
422 | this, SLOT(cleanupConfigDlg())); | 424 | this, SLOT(cleanupConfigDlg())); |
423 | configdlg->showMaximized(); | 425 | configdlg->showMaximized(); |
424 | configdlg->show(); | 426 | configdlg->show(); |
425 | configdlg->raise(); | 427 | configdlg->raise(); |
426 | } | 428 | } |
427 | 429 | ||
428 | } else if (qkeycode == Qt::Key_Control) { | 430 | } else if (qkeycode == Qt::Key_Control) { |
429 | need_repaint = TRUE; | 431 | need_repaint = TRUE; |
430 | 432 | ||
431 | if (ctrl) { | 433 | if (ctrl) { |
432 | 434 | ||
433 | *ctrl = 0; | 435 | *ctrl = 0; |
434 | ctrl = 0; | 436 | ctrl = 0; |
435 | 437 | ||
436 | } else { | 438 | } else { |
437 | 439 | ||
438 | ctrl = keys->pressedPtr(row, col); | 440 | ctrl = keys->pressedPtr(row, col); |
439 | need_repaint = TRUE; | 441 | need_repaint = TRUE; |
440 | *ctrl = !keys->pressed(row, col); | 442 | *ctrl = !keys->pressed(row, col); |
441 | 443 | ||
442 | } | 444 | } |
443 | 445 | ||
444 | } else if (qkeycode == Qt::Key_Alt) { | 446 | } else if (qkeycode == Qt::Key_Alt) { |
445 | need_repaint = TRUE; | 447 | need_repaint = TRUE; |
446 | 448 | ||
447 | if (alt) { | 449 | if (alt) { |
448 | *alt = 0; | 450 | *alt = 0; |
449 | alt = 0; | 451 | alt = 0; |
450 | 452 | ||
451 | } else { | 453 | } else { |
452 | 454 | ||
453 | alt = keys->pressedPtr(row, col); | 455 | alt = keys->pressedPtr(row, col); |
454 | need_repaint = TRUE; | 456 | need_repaint = TRUE; |
455 | *alt = !keys->pressed(row, col); | 457 | *alt = !keys->pressed(row, col); |
456 | } | 458 | } |
457 | 459 | ||
458 | } else if (qkeycode == Qt::Key_Shift) { | 460 | } else if (qkeycode == Qt::Key_Shift) { |
459 | need_repaint = TRUE; | 461 | need_repaint = TRUE; |
460 | 462 | ||
461 | if (shift) { | 463 | if (shift) { |
462 | *shift = 0; | 464 | *shift = 0; |
463 | shift = 0; | 465 | shift = 0; |
464 | } | 466 | } |
465 | else { | 467 | else { |
466 | shift = keys->pressedPtr(row, col); | 468 | shift = keys->pressedPtr(row, col); |
467 | *shift = 1; | 469 | *shift = 1; |
468 | if (lock) { | 470 | if (lock) { |
469 | *lock = 0; | 471 | *lock = 0; |
470 | lock = 0; | 472 | lock = 0; |
471 | } | 473 | } |
472 | } | 474 | } |
473 | 475 | ||
474 | 476 | ||
475 | /* | 477 | /* |
476 | * want to be able to hit circumflex/diaeresis -> shift | 478 | * want to be able to hit circumflex/diaeresis -> shift |
477 | * to type in shifted circumflex/diaeresis chars. | 479 | * to type in shifted circumflex/diaeresis chars. |
478 | * same thing with meta | 480 | * same thing with meta |
479 | 481 | ||
480 | if (meta) { *meta = 0; meta = 0; } | 482 | if (meta) { *meta = 0; meta = 0; } |
481 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 483 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
482 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 484 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
483 | 485 | ||
484 | */ | 486 | */ |
485 | 487 | ||
486 | } else if (qkeycode == Qt::Key_CapsLock) { | 488 | } else if (qkeycode == Qt::Key_CapsLock) { |
487 | need_repaint = TRUE; | 489 | need_repaint = TRUE; |
488 | 490 | ||
489 | if (lock) { | 491 | if (lock) { |
490 | *lock = 0; | 492 | *lock = 0; |
491 | lock = 0; | 493 | lock = 0; |
492 | } | 494 | } |
493 | else { | 495 | else { |
494 | lock = keys->pressedPtr(row, col);; | 496 | lock = keys->pressedPtr(row, col);; |
495 | *lock = true;; | 497 | *lock = true;; |
496 | if (shift) { | 498 | if (shift) { |
497 | *shift = 0; | 499 | *shift = 0; |
498 | shift = 0; | 500 | shift = 0; |
499 | } | 501 | } |
500 | } | 502 | } |
501 | 503 | ||
502 | /* | 504 | /* |
503 | if (meta) { *meta = 0; meta = 0; } | 505 | if (meta) { *meta = 0; meta = 0; } |
504 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 506 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
505 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 507 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
506 | */ | 508 | */ |
507 | 509 | ||
508 | } else if (qkeycode == Qt::Key_Meta) { | 510 | } else if (qkeycode == Qt::Key_Meta) { |
509 | need_repaint = TRUE; | 511 | need_repaint = TRUE; |
510 | 512 | ||
511 | if (meta) { | 513 | if (meta) { |
512 | *meta = 0; | 514 | *meta = 0; |
513 | meta = 0; | 515 | meta = 0; |
514 | 516 | ||
515 | } else { | 517 | } else { |
516 | 518 | ||
517 | meta = keys->pressedPtr(row, col); | 519 | meta = keys->pressedPtr(row, col); |
518 | *meta = true; | 520 | *meta = true; |
519 | } | 521 | } |
520 | 522 | ||
521 | // reset all the other keys | 523 | // reset all the other keys |
522 | if (shift) { *shift = 0; shift = 0; } | 524 | if (shift) { *shift = 0; shift = 0; } |
523 | if (lock) { *lock = 0; lock = 0; } | 525 | if (lock) { *lock = 0; lock = 0; } |
524 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 526 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
525 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 527 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
526 | if (baccent) { *baccent = 0; baccent = 0; } | 528 | if (baccent) { *baccent = 0; baccent = 0; } |
527 | if (accent) { *accent = 0; accent = 0; } | 529 | if (accent) { *accent = 0; accent = 0; } |
528 | 530 | ||
529 | // dont need to emit this key... acts same as alt | 531 | // dont need to emit this key... acts same as alt |
530 | qkeycode = 0; | 532 | qkeycode = 0; |
531 | 533 | ||
532 | // circumflex | 534 | // circumflex |
533 | } else if (qkeycode == 0x2000) { | 535 | } else if (qkeycode == 0x2000) { |
534 | need_repaint = TRUE; | 536 | need_repaint = TRUE; |
535 | 537 | ||
536 | if (circumflex) { | 538 | if (circumflex) { |
537 | 539 | ||
538 | *circumflex = 0; | 540 | *circumflex = 0; |
539 | circumflex = 0; | 541 | circumflex = 0; |
540 | 542 | ||
541 | } else { | 543 | } else { |
542 | 544 | ||
543 | circumflex = keys->pressedPtr(row, col); | 545 | circumflex = keys->pressedPtr(row, col); |
544 | *circumflex = true; | 546 | *circumflex = true; |
545 | } | 547 | } |
546 | 548 | ||
547 | /* no need to turn off shift or lock if circumflex | 549 | /* no need to turn off shift or lock if circumflex |
548 | * keys are pressed | 550 | * keys are pressed |
549 | 551 | ||
550 | if (shift) { *shift = 0; shift = 0; } | 552 | if (shift) { *shift = 0; shift = 0; } |
551 | if (lock) { *lock = 0; lock = 0; } | 553 | if (lock) { *lock = 0; lock = 0; } |
552 | 554 | ||
553 | */ | 555 | */ |
554 | 556 | ||
555 | // have to reset all the other keys | 557 | // have to reset all the other keys |
556 | if (meta) { *meta = 0; meta = 0; } | 558 | if (meta) { *meta = 0; meta = 0; } |
557 | if (diaeresis) { | 559 | if (diaeresis) { |
558 | 560 | ||
559 | // *diaeresis and *circumflex point to the same thing | 561 | // *diaeresis and *circumflex point to the same thing |
560 | // when diaeresis is enabled and you hit the circumflex | 562 | // when diaeresis is enabled and you hit the circumflex |
561 | // since they are the same key, it should turn off the | 563 | // since they are the same key, it should turn off the |
562 | // key | 564 | // key |
563 | 565 | ||
564 | *diaeresis = 0; | 566 | *diaeresis = 0; |
565 | diaeresis = 0; | 567 | diaeresis = 0; |
566 | circumflex = 0; | 568 | circumflex = 0; |
567 | } | 569 | } |
568 | 570 | ||
569 | qkeycode = 0; | 571 | qkeycode = 0; |
570 | 572 | ||
571 | // diaeresis | 573 | // diaeresis |
572 | } else if (qkeycode == 0x2001) { | 574 | } else if (qkeycode == 0x2001) { |
573 | need_repaint = TRUE; | 575 | need_repaint = TRUE; |
574 | 576 | ||
575 | if (diaeresis) { | 577 | if (diaeresis) { |
576 | 578 | ||
577 | *diaeresis = 0; | 579 | *diaeresis = 0; |
578 | diaeresis = 0; | 580 | diaeresis = 0; |
579 | 581 | ||
580 | } else { | 582 | } else { |
581 | 583 | ||
582 | diaeresis = keys->pressedPtr(row, col); | 584 | diaeresis = keys->pressedPtr(row, col); |
583 | *diaeresis = true; | 585 | *diaeresis = true; |
584 | } | 586 | } |
585 | 587 | ||
586 | 588 | ||
587 | if (shift) { *shift = 0; shift = 0; } | 589 | if (shift) { *shift = 0; shift = 0; } |
588 | 590 | ||
589 | /* | 591 | /* |
590 | * | 592 | * |
591 | if (lock) { *lock = 0; lock = 0; } | 593 | if (lock) { *lock = 0; lock = 0; } |
592 | * | 594 | * |
593 | */ | 595 | */ |
594 | 596 | ||
595 | if (meta) { *meta = 0; meta = 0; } | 597 | if (meta) { *meta = 0; meta = 0; } |
596 | if (circumflex) { | 598 | if (circumflex) { |
597 | 599 | ||
598 | // *circumflex = 0; | 600 | // *circumflex = 0; |
599 | // | 601 | // |
600 | // same thing the diaeresis pointer points too | 602 | // same thing the diaeresis pointer points too |
601 | 603 | ||
602 | circumflex = 0; | 604 | circumflex = 0; |
603 | } | 605 | } |
604 | 606 | ||
605 | 607 | ||
606 | qkeycode = 0; | 608 | qkeycode = 0; |
607 | 609 | ||
608 | // Back accent | 610 | // Back accent |
609 | } else if (qkeycode == 0x2002) { | 611 | } else if (qkeycode == 0x2002) { |
610 | need_repaint = TRUE; | 612 | need_repaint = TRUE; |
611 | 613 | ||
612 | if (baccent) { | 614 | if (baccent) { |
613 | 615 | ||
614 | *baccent = 0; | 616 | *baccent = 0; |
615 | baccent = 0; | 617 | baccent = 0; |
616 | 618 | ||
617 | } else { | 619 | } else { |
618 | 620 | ||
619 | baccent = keys->pressedPtr(row, col); | 621 | baccent = keys->pressedPtr(row, col); |
620 | *baccent = true; | 622 | *baccent = true; |
621 | } | 623 | } |
622 | 624 | ||
623 | 625 | ||
624 | if (shift) { *shift = 0; shift = 0; } | 626 | if (shift) { *shift = 0; shift = 0; } |
625 | if (meta) { *meta = 0; meta = 0; } | 627 | if (meta) { *meta = 0; meta = 0; } |
626 | if (accent) { *accent = 0; accent = 0; } | 628 | if (accent) { *accent = 0; accent = 0; } |
627 | 629 | ||
628 | qkeycode = 0; | 630 | qkeycode = 0; |
629 | 631 | ||
630 | // Accent | 632 | // Accent |
631 | } else if (qkeycode == 0x2003) { | 633 | } else if (qkeycode == 0x2003) { |
632 | need_repaint = TRUE; | 634 | need_repaint = TRUE; |
633 | 635 | ||
634 | if (accent) { | 636 | if (accent) { |
635 | 637 | ||
636 | *accent = 0; | 638 | *accent = 0; |
637 | accent = 0; | 639 | accent = 0; |
638 | 640 | ||
639 | } else { | 641 | } else { |
640 | 642 | ||
641 | accent = keys->pressedPtr(row, col); | 643 | accent = keys->pressedPtr(row, col); |
642 | *accent = true; | 644 | *accent = true; |
643 | } | 645 | } |
644 | 646 | ||
645 | 647 | ||
646 | if (shift) { *shift = 0; shift = 0; } | 648 | if (shift) { *shift = 0; shift = 0; } |
647 | if (meta) { *meta = 0; meta = 0; } | 649 | if (meta) { *meta = 0; meta = 0; } |
648 | if (baccent) { *baccent = 0; } | 650 | if (baccent) { *baccent = 0; } |
649 | 651 | ||
650 | qkeycode = 0; | 652 | qkeycode = 0; |
651 | } | 653 | } |
652 | 654 | ||
653 | } | 655 | } |
654 | else { // normal char | 656 | else { // normal char |
655 | if ((shift || lock) && keys->shift(unicode)) { | 657 | if ((shift || lock) && keys->shift(unicode)) { |
656 | 658 | ||
657 | // make diaeresis/circumflex -> shift input shifted | 659 | // make diaeresis/circumflex -> shift input shifted |
658 | // diaeresis/circumflex chars | 660 | // diaeresis/circumflex chars |
659 | 661 | ||
660 | if (circumflex && keys->circumflex(keys->shift(unicode))) | 662 | if (circumflex && keys->circumflex(keys->shift(unicode))) |
661 | unicode = keys->circumflex(keys->shift(unicode)); | 663 | unicode = keys->circumflex(keys->shift(unicode)); |
662 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) | 664 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) |
663 | unicode = keys->diaeresis(keys->shift(unicode)); | 665 | unicode = keys->diaeresis(keys->shift(unicode)); |
664 | else if (baccent && keys->baccent(keys->shift(unicode))) | 666 | else if (baccent && keys->baccent(keys->shift(unicode))) |
665 | unicode = keys->baccent(keys->shift(unicode)); | 667 | unicode = keys->baccent(keys->shift(unicode)); |
666 | else if (accent && keys->accent(keys->shift(unicode))) | 668 | else if (accent && keys->accent(keys->shift(unicode))) |
667 | unicode = keys->accent(keys->shift(unicode)); | 669 | unicode = keys->accent(keys->shift(unicode)); |
668 | else if (meta && keys->meta(keys->shift(unicode))) | 670 | else if (meta && keys->meta(keys->shift(unicode))) |
669 | unicode = keys->meta(keys->shift(unicode)); | 671 | unicode = keys->meta(keys->shift(unicode)); |
670 | else | 672 | else |
671 | unicode = keys->shift(unicode); | 673 | unicode = keys->shift(unicode); |
672 | } | 674 | } |
673 | else if (meta && keys->meta(unicode)) { | 675 | else if (meta && keys->meta(unicode)) { |
674 | unicode = keys->meta(unicode); | 676 | unicode = keys->meta(unicode); |
675 | } | 677 | } |
676 | else if (circumflex && keys->circumflex(unicode)) { | 678 | else if (circumflex && keys->circumflex(unicode)) { |
677 | unicode = keys->circumflex(unicode); | 679 | unicode = keys->circumflex(unicode); |
678 | } | 680 | } |
679 | else if (diaeresis && keys->diaeresis(unicode)) { | 681 | else if (diaeresis && keys->diaeresis(unicode)) { |
680 | 682 | ||
681 | unicode = keys->diaeresis(unicode); | 683 | unicode = keys->diaeresis(unicode); |
682 | } | 684 | } |
683 | else if (baccent && keys->baccent(unicode)) { | 685 | else if (baccent && keys->baccent(unicode)) { |
684 | unicode = keys->baccent(unicode); | 686 | unicode = keys->baccent(unicode); |
685 | } | 687 | } |
686 | else if (accent && keys->accent(unicode)) { | 688 | else if (accent && keys->accent(unicode)) { |
687 | unicode = keys->accent(unicode); | 689 | unicode = keys->accent(unicode); |
688 | } | 690 | } |
689 | } | 691 | } |
690 | 692 | ||
691 | // korean parsing | 693 | // korean parsing |
692 | if (keys->lang == "ko") { | 694 | if (keys->lang == "ko") { |
693 | 695 | ||
694 | unicode = parseKoreanInput(unicode); | 696 | unicode = parseKoreanInput(unicode); |
695 | } | 697 | } |
696 | 698 | ||
697 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 699 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
698 | 700 | ||
699 | if ('A' <= unicode && unicode <= 'z' && modifiers) { | 701 | if ('A' <= unicode && unicode <= 'z' && modifiers) { |
700 | 702 | ||
701 | qkeycode = QChar(unicode).upper(); | 703 | qkeycode = QChar(unicode).upper(); |
702 | unicode = qkeycode - '@'; | 704 | unicode = qkeycode - '@'; |
703 | } | 705 | } |
704 | 706 | ||
705 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); | 707 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); |
706 | 708 | ||
707 | // pickboard stuff | 709 | // pickboard stuff |
708 | if (usePicks) { | 710 | if (usePicks) { |
709 | 711 | ||
710 | KeyboardConfig *dc = picks->dc; | 712 | KeyboardConfig *dc = picks->dc; |
711 | 713 | ||
712 | if (dc) { | 714 | if (dc) { |
713 | if (qkeycode == Qt::Key_Backspace) { | 715 | if (qkeycode == Qt::Key_Backspace) { |
714 | dc->input.remove(dc->input.last()); // remove last input | 716 | dc->input.remove(dc->input.last()); // remove last input |
715 | dc->decBackspaces(); | 717 | dc->decBackspaces(); |
716 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 718 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
717 | dc->input.clear(); | 719 | dc->input.clear(); |
718 | dc->resetBackspaces(); | 720 | dc->resetBackspaces(); |
719 | } else { | 721 | } else { |
720 | dc->add(QString(QChar(unicode))); | 722 | dc->add(QString(QChar(unicode))); |
721 | dc->incBackspaces(); | 723 | dc->incBackspaces(); |
722 | } | 724 | } |
723 | } | 725 | } |
724 | picks->repaint(); | 726 | picks->repaint(); |
725 | } | 727 | } |
726 | 728 | ||
727 | 729 | ||
728 | // painting | 730 | // painting |
729 | pressed = TRUE; | 731 | pressed = TRUE; |
730 | 732 | ||
731 | pressedKeyRow = row; | 733 | pressedKeyRow = row; |
732 | pressedKeyCol = col; | 734 | pressedKeyCol = col; |
733 | 735 | ||
734 | if (need_repaint) repaint(FALSE); | 736 | if (need_repaint) repaint(FALSE); |
735 | else { // just paint the one key pressed | 737 | else { // just paint the one key pressed |
736 | 738 | ||
737 | 739 | ||
738 | 740 | ||
739 | QPainter p(this); | 741 | QPainter p(this); |
740 | drawKeyboard(p, row, col); | 742 | drawKeyboard(p, row, col); |
741 | 743 | ||
742 | } | 744 | } |
743 | 745 | ||
744 | if (useRepeat) repeatTimer->start( 800 ); | 746 | if (useRepeat) repeatTimer->start( 800 ); |
745 | //pressTid = startTimer(80); | 747 | //pressTid = startTimer(80); |
746 | 748 | ||
747 | } | 749 | } |
748 | 750 | ||
749 | 751 | ||
750 | /* Keyboard::mouseReleaseEvent {{{1 */ | 752 | /* Keyboard::mouseReleaseEvent {{{1 */ |
751 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 753 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
752 | { | 754 | { |
753 | pressed = FALSE; | 755 | pressed = FALSE; |
754 | //if ( pressTid == 0 ) | 756 | //if ( pressTid == 0 ) |
755 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 757 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
756 | if ( unicode != -1 ) { | 758 | if ( unicode != -1 ) { |
757 | emit key( unicode, qkeycode, modifiers, false, false ); | 759 | emit key( unicode, qkeycode, modifiers, false, false ); |
758 | repeatTimer->stop(); | 760 | repeatTimer->stop(); |
759 | } | 761 | } |
760 | #endif | 762 | #endif |
761 | if (shift && unicode != 0) { | 763 | if (shift && unicode != 0) { |
762 | 764 | ||
763 | 765 | ||
764 | *shift = 0; // unpress shift key | 766 | *shift = 0; // unpress shift key |
765 | shift = 0; // reset the shift pointer | 767 | shift = 0; // reset the shift pointer |
766 | repaint(FALSE); | 768 | repaint(FALSE); |
767 | 769 | ||
768 | } | 770 | } |
771 | if (ctrl && unicode != 0) { | ||
772 | |||
773 | *ctrl = 0; | ||
774 | ctrl = 0; | ||
775 | repaint(FALSE); | ||
776 | |||
777 | } | ||
769 | 778 | ||
770 | /* | 779 | /* |
771 | * do not make the meta key release after being pressed | 780 | * do not make the meta key release after being pressed |
772 | * | 781 | * |
773 | 782 | ||
774 | else if (meta && unicode != 0) { | 783 | else if (meta && unicode != 0) { |
775 | 784 | ||
776 | *meta = 0; | 785 | *meta = 0; |
777 | meta = 0; | 786 | meta = 0; |
778 | repaint(FALSE); | 787 | repaint(FALSE); |
779 | } | 788 | } |
780 | 789 | ||
781 | */ | 790 | */ |
782 | 791 | ||
783 | else clearHighlight(); | 792 | else clearHighlight(); |
784 | } | 793 | } |
785 | 794 | ||
786 | /* Keyboard::timerEvent {{{1 */ | 795 | /* Keyboard::timerEvent {{{1 */ |
787 | 796 | ||
788 | /* dont know what this does, but i think it is here so that if your screen | 797 | /* dont know what this does, but i think it is here so that if your screen |
789 | * sticks (like on an ipaq) then it will stop repeating if you click another | 798 | * sticks (like on an ipaq) then it will stop repeating if you click another |
790 | * key... but who knows what anything does in this thing anyway? | 799 | * key... but who knows what anything does in this thing anyway? |
791 | 800 | ||
792 | void Keyboard::timerEvent(QTimerEvent* e) | 801 | void Keyboard::timerEvent(QTimerEvent* e) |
793 | { | 802 | { |
794 | if ( e->timerId() == pressTid ) { | 803 | if ( e->timerId() == pressTid ) { |
795 | killTimer(pressTid); | 804 | killTimer(pressTid); |
796 | pressTid = 0; | 805 | pressTid = 0; |
797 | if ( !pressed ) | 806 | if ( !pressed ) |
798 | cout << "calling clearHighlight from timerEvent\n"; | 807 | cout << "calling clearHighlight from timerEvent\n"; |
799 | //clearHighlight(); | 808 | //clearHighlight(); |
800 | } | 809 | } |
801 | } | 810 | } |
802 | */ | 811 | */ |
803 | 812 | ||
804 | void Keyboard::repeat() | 813 | void Keyboard::repeat() |
805 | { | 814 | { |
806 | 815 | ||
807 | repeatTimer->start( 200 ); | 816 | repeatTimer->start( 200 ); |
808 | emit key( unicode, qkeycode, modifiers, true, true ); | 817 | emit key( unicode, qkeycode, modifiers, true, true ); |
809 | } | 818 | } |
810 | 819 | ||
811 | void Keyboard::clearHighlight() | 820 | void Keyboard::clearHighlight() |
812 | { | 821 | { |
813 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 822 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
814 | int tmpRow = pressedKeyRow; | 823 | int tmpRow = pressedKeyRow; |
815 | int tmpCol = pressedKeyCol; | 824 | int tmpCol = pressedKeyCol; |
816 | 825 | ||
817 | pressedKeyRow = -1; | 826 | pressedKeyRow = -1; |
818 | pressedKeyCol = -1; | 827 | pressedKeyCol = -1; |
819 | 828 | ||
820 | QPainter p(this); | 829 | QPainter p(this); |
821 | drawKeyboard(p, tmpRow, tmpCol); | 830 | drawKeyboard(p, tmpRow, tmpCol); |
822 | } | 831 | } |
823 | } | 832 | } |
824 | 833 | ||
825 | 834 | ||
826 | /* Keyboard::sizeHint {{{1 */ | 835 | /* Keyboard::sizeHint {{{1 */ |
827 | QSize Keyboard::sizeHint() const | 836 | QSize Keyboard::sizeHint() const |
828 | { | 837 | { |
829 | QFontMetrics fm=fontMetrics(); | 838 | QFontMetrics fm=fontMetrics(); |
830 | int keyHeight = fm.lineSpacing() + 2; | 839 | int keyHeight = fm.lineSpacing() + 2; |
831 | 840 | ||
832 | return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); | 841 | return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); |
833 | } | 842 | } |
834 | 843 | ||
835 | 844 | ||
836 | void Keyboard::resetState() | 845 | void Keyboard::resetState() |
837 | { | 846 | { |
838 | if (shift) { *shift = 0; shift = 0; } | 847 | if (shift) { *shift = 0; shift = 0; } |
839 | if (lock) {*lock = 0; lock = 0; } | 848 | if (lock) {*lock = 0; lock = 0; } |
840 | if (meta) { *meta = 0; meta = 0; } | 849 | if (meta) { *meta = 0; meta = 0; } |
841 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 850 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
842 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 851 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
843 | if (baccent) { *baccent = 0; baccent = 0; } | 852 | if (baccent) { *baccent = 0; baccent = 0; } |
844 | if (accent) { *accent = 0; accent = 0; } | 853 | if (accent) { *accent = 0; accent = 0; } |
845 | 854 | ||
846 | schar = mchar = echar = 0; | 855 | schar = mchar = echar = 0; |
847 | picks->resetState(); | 856 | picks->resetState(); |
848 | } | 857 | } |
849 | 858 | ||
850 | /* Keyboard::togglePickboard {{{1 */ | 859 | /* Keyboard::togglePickboard {{{1 */ |
851 | void Keyboard::togglePickboard(bool on_off) | 860 | void Keyboard::togglePickboard(bool on_off) |
852 | { | 861 | { |
853 | usePicks = on_off; | 862 | usePicks = on_off; |
854 | if (usePicks) { | 863 | if (usePicks) { |
855 | picks->show(); | 864 | picks->show(); |
856 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 865 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
857 | //adjustSize(); | 866 | //adjustSize(); |
858 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 867 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
859 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 868 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
860 | } else { | 869 | } else { |
861 | 870 | ||
862 | picks->hide(); | 871 | picks->hide(); |
863 | picks->resetState(); | 872 | picks->resetState(); |
864 | //move(x(), y() + picks->height()); | 873 | //move(x(), y() + picks->height()); |
865 | //adjustSize(); | 874 | //adjustSize(); |
866 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 875 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
867 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 876 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
868 | 877 | ||
869 | } | 878 | } |
870 | /* | 879 | /* |
871 | * this closes && opens the input method | 880 | * this closes && opens the input method |
872 | */ | 881 | */ |
873 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 882 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
874 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 883 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
875 | } | 884 | } |
876 | 885 | ||
877 | void Keyboard::toggleRepeat(bool on) { | 886 | void Keyboard::toggleRepeat(bool on) { |
878 | 887 | ||
879 | useRepeat = on; | 888 | useRepeat = on; |
880 | //cout << "setting useRepeat to: " << useRepeat << "\n"; | 889 | //cout << "setting useRepeat to: " << useRepeat << "\n"; |
881 | } | 890 | } |
882 | 891 | ||
883 | void Keyboard::cleanupConfigDlg() { | 892 | void Keyboard::cleanupConfigDlg() { |
884 | 893 | ||
885 | if ( configdlg ) { | 894 | if ( configdlg ) { |
886 | delete (ConfigDlg *) configdlg; | 895 | delete (ConfigDlg *) configdlg; |
887 | configdlg = 0; | 896 | configdlg = 0; |
888 | } | 897 | } |
889 | } | 898 | } |
890 | 899 | ||
891 | /* Keyboard::setMapTo ... {{{1 */ | 900 | /* Keyboard::setMapTo ... {{{1 */ |
892 | void Keyboard::setMapToDefault() { | 901 | void Keyboard::setMapToDefault() { |
893 | 902 | ||
894 | 903 | ||
895 | /* load current locale language map */ | 904 | /* load current locale language map */ |
896 | Config *config = new Config("locale"); | 905 | Config *config = new Config("locale"); |
897 | config->setGroup( "Language" ); | 906 | config->setGroup( "Language" ); |
898 | QString l = config->readEntry( "Language" , "en" ); | 907 | QString l = config->readEntry( "Language" , "en" ); |
899 | delete config; | 908 | delete config; |
900 | 909 | ||
901 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" | 910 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" |
902 | + l + ".keymap"; | 911 | + l + ".keymap"; |
903 | 912 | ||
904 | /* save change to multikey config file */ | 913 | /* save change to multikey config file */ |
905 | config = new Config("multikey"); | 914 | config = new Config("multikey"); |
906 | config->setGroup ("keymaps"); | 915 | config->setGroup ("keymaps"); |
907 | config->writeEntry ("current", key_map); // default closed | 916 | config->writeEntry ("current", key_map); // default closed |
908 | delete config; | 917 | delete config; |
909 | 918 | ||
910 | int prevRows = keys->rows(); | 919 | int prevRows = keys->rows(); |
911 | 920 | ||
912 | delete keys; | 921 | delete keys; |
913 | keys = new Keys(key_map); | 922 | keys = new Keys(key_map); |
914 | 923 | ||
915 | // have to repaint the keyboard | 924 | // have to repaint the keyboard |
916 | if (prevRows != keys->rows()) { | 925 | if (prevRows != keys->rows()) { |
917 | 926 | ||
918 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 927 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
919 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 928 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
920 | 929 | ||
921 | } else repaint(FALSE); | 930 | } else repaint(FALSE); |
922 | 931 | ||
923 | resetState(); | 932 | resetState(); |
924 | } | 933 | } |
925 | 934 | ||
926 | void Keyboard::setMapToFile(QString map) { | 935 | void Keyboard::setMapToFile(QString map) { |
927 | 936 | ||
928 | /* save change to multikey config file */ | 937 | /* save change to multikey config file */ |
929 | Config *config = new Config("multikey"); | 938 | Config *config = new Config("multikey"); |
930 | config->setGroup ("keymaps"); | 939 | config->setGroup ("keymaps"); |
931 | config->writeEntry ("current", map); // default closed | 940 | config->writeEntry ("current", map); // default closed |
932 | 941 | ||
933 | delete config; | 942 | delete config; |
934 | 943 | ||
935 | int prevRows = keys->rows(); | 944 | int prevRows = keys->rows(); |
936 | 945 | ||
937 | delete keys; | 946 | delete keys; |
938 | if (QFile(map).exists()) | 947 | if (QFile(map).exists()) |
939 | keys = new Keys(map); | 948 | keys = new Keys(map); |
940 | else | 949 | else |
941 | keys = new Keys(); | 950 | keys = new Keys(); |
942 | 951 | ||
943 | if (keys->rows() != prevRows) { | 952 | if (keys->rows() != prevRows) { |
944 | 953 | ||
945 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 954 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
946 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 955 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
947 | } | 956 | } |
948 | else repaint(FALSE); | 957 | else repaint(FALSE); |
949 | 958 | ||
950 | resetState(); | 959 | resetState(); |
951 | } | 960 | } |
952 | 961 | ||
953 | /* Keybaord::reloadKeyboard {{{1 */ | 962 | /* Keybaord::reloadKeyboard {{{1 */ |
954 | void Keyboard::reloadKeyboard() { | 963 | void Keyboard::reloadKeyboard() { |
955 | 964 | ||
956 | // reload colors and redraw | 965 | // reload colors and redraw |
957 | loadKeyboardColors(); | 966 | loadKeyboardColors(); |
958 | repaint(); | 967 | repaint(); |
959 | 968 | ||
960 | } | 969 | } |
961 | 970 | ||
962 | void Keyboard::loadKeyboardColors() { | 971 | void Keyboard::loadKeyboardColors() { |
963 | 972 | ||
964 | Config config ("multikey"); | 973 | Config config ("multikey"); |
965 | config.setGroup("colors"); | 974 | config.setGroup("colors"); |
966 | 975 | ||
967 | QStringList color; | 976 | QStringList color; |
968 | color = config.readListEntry("keycolor", QChar(',')); | 977 | color = config.readListEntry("keycolor", QChar(',')); |
969 | if (color.isEmpty()) { | 978 | if (color.isEmpty()) { |
970 | color = QStringList::split(",", "240,240,240"); | 979 | color = QStringList::split(",", "240,240,240"); |
971 | config.writeEntry("keycolor", color.join(",")); | 980 | config.writeEntry("keycolor", color.join(",")); |
972 | 981 | ||
973 | } | 982 | } |
974 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 983 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
975 | 984 | ||
976 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 985 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
977 | if (color.isEmpty()) { | 986 | if (color.isEmpty()) { |
978 | color = QStringList::split(",", "171,183,198"); | 987 | color = QStringList::split(",", "171,183,198"); |
979 | config.writeEntry("keycolor_pressed", color.join(",")); | 988 | config.writeEntry("keycolor_pressed", color.join(",")); |
980 | 989 | ||
981 | } | 990 | } |
982 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 991 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
983 | 992 | ||
984 | color = config.readListEntry("keycolor_lines", QChar(',')); | 993 | color = config.readListEntry("keycolor_lines", QChar(',')); |
985 | if (color.isEmpty()) { | 994 | if (color.isEmpty()) { |
986 | color = QStringList::split(",", "138,148,160"); | 995 | color = QStringList::split(",", "138,148,160"); |
987 | config.writeEntry("keycolor_lines", color.join(",")); | 996 | config.writeEntry("keycolor_lines", color.join(",")); |
988 | 997 | ||
989 | } | 998 | } |
990 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 999 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
991 | 1000 | ||
992 | color = config.readListEntry("textcolor", QChar(',')); | 1001 | color = config.readListEntry("textcolor", QChar(',')); |
993 | if (color.isEmpty()) { | 1002 | if (color.isEmpty()) { |
994 | color = QStringList::split(",", "43,54,68"); | 1003 | color = QStringList::split(",", "43,54,68"); |
995 | config.writeEntry("textcolor", color.join(",")); | 1004 | config.writeEntry("textcolor", color.join(",")); |
996 | 1005 | ||
997 | } | 1006 | } |
998 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 1007 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
999 | 1008 | ||
1000 | } | 1009 | } |
1001 | 1010 | ||
1002 | /* korean input functions {{{1 | 1011 | /* korean input functions {{{1 |
1003 | * | 1012 | * |
1004 | * TODO | 1013 | * TODO |
1005 | * one major problem with this implementation is that you can't move the | 1014 | * one major problem with this implementation is that you can't move the |
1006 | * cursor after inputing korean chars, otherwise it will eat up and replace | 1015 | * cursor after inputing korean chars, otherwise it will eat up and replace |
1007 | * the char before the cursor you move to. fix that | 1016 | * the char before the cursor you move to. fix that |
1008 | * | 1017 | * |
1009 | * make backspace delete one single char, not the whole thing if still | 1018 | * make backspace delete one single char, not the whole thing if still |
1010 | * editing. | 1019 | * editing. |
1011 | * | 1020 | * |
1012 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 1021 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
1013 | * | 1022 | * |
1014 | * how korean input works | 1023 | * how korean input works |
1015 | * | 1024 | * |
1016 | * all following chars means unicode char value and are in hex | 1025 | * all following chars means unicode char value and are in hex |
1017 | * | 1026 | * |
1018 | * = schar (start char) | 1027 | * 초음 = schar (start char) |
1019 | * = mchar (middle char) | 1028 | * 중음 = mchar (middle char) |
1020 | * = echar (end char) | 1029 | * 끝음 = echar (end char) |
1021 | * | 1030 | * |
1022 | * there are 19 schars. unicode position is at 1100 - 1112 | 1031 | * there are 19 schars. unicode position is at 1100 - 1112 |
1023 | * there are 21 mchars. unicode position is at 1161 - 1175 | 1032 | * there are 21 mchars. unicode position is at 1161 - 1175 |
1024 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 1033 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
1025 | * | 1034 | * |
1026 | * the map with everything combined is at ac00 - d7a3 | 1035 | * the map with everything combined is at ac00 - d7a3 |
1027 | * | 1036 | * |
1028 | */ | 1037 | */ |
1029 | 1038 | ||
1030 | ushort Keyboard::parseKoreanInput (ushort c) { | 1039 | ushort Keyboard::parseKoreanInput (ushort c) { |
1031 | 1040 | ||
1032 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) | 1041 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) |
1033 | || | 1042 | || |
1034 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode | 1043 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode |
1035 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { | 1044 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { |
1036 | 1045 | ||
1037 | schar = 0, mchar = 0, echar = 0; | 1046 | schar = 0, mchar = 0, echar = 0; |
1038 | return c; | 1047 | return c; |
1039 | } | 1048 | } |
1040 | 1049 | ||
1041 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input | 1050 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input |
1042 | 1051 | ||
1043 | if (schar == 0 || (schar != 0 && mchar == 0)) { | 1052 | if (schar == 0 || (schar != 0 && mchar == 0)) { |
1044 | schar = c; mchar = 0; echar = 0; | 1053 | schar = c; mchar = 0; echar = 0; |
1045 | return c; | 1054 | return c; |
1046 | } | 1055 | } |
1047 | else if (mchar != 0) { | 1056 | else if (mchar != 0) { |
1048 | 1057 | ||
1049 | if (echar == 0) { | 1058 | if (echar == 0) { |
1050 | 1059 | ||
1051 | if (!(echar = constoe(c))) { | 1060 | if (!(echar = constoe(c))) { |
1052 | 1061 | ||
1053 | schar = c; mchar = 0; echar = 0; | 1062 | schar = c; mchar = 0; echar = 0; |
1054 | return c; | 1063 | return c; |
1055 | } | 1064 | } |
1056 | 1065 | ||
1057 | } | 1066 | } |
1058 | else { // must figure out what the echar is | 1067 | else { // must figure out what the echar is |
1059 | 1068 | ||
1060 | if (echar == 0x11a8) { // | 1069 | if (echar == 0x11a8) { // ㄱ |
1061 | 1070 | ||
1062 | if (c == 0x1100) echar = 0x11a9; // + | 1071 | if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ |
1063 | else if (c == 0x1109) echar = 0x11aa; // + | 1072 | else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ |
1064 | else { | 1073 | else { |
1065 | schar = c; mchar = 0; echar = 0; | 1074 | schar = c; mchar = 0; echar = 0; |
1066 | return c; | 1075 | return c; |
1067 | } | 1076 | } |
1068 | 1077 | ||
1069 | } else if (echar == 0x11ab) { // | 1078 | } else if (echar == 0x11ab) { // ㄴ |
1070 | 1079 | ||
1071 | if (c == 0x110c) echar = 0x11ac; // + | 1080 | if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ |
1072 | else if (c == 0x1112) echar = 0x11ad; // + | 1081 | else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ |
1073 | else { | 1082 | else { |
1074 | schar = c; mchar = 0; echar = 0; | 1083 | schar = c; mchar = 0; echar = 0; |
1075 | return c; | 1084 | return c; |
1076 | } | 1085 | } |
1077 | 1086 | ||
1078 | } else if (echar == 0x11af) { // | 1087 | } else if (echar == 0x11af) { // ㄹ |
1079 | 1088 | ||
1080 | if (c == 0x1100) echar = 0x11b0; // + | 1089 | if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ |
1081 | else if (c == 0x1106) echar = 0x11b1; // + | 1090 | else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ |
1082 | else if (c == 0x1107) echar = 0x11b2; // + | 1091 | else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ |
1083 | else if (c == 0x1109) echar = 0x11b3; // + | 1092 | else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ |
1084 | else if (c == 0x1110) echar = 0x11b4; // + | 1093 | else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ |
1085 | else if (c == 0x1111) echar = 0x11b5; // + | 1094 | else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ |
1086 | else if (c == 0x1112) echar = 0x11b6; // + | 1095 | else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ |
1087 | else { | 1096 | else { |
1088 | schar = c; mchar = 0; echar = 0; | 1097 | schar = c; mchar = 0; echar = 0; |
1089 | return c; | 1098 | return c; |
1090 | } | 1099 | } |
1091 | 1100 | ||
1092 | } else if (echar == 0x11b8) { // | 1101 | } else if (echar == 0x11b8) { // ㅂ |
1093 | 1102 | ||
1094 | if (c == 0x1109) echar = 0x11b9; // + | 1103 | if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ |
1095 | else { | 1104 | else { |
1096 | schar = c; mchar = 0; echar = 0; | 1105 | schar = c; mchar = 0; echar = 0; |
1097 | return c; | 1106 | return c; |
1098 | } | 1107 | } |
1099 | 1108 | ||
1100 | } else if (echar == 0x11ba) { // | 1109 | } else if (echar == 0x11ba) { // ㅅ |
1101 | 1110 | ||
1102 | if (c == 0x1109) echar = 0x11bb; // + | 1111 | if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ |
1103 | else { | 1112 | else { |
1104 | schar = c; mchar = 0; echar = 0; | 1113 | schar = c; mchar = 0; echar = 0; |
1105 | return c; | 1114 | return c; |
1106 | } | 1115 | } |
1107 | 1116 | ||
1108 | } else { // if any other char, cannot combine chars | 1117 | } else { // if any other char, cannot combine chars |
1109 | 1118 | ||
1110 | schar = c; mchar = 0; echar = 0; | 1119 | schar = c; mchar = 0; echar = 0; |
1111 | return c; | 1120 | return c; |
1112 | } | 1121 | } |
1113 | 1122 | ||
1114 | unicode = echar; | 1123 | unicode = echar; |
1115 | } | 1124 | } |
1116 | } | 1125 | } |
1117 | 1126 | ||
1118 | } | 1127 | } |
1119 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input | 1128 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input |
1120 | 1129 | ||
1121 | if (schar != 0 && mchar == 0) { mchar = c; } | 1130 | if (schar != 0 && mchar == 0) { mchar = c; } |
1122 | 1131 | ||
1123 | else if (schar != 0 && mchar != 0 && echar == 0) { | 1132 | else if (schar != 0 && mchar != 0 && echar == 0) { |
1124 | 1133 | ||
1125 | switch (mchar) { | 1134 | switch (mchar) { |
1126 | case 0x1169: | 1135 | case 0x1169: |
1127 | if (c == 0x1161) mchar = 0x116a; | 1136 | if (c == 0x1161) mchar = 0x116a; |
1128 | else if (c == 0x1162) mchar = 0x116b; | 1137 | else if (c == 0x1162) mchar = 0x116b; |
1129 | else if (c == 0x1175) mchar = 0x116c; | 1138 | else if (c == 0x1175) mchar = 0x116c; |
1130 | else { | 1139 | else { |
1131 | schar = 0; mchar = 0; echar = 0; | 1140 | schar = 0; mchar = 0; echar = 0; |
1132 | return c; | 1141 | return c; |
1133 | } | 1142 | } |
1134 | break; | 1143 | break; |
1135 | case 0x116e: | 1144 | case 0x116e: |
1136 | if (c == 0x1165) mchar = 0x116f; | 1145 | if (c == 0x1165) mchar = 0x116f; |
1137 | else if (c == 0x1166) mchar = 0x1170; | 1146 | else if (c == 0x1166) mchar = 0x1170; |
1138 | else if (c == 0x1175) mchar = 0x1171; | 1147 | else if (c == 0x1175) mchar = 0x1171; |
1139 | else { | 1148 | else { |
1140 | schar = 0; mchar = 0; echar = 0; | 1149 | schar = 0; mchar = 0; echar = 0; |
1141 | return c; | 1150 | return c; |
1142 | } | 1151 | } |
1143 | break; | 1152 | break; |
1144 | case 0x1173: | 1153 | case 0x1173: |
1145 | if (c == 0x1175) mchar = 0x1174; | 1154 | if (c == 0x1175) mchar = 0x1174; |
1146 | else { | 1155 | else { |
1147 | schar = 0; mchar = 0; echar = 0; | 1156 | schar = 0; mchar = 0; echar = 0; |
1148 | return c; | 1157 | return c; |
1149 | } | 1158 | } |
1150 | break; | 1159 | break; |
1151 | default: | 1160 | default: |
1152 | schar = 0; mchar = 0; echar = 0; | 1161 | schar = 0; mchar = 0; echar = 0; |
1153 | return c; | 1162 | return c; |
1154 | } | 1163 | } |
1155 | } | 1164 | } |
1156 | else if (schar != 0 && mchar != 0 && echar != 0) { | 1165 | else if (schar != 0 && mchar != 0 && echar != 0) { |
1157 | 1166 | ||
1158 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1167 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1159 | 1168 | ||
1160 | ushort prev = 0; | 1169 | ushort prev = 0; |
1161 | switch (echar) { | 1170 | switch (echar) { |
1162 | /* | 1171 | /* |
1163 | case 0x11a9: | 1172 | case 0x11a9: |
1164 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1173 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1165 | schar = 0x1100; | 1174 | schar = 0x1100; |
1166 | break; | 1175 | break; |
1167 | */ | 1176 | */ |
1168 | case 0x11aa: | 1177 | case 0x11aa: |
1169 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1178 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1170 | schar = 0x1109; | 1179 | schar = 0x1109; |
1171 | break; | 1180 | break; |
1172 | case 0x11ac: | 1181 | case 0x11ac: |
1173 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1182 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1174 | schar = 0x110c; | 1183 | schar = 0x110c; |
1175 | break; | 1184 | break; |
1176 | case 0x11ad: | 1185 | case 0x11ad: |
1177 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1186 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1178 | schar = 0x1112; | 1187 | schar = 0x1112; |
1179 | break; | 1188 | break; |
1180 | case 0x11b0: | 1189 | case 0x11b0: |
1181 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1190 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1182 | schar = 0x1100; | 1191 | schar = 0x1100; |
1183 | break; | 1192 | break; |
1184 | case 0x11b1: | 1193 | case 0x11b1: |
1185 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1194 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1186 | schar = 0x1106; | 1195 | schar = 0x1106; |
1187 | break; | 1196 | break; |
1188 | case 0x11b2: | 1197 | case 0x11b2: |
1189 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1198 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1190 | schar = 0x1107; | 1199 | schar = 0x1107; |
1191 | break; | 1200 | break; |
1192 | case 0x11b3: | 1201 | case 0x11b3: |
1193 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1202 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1194 | schar = 0x1109; | 1203 | schar = 0x1109; |
1195 | break; | 1204 | break; |
1196 | case 0x11b4: | 1205 | case 0x11b4: |
1197 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1206 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1198 | schar = 0x1110; | 1207 | schar = 0x1110; |
1199 | break; | 1208 | break; |
1200 | case 0x11b9: | 1209 | case 0x11b9: |
1201 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 1210 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
1202 | schar = 0x1109; | 1211 | schar = 0x1109; |
1203 | break; | 1212 | break; |
1204 | /* | 1213 | /* |
1205 | case 0x11bb: | 1214 | case 0x11bb: |
1206 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 1215 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
1207 | schar = 0x1109; | 1216 | schar = 0x1109; |
1208 | break; | 1217 | break; |
1209 | */ | 1218 | */ |
1210 | default: | 1219 | default: |
1211 | 1220 | ||
1212 | if (constoe(echar)) { | 1221 | if (constoe(echar)) { |
1213 | 1222 | ||
1214 | prev = combineKoreanChars(schar, mchar, 0); | 1223 | prev = combineKoreanChars(schar, mchar, 0); |
1215 | schar = constoe(echar); | 1224 | schar = constoe(echar); |
1216 | } | 1225 | } |
1217 | break; | 1226 | break; |
1218 | } | 1227 | } |
1219 | 1228 | ||
1220 | emit key( prev, prev, 0, true, false ); | 1229 | emit key( prev, prev, 0, true, false ); |
1221 | 1230 | ||
1222 | mchar = c; echar = 0; | 1231 | mchar = c; echar = 0; |
1223 | 1232 | ||
1224 | return combineKoreanChars(schar, mchar, 0); | 1233 | return combineKoreanChars(schar, mchar, 0); |
1225 | 1234 | ||
1226 | } | 1235 | } |
1227 | else { | 1236 | else { |
1228 | schar = 0; mchar = 0; echar = 0; | 1237 | schar = 0; mchar = 0; echar = 0; |
1229 | return c; | 1238 | return c; |
1230 | } | 1239 | } |
1231 | 1240 | ||
1232 | } | 1241 | } |
1233 | else /*if (c == ' ')*/ return c; | 1242 | else /*if (c == ' ')*/ return c; |
1234 | 1243 | ||
1235 | 1244 | ||
1236 | // and now... finally delete previous char, and return new char | 1245 | // and now... finally delete previous char, and return new char |
1237 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1246 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1238 | 1247 | ||
1239 | 1248 | ||
1240 | return combineKoreanChars( schar, mchar, echar); | 1249 | return combineKoreanChars( schar, mchar, echar); |
1241 | 1250 | ||
1242 | } | 1251 | } |
1243 | 1252 | ||
1244 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 1253 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
1245 | 1254 | ||
1246 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 1255 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
1247 | 1256 | ||
1248 | } | 1257 | } |
1249 | 1258 | ||
1250 | ushort Keyboard::constoe(const ushort c) { | 1259 | ushort Keyboard::constoe(const ushort c) { |
1251 | 1260 | ||
1252 | // converts schars to echars if possible | 1261 | // converts schars to echars if possible |
1253 | 1262 | ||
1254 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 1263 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
1255 | 1264 | ||
1256 | switch (c) { | 1265 | switch (c) { |
1257 | case 0x1100: return 0x11a8; | 1266 | case 0x1100: return 0x11a8; |
1258 | case 0x1101: return 0x11a9; | 1267 | case 0x1101: return 0x11a9; |
1259 | case 0x1102: return 0x11ab; | 1268 | case 0x1102: return 0x11ab; |
1260 | case 0x1103: return 0x11ae; | 1269 | case 0x1103: return 0x11ae; |
1261 | case 0x1105: return 0x11af; | 1270 | case 0x1105: return 0x11af; |
1262 | case 0x1106: return 0x11b7; | 1271 | case 0x1106: return 0x11b7; |
1263 | case 0x1107: return 0x11b8; | 1272 | case 0x1107: return 0x11b8; |
1264 | case 0x1109: return 0x11ba; | 1273 | case 0x1109: return 0x11ba; |
1265 | case 0x110a: return 0x11bb; | 1274 | case 0x110a: return 0x11bb; |
1266 | case 0x110b: return 0x11bc; | 1275 | case 0x110b: return 0x11bc; |
1267 | case 0x110c: return 0x11bd; | 1276 | case 0x110c: return 0x11bd; |
1268 | case 0x110e: return 0x11be; | 1277 | case 0x110e: return 0x11be; |
1269 | case 0x110f: return 0x11bf; | 1278 | case 0x110f: return 0x11bf; |
1270 | case 0x1110: return 0x11c0; | 1279 | case 0x1110: return 0x11c0; |
1271 | case 0x1111: return 0x11c1; | 1280 | case 0x1111: return 0x11c1; |
1272 | case 0x1112: return 0x11c2; | 1281 | case 0x1112: return 0x11c2; |
1273 | default: return 0; | 1282 | default: return 0; |
1274 | 1283 | ||
1275 | } | 1284 | } |
1276 | 1285 | ||
1277 | } else { //echar to schar | 1286 | } else { //echar to schar |
1278 | 1287 | ||
1279 | switch (c) { | 1288 | switch (c) { |
1280 | case 0x11a8: return 0x1100; | 1289 | case 0x11a8: return 0x1100; |
1281 | case 0x11a9: return 0x1101; | 1290 | case 0x11a9: return 0x1101; |
1282 | case 0x11ab: return 0x1102; | 1291 | case 0x11ab: return 0x1102; |
1283 | case 0x11ae: return 0x1103; | 1292 | case 0x11ae: return 0x1103; |
1284 | case 0x11af: return 0x1105; | 1293 | case 0x11af: return 0x1105; |
1285 | case 0x11b7: return 0x1106; | 1294 | case 0x11b7: return 0x1106; |
1286 | case 0x11b8: return 0x1107; | 1295 | case 0x11b8: return 0x1107; |
1287 | case 0x11ba: return 0x1109; | 1296 | case 0x11ba: return 0x1109; |
1288 | case 0x11bb: return 0x110a; | 1297 | case 0x11bb: return 0x110a; |
1289 | case 0x11bc: return 0x110b; | 1298 | case 0x11bc: return 0x110b; |
1290 | case 0x11bd: return 0x110c; | 1299 | case 0x11bd: return 0x110c; |
1291 | case 0x11be: return 0x110e; | 1300 | case 0x11be: return 0x110e; |
1292 | case 0x11bf: return 0x110f; | 1301 | case 0x11bf: return 0x110f; |
1293 | case 0x11c0: return 0x1110; | 1302 | case 0x11c0: return 0x1110; |
1294 | case 0x11c1: return 0x1111; | 1303 | case 0x11c1: return 0x1111; |
1295 | case 0x11c2: return 0x1112; | 1304 | case 0x11c2: return 0x1112; |
1296 | default: return 0; | 1305 | default: return 0; |
1297 | 1306 | ||
1298 | } | 1307 | } |
1299 | 1308 | ||
1300 | } | 1309 | } |
1301 | } | 1310 | } |
1302 | 1311 | ||
1303 | 1312 | ||
1304 | // Keys::Keys {{{1 | 1313 | // Keys::Keys {{{1 |
1305 | 1314 | ||
1306 | Keys::Keys() { | 1315 | Keys::Keys() { |
1307 | 1316 | ||
1308 | Config *config = new Config ("multikey"); | 1317 | Config *config = new Config ("multikey"); |
1309 | config->setGroup( "keymaps" ); | 1318 | config->setGroup( "keymaps" ); |
1310 | QString map = config->readEntry( "current" ); | 1319 | QString map = config->readEntry( "current" ); |
1311 | delete config; | 1320 | delete config; |
1312 | 1321 | ||
1313 | if (map.isNull() || !(QFile(map).exists())) { | 1322 | if (map.isNull() || !(QFile(map).exists())) { |
1314 | 1323 | ||
1315 | Config *config = new Config("locale"); | 1324 | Config *config = new Config("locale"); |
1316 | config->setGroup( "Language" ); | 1325 | config->setGroup( "Language" ); |
1317 | QString l = config->readEntry( "Language" , "en" ); | 1326 | QString l = config->readEntry( "Language" , "en" ); |
1318 | delete config; | 1327 | delete config; |
1319 | 1328 | ||
1320 | map = QPEApplication::qpeDir() + "/share/multikey/" | 1329 | map = QPEApplication::qpeDir() + "/share/multikey/" |
1321 | + l + ".keymap"; | 1330 | + l + ".keymap"; |
1322 | 1331 | ||
1323 | } | 1332 | } |
1324 | if (map.isNull() || !(QFile(map).exists())) { | 1333 | if (map.isNull() || !(QFile(map).exists())) { |
1325 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; | 1334 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; |
1326 | } | 1335 | } |
1327 | 1336 | ||
1328 | setKeysFromFile(map); | 1337 | setKeysFromFile(map); |
1329 | } | 1338 | } |
1330 | 1339 | ||
1331 | Keys::Keys(const char * filename) { | 1340 | Keys::Keys(const char * filename) { |
1332 | 1341 | ||
1333 | setKeysFromFile(filename); | 1342 | setKeysFromFile(filename); |
1334 | } | 1343 | } |
1335 | 1344 | ||
1336 | // Keys::setKeysFromFile {{{2 | 1345 | // Keys::setKeysFromFile {{{2 |
1337 | void Keys::setKeysFromFile(const char * filename) { | 1346 | void Keys::setKeysFromFile(const char * filename) { |
1338 | 1347 | ||
1339 | QFile f(filename); | 1348 | QFile f(filename); |
1340 | 1349 | ||
1341 | if (f.open(IO_ReadOnly)) { | 1350 | if (f.open(IO_ReadOnly)) { |
1342 | 1351 | ||
1343 | QTextStream t(&f); | 1352 | QTextStream t(&f); |
1344 | int row; | 1353 | int row; |
1345 | int qcode; | 1354 | int qcode; |
1346 | ushort unicode; | 1355 | ushort unicode; |
1347 | int width; | 1356 | int width; |
1348 | QString buf; | 1357 | QString buf; |
1349 | QString comment; | 1358 | QString comment; |
1350 | char * xpm[256]; //couldnt be larger than that... could it? | 1359 | char * xpm[256]; //couldnt be larger than that... could it? |
1351 | QImage *xpm2pix = 0; | 1360 | QImage *xpm2pix = 0; |
1352 | 1361 | ||
1353 | buf = t.readLine(); | 1362 | buf = t.readLine(); |
1354 | while (buf) { | 1363 | while (buf) { |
1355 | 1364 | ||
1356 | // get rid of comments | 1365 | // get rid of comments |
1357 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); | 1366 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); |
1358 | 1367 | ||
1359 | // key definition | 1368 | // key definition |
1360 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 1369 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
1361 | // no $1 type referencing!!! this implementation of regexp sucks | 1370 | // no $1 type referencing!!! this implementation of regexp sucks |
1362 | 1371 | ||
1363 | // dont know of any sscanf() type funcs in Qt lib | 1372 | // dont know of any sscanf() type funcs in Qt lib |
1364 | QTextStream tmp (buf, IO_ReadOnly); | 1373 | QTextStream tmp (buf, IO_ReadOnly); |
1365 | tmp >> row >> qcode >> unicode >> width >> comment; | 1374 | tmp >> row >> qcode >> unicode >> width >> comment; |
1366 | 1375 | ||
1367 | buf = t.readLine(); | 1376 | buf = t.readLine(); |
1368 | int xpmLineCount = 0; | 1377 | int xpmLineCount = 0; |
1369 | xpm2pix = 0; | 1378 | xpm2pix = 0; |
1370 | 1379 | ||
1371 | // erase blank space | 1380 | // erase blank space |
1372 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 1381 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
1373 | 1382 | ||
1374 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 1383 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
1375 | 1384 | ||
1376 | QString xpmBuf = buf.stripWhiteSpace(); | 1385 | QString xpmBuf = buf.stripWhiteSpace(); |
1377 | 1386 | ||
1378 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 1387 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |
1379 | 1388 | ||
1380 | int j = 0; | 1389 | int j = 0; |
1381 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 1390 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
1382 | if (xpmBuf[i].latin1() != '"') { | 1391 | if (xpmBuf[i].latin1() != '"') { |
1383 | 1392 | ||
1384 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 1393 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
1385 | j++; | 1394 | j++; |
1386 | } | 1395 | } |
1387 | 1396 | ||
1388 | } | 1397 | } |
1389 | // have to close that facker up | 1398 | // have to close that facker up |
1390 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 1399 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
1391 | 1400 | ||
1392 | xpmLineCount++; | 1401 | xpmLineCount++; |
1393 | buf = t.readLine(); | 1402 | buf = t.readLine(); |
1394 | } | 1403 | } |
1395 | if (xpmLineCount) { | 1404 | if (xpmLineCount) { |
1396 | 1405 | ||
1397 | xpm2pix = new QImage((const char **)xpm); | 1406 | xpm2pix = new QImage((const char **)xpm); |
1398 | for (int i = 0; i < xpmLineCount; i++) | 1407 | for (int i = 0; i < xpmLineCount; i++) |
1399 | 1408 | ||
1400 | delete [] (xpm[i]); | 1409 | delete [] (xpm[i]); |
1401 | 1410 | ||
1402 | } | 1411 | } |
1403 | setKey(row, qcode, unicode, width, xpm2pix); | 1412 | setKey(row, qcode, unicode, width, xpm2pix); |
1404 | } | 1413 | } |
1405 | 1414 | ||
1406 | // shift map | 1415 | // shift map |
1407 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1416 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1408 | 1417 | ||
1409 | QTextStream tmp (buf, IO_ReadOnly); | 1418 | QTextStream tmp (buf, IO_ReadOnly); |
1410 | ushort lower, shift; | 1419 | ushort lower, shift; |
1411 | tmp >> lower >> shift; | 1420 | tmp >> lower >> shift; |
1412 | 1421 | ||
1413 | shiftMap.insert(lower, shift); | 1422 | shiftMap.insert(lower, shift); |
1414 | 1423 | ||
1415 | buf = t.readLine(); | 1424 | buf = t.readLine(); |
1416 | } | 1425 | } |
1417 | 1426 | ||
1418 | // meta key map | 1427 | // meta key map |
1419 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1428 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1420 | 1429 | ||
1421 | QTextStream tmp (buf, IO_ReadOnly); | 1430 | QTextStream tmp (buf, IO_ReadOnly); |
1422 | ushort lower, shift; | 1431 | ushort lower, shift; |
1423 | QChar m; | 1432 | QChar m; |
1424 | tmp >> m >> lower >> shift; | 1433 | tmp >> m >> lower >> shift; |
1425 | 1434 | ||
1426 | metaMap.insert(lower, shift); | 1435 | metaMap.insert(lower, shift); |
1427 | 1436 | ||
1428 | buf = t.readLine(); | 1437 | buf = t.readLine(); |
1429 | } | 1438 | } |
1430 | 1439 | ||
1431 | // circumflex | 1440 | // circumflex |
1432 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1441 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1433 | 1442 | ||
1434 | QTextStream tmp (buf, IO_ReadOnly); | 1443 | QTextStream tmp (buf, IO_ReadOnly); |
1435 | ushort lower, shift; | 1444 | ushort lower, shift; |
1436 | QChar c; | 1445 | QChar c; |
1437 | tmp >> c >> lower >> shift; | 1446 | tmp >> c >> lower >> shift; |
1438 | 1447 | ||
1439 | circumflexMap.insert(lower, shift); | 1448 | circumflexMap.insert(lower, shift); |
1440 | 1449 | ||
1441 | buf = t.readLine(); | 1450 | buf = t.readLine(); |
1442 | } | 1451 | } |
1443 | // diaeresis | 1452 | // diaeresis |
1444 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1453 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1445 | 1454 | ||
1446 | QTextStream tmp (buf, IO_ReadOnly); | 1455 | QTextStream tmp (buf, IO_ReadOnly); |
1447 | ushort lower, shift; | 1456 | ushort lower, shift; |
1448 | QChar d; | 1457 | QChar d; |
1449 | tmp >> d >> lower >> shift; | 1458 | tmp >> d >> lower >> shift; |
1450 | 1459 | ||
1451 | diaeresisMap.insert(lower, shift); | 1460 | diaeresisMap.insert(lower, shift); |
1452 | 1461 | ||
1453 | buf = t.readLine(); | 1462 | buf = t.readLine(); |
1454 | } | 1463 | } |
1455 | // back accent | 1464 | // back accent |
1456 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1465 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1457 | 1466 | ||
1458 | QTextStream tmp (buf, IO_ReadOnly); | 1467 | QTextStream tmp (buf, IO_ReadOnly); |
1459 | ushort lower, shift; | 1468 | ushort lower, shift; |
1460 | QChar d; | 1469 | QChar d; |
1461 | tmp >> d >> lower >> shift; | 1470 | tmp >> d >> lower >> shift; |
1462 | 1471 | ||
1463 | baccentMap.insert(lower, shift); | 1472 | baccentMap.insert(lower, shift); |
1464 | 1473 | ||
1465 | qDebug ("Estoy aadiendo %i con %i", lower, shift); | 1474 | qDebug ("Estoy aadiendo %i con %i", lower, shift); |
1466 | buf = t.readLine(); | 1475 | buf = t.readLine(); |
1467 | } | 1476 | } |
1468 | // accent | 1477 | // accent |
1469 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1478 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1470 | 1479 | ||
1471 | QTextStream tmp (buf, IO_ReadOnly); | 1480 | QTextStream tmp (buf, IO_ReadOnly); |
1472 | ushort lower, shift; | 1481 | ushort lower, shift; |
1473 | QChar d; | 1482 | QChar d; |
1474 | tmp >> d >> lower >> shift; | 1483 | tmp >> d >> lower >> shift; |
1475 | 1484 | ||
1476 | accentMap.insert(lower, shift); | 1485 | accentMap.insert(lower, shift); |
1477 | 1486 | ||
1478 | buf = t.readLine(); | 1487 | buf = t.readLine(); |
1479 | } | 1488 | } |
1480 | 1489 | ||
1481 | // other variables like lang & title | 1490 | // other variables like lang & title |
1482 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 1491 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
1483 | 1492 | ||
1484 | QTextStream tmp (buf, IO_ReadOnly); | 1493 | QTextStream tmp (buf, IO_ReadOnly); |
1485 | QString name, equals, value; | 1494 | QString name, equals, value; |
1486 | 1495 | ||
1487 | tmp >> name >> equals >> value; | 1496 | tmp >> name >> equals >> value; |
1488 | 1497 | ||
1489 | if (name == "lang") { | 1498 | if (name == "lang") { |
1490 | 1499 | ||
1491 | lang = value; | 1500 | lang = value; |
1492 | 1501 | ||
1493 | } | 1502 | } |
1494 | 1503 | ||
1495 | buf = t.readLine(); | 1504 | buf = t.readLine(); |
1496 | } | 1505 | } |
1497 | // comments | 1506 | // comments |
1498 | else if (buf.contains(QRegExp("^\\s*#"))) { | 1507 | else if (buf.contains(QRegExp("^\\s*#"))) { |
1499 | 1508 | ||
1500 | buf = t.readLine(); | 1509 | buf = t.readLine(); |
1501 | 1510 | ||
1502 | } else { // blank line, or garbage | 1511 | } else { // blank line, or garbage |
1503 | 1512 | ||
1504 | buf = t.readLine(); | 1513 | buf = t.readLine(); |
1505 | 1514 | ||
1506 | } | 1515 | } |
1507 | 1516 | ||
1508 | } | 1517 | } |
1509 | f.close(); | 1518 | f.close(); |
1510 | } | 1519 | } |
1511 | 1520 | ||
1512 | } | 1521 | } |
1513 | 1522 | ||
1514 | // Keys::setKey {{{2 | 1523 | // Keys::setKey {{{2 |
1515 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 1524 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
1516 | const int width, QImage *pix) { | 1525 | const int width, QImage *pix) { |
1517 | 1526 | ||
1518 | Key * key; | 1527 | Key * key; |
1519 | key = new Key; | 1528 | key = new Key; |
1520 | key->qcode = qcode; | 1529 | key->qcode = qcode; |
1521 | key->unicode = unicode; | 1530 | key->unicode = unicode; |
1522 | key->width = width; | 1531 | key->width = width; |
1523 | 1532 | ||
1524 | // share key->pressed between same keys | 1533 | // share key->pressed between same keys |
1525 | bool found = 0; | 1534 | bool found = 0; |
1526 | for (int i = 1; i <= 5; i++) { | 1535 | for (int i = 1; i <= 5; i++) { |
1527 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1536 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1528 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1537 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
1529 | 1538 | ||
1530 | key->pressed = keys[i].at(j)->pressed; | 1539 | key->pressed = keys[i].at(j)->pressed; |
1531 | found = 1; | 1540 | found = 1; |
1532 | } | 1541 | } |
1533 | 1542 | ||
1534 | } | 1543 | } |
1535 | if (!found) { | 1544 | if (!found) { |
1536 | 1545 | ||
1537 | key->pressed = new bool; | 1546 | key->pressed = new bool; |
1538 | *(key->pressed) = 0; | 1547 | *(key->pressed) = 0; |
1539 | } | 1548 | } |
1540 | 1549 | ||
1541 | key->pix = pix; | 1550 | key->pix = pix; |
1542 | 1551 | ||
1543 | 1552 | ||
1544 | keys[row].append(key); | 1553 | keys[row].append(key); |
1545 | } | 1554 | } |
1546 | 1555 | ||
1547 | // Keys::~Keys {{{2 | 1556 | // Keys::~Keys {{{2 |
1548 | Keys::~Keys() { | 1557 | Keys::~Keys() { |
1549 | 1558 | ||
1550 | for (int i = 1; i <= 5; i++) | 1559 | for (int i = 1; i <= 5; i++) |
1551 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1560 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1552 | delete keys[i].at(j); | 1561 | delete keys[i].at(j); |
1553 | 1562 | ||
1554 | } | 1563 | } |
1555 | 1564 | ||
1556 | // Keys:: other functions {{{2 | 1565 | // Keys:: other functions {{{2 |
1557 | int Keys::width(const int row, const int col) { | 1566 | int Keys::width(const int row, const int col) { |
1558 | 1567 | ||
1559 | return keys[row].at(col)->width; | 1568 | return keys[row].at(col)->width; |
1560 | 1569 | ||
1561 | } | 1570 | } |
1562 | 1571 | ||
1563 | int Keys::rows() { | 1572 | int Keys::rows() { |
1564 | 1573 | ||
1565 | for (int i = 1; i <= 5; i++) { | 1574 | for (int i = 1; i <= 5; i++) { |
1566 | 1575 | ||
1567 | if (keys[i].count() == 0) | 1576 | if (keys[i].count() == 0) |
1568 | return i - 1; | 1577 | return i - 1; |
1569 | 1578 | ||
1570 | } | 1579 | } |
1571 | return 5; | 1580 | return 5; |
1572 | } | 1581 | } |
1573 | 1582 | ||
1574 | ushort Keys::uni(const int row, const int col) { | 1583 | ushort Keys::uni(const int row, const int col) { |
1575 | 1584 | ||
1576 | return keys[row].at(col)->unicode; | 1585 | return keys[row].at(col)->unicode; |
1577 | 1586 | ||
1578 | } | 1587 | } |
1579 | 1588 | ||
1580 | int Keys::qcode(const int row, const int col) { | 1589 | int Keys::qcode(const int row, const int col) { |
1581 | 1590 | ||
1582 | return keys[row].at(col)->qcode; | 1591 | return keys[row].at(col)->qcode; |
1583 | } | 1592 | } |
1584 | 1593 | ||
1585 | QImage *Keys::pix(const int row, const int col) { | 1594 | QImage *Keys::pix(const int row, const int col) { |
1586 | 1595 | ||
1587 | return keys[row].at(col)->pix; | 1596 | return keys[row].at(col)->pix; |
1588 | 1597 | ||
1589 | } | 1598 | } |
1590 | bool Keys::pressed(const int row, const int col) { | 1599 | bool Keys::pressed(const int row, const int col) { |
1591 | 1600 | ||
1592 | return *(keys[row].at(col)->pressed); | 1601 | return *(keys[row].at(col)->pressed); |
1593 | } | 1602 | } |
1594 | 1603 | ||
1595 | int Keys::numKeys(const int row) { | 1604 | int Keys::numKeys(const int row) { |
1596 | 1605 | ||
1597 | return keys[row].count(); | 1606 | return keys[row].count(); |
1598 | } | 1607 | } |
1599 | 1608 | ||
1600 | void Keys::setPressed(const int row, const int col, const bool pressed) { | 1609 | void Keys::setPressed(const int row, const int col, const bool pressed) { |
1601 | 1610 | ||
1602 | *(keys[row].at(col)->pressed) = pressed; | 1611 | *(keys[row].at(col)->pressed) = pressed; |
1603 | } | 1612 | } |
1604 | 1613 | ||
1605 | ushort Keys::shift(const ushort uni) { | 1614 | ushort Keys::shift(const ushort uni) { |
1606 | 1615 | ||
1607 | if (shiftMap[uni]) return shiftMap[uni]; | 1616 | if (shiftMap[uni]) return shiftMap[uni]; |
1608 | else return 0; | 1617 | else return 0; |
1609 | } | 1618 | } |
1610 | 1619 | ||
1611 | ushort Keys::meta(const ushort uni) { | 1620 | ushort Keys::meta(const ushort uni) { |
1612 | 1621 | ||
1613 | if (metaMap[uni]) return metaMap[uni]; | 1622 | if (metaMap[uni]) return metaMap[uni]; |
1614 | else return 0; | 1623 | else return 0; |
1615 | } | 1624 | } |
1616 | 1625 | ||
1617 | ushort Keys::circumflex(const ushort uni) { | 1626 | ushort Keys::circumflex(const ushort uni) { |
1618 | 1627 | ||
1619 | if (circumflexMap[uni]) return circumflexMap[uni]; | 1628 | if (circumflexMap[uni]) return circumflexMap[uni]; |
1620 | else return 0; | 1629 | else return 0; |
1621 | } | 1630 | } |
1622 | 1631 | ||
1623 | ushort Keys::diaeresis(const ushort uni) { | 1632 | ushort Keys::diaeresis(const ushort uni) { |
1624 | 1633 | ||
1625 | if(diaeresisMap[uni]) return diaeresisMap[uni]; | 1634 | if(diaeresisMap[uni]) return diaeresisMap[uni]; |
1626 | else return 0; | 1635 | else return 0; |
1627 | } | 1636 | } |
1628 | 1637 | ||
1629 | ushort Keys::baccent(const ushort uni) { | 1638 | ushort Keys::baccent(const ushort uni) { |
1630 | 1639 | ||
1631 | if(baccentMap[uni]) return baccentMap[uni]; | 1640 | if(baccentMap[uni]) return baccentMap[uni]; |
1632 | else return 0; | 1641 | else return 0; |
1633 | } | 1642 | } |
1634 | 1643 | ||
1635 | ushort Keys::accent(const ushort uni) { | 1644 | ushort Keys::accent(const ushort uni) { |
1636 | 1645 | ||
1637 | if(accentMap[uni]) return accentMap[uni]; | 1646 | if(accentMap[uni]) return accentMap[uni]; |
1638 | else return 0; | 1647 | else return 0; |
1639 | } | 1648 | } |
1640 | 1649 | ||
1641 | bool *Keys::pressedPtr(const int row, const int col) { | 1650 | bool *Keys::pressedPtr(const int row, const int col) { |
1642 | 1651 | ||
1643 | return keys[row].at(col)->pressed; | 1652 | return keys[row].at(col)->pressed; |
1644 | } | 1653 | } |