Changeset 179 for trunk/src


Ignore:
Timestamp:
Sep 12, 2009, 2:10:36 AM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: Implemented support for entering dead keys from the keyboard (#68).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qkeymapper_pm.cpp

    r169 r179  
    197197};
    198198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
    199229// Key translation ---------------------------------------------------[ end ]---
    200230
     
    241271}
    242272
    243 static inline int asciiToKeycode(char a, int state)
    244 {
    245     if (a >= 'a' && a <= 'z')
    246         a = toupper(a);
    247     if ((state & Qt::ControlModifier) != 0) {
    248         if (a >= 0 && a <= 31)              // [email protected]+A..CTRL+Z..Ctrl+_
    249             a += '@';                       // to @..A..Z.._
    250     }
    251     return a & 0xff;
     273static inline int charToKeycode(const QChar &ch, int state)
     274{
     275    if (!ch.row()) {
     276        if ((state & Qt::ControlModifier) != 0) {
     277            int ascii = ch.cell();
     278            if (ascii >= 0 && ascii <= 31)  // [email protected]+A..CTRL+Z..Ctrl+_
     279                return ascii + '@';         // to @..A..Z.._
     280        }
     281    }
     282
     283    return ch.toUpper().unicode();
    252284}
    253285
     
    383415            QString text;
    384416            if (chm.chr) {
    385                 // Note: We ignore the KC_CHAR flag when generating text for the
    386                 // key in order to get correct (non-null) text even for Alt+Letter
    387                 // combinations (that don't have KC_CHAR set) because processing
    388                 // Alt+Letter shortcuts for non-ASCII letters in widgets (e.g.
    389                 // QPushButton) depends on that.
     417                // Note: We ignore the KC_CHAR flag when
     418                //
     419                //
     420                //
     421                // QPushButton) depends on that.
    390422                if ((chm.fs & (KC_VIRTUALKEY | KC_CHAR)) == KC_CHAR && (chm.chr & 0xFF00)) {
    391                     // We assime we get a DBCS char if the above condition is met.
     423                    // We assme we get a DBCS char if the above condition is met.
    392424                    // DBCS chars seem to have KC_CHAR set but not KC_VIRTUALKEY; we
    393425                    // use this to prevent keys like ESC (chm=0x011B) with the
     
    396428                } else if (chm.chr & 0xFF) {
    397429                    text = QString::fromLocal8Bit((char*)&chm.chr, 1);
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
    398445                }
    399446
    400447                Q_ASSERT(code || !text.isEmpty()); // we must provide the key code
    401448                if (!code && !text.isEmpty()) {
    402                     if (!text[0].row())
    403                         code = asciiToKeycode(text[0].cell(), state);
    404                     else
    405                         code = text[0].toUpper().unicode();
     449                    code = charToKeycode(text[0], state);
    406450                }
    407451            }
Note: See TracChangeset for help on using the changeset viewer.