diff -Naur qt-orig/src/gui/kernel/qkeymapper_x11.cpp qt/src/gui/kernel/qkeymapper_x11.cpp --- qt-orig/src/gui/kernel/qkeymapper_x11.cpp 2010-07-01 07:13:35 +0400 +++ qt/src/gui/kernel/qkeymapper_x11.cpp 2010-07-01 07:19:35 +0400 @@ -290,6 +290,7 @@ return QList(); QList result; + QList codes; // translate sym -> code Qt::KeyboardModifiers baseModifiers = 0; @@ -306,6 +307,7 @@ if (baseCode && baseCode < 0xfffe) baseCode = QChar(baseCode).toUpper().unicode(); result += (baseCode | baseModifiers); + codes += baseCode; int pos1Bits[MaxBits]; int num1Bits = 0; @@ -355,11 +357,41 @@ text = QString(); } - if (code == baseCode) + if (codes.contains(code)) + continue; + + result += (code | modifiers); + codes += code; + } + + XkbDescRec *xkb = XkbGetMap(X11->display, XkbKeySymsMask|XkbKeyTypesMask, XkbUseCoreKbd); + KeySym *entry = XkbKeySymsPtr(xkb, xkeycode); + int total_syms = XkbKeyNumSyms (xkb, xkeycode); + int i = 0; + + for (i=0; i < total_syms; i++) { + // translate sym -> code + Qt::KeyboardModifiers modifiers = 0; + int code = -1; + chars.clear(); + count = 0; + // mask out the modifiers needed to translate keycode + text = translateKeySym(entry[i], xmodifiers, code, modifiers, chars, count); + if (code == -1) { + if (text.isEmpty()) + continue; + code = text.at(0).unicode(); + } + + if (code && code < 0xfffe) + code = QChar(code).toUpper().unicode(); + if (codes.contains(code) || !QChar(code).isLetter()) continue; result += (code | modifiers); + codes += code; } + XkbFreeKeyboard(xkb, XkbAllComponentsMask, True); #if 0 qDebug() << "possibleKeysXKB()" << hex << result; diff -Naur qt-orig/src/gui/widgets/qmenubar.cpp qt/src/gui/widgets/qmenubar.cpp --- qt-orig/src/gui/widgets/qmenubar.cpp 2010-05-22 18:12:50 +0400 +++ qt/src/gui/widgets/qmenubar.cpp 2010-07-01 07:19:35 +0400 @@ -522,6 +522,8 @@ // emit q->highlighted(action); } +#include + void QMenuBarPrivate::_q_actionTriggered() { @@ -1201,6 +1203,10 @@ QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; { QChar c = e->text()[0].toUpper(); + QList possibleKeys = qt_keymapper_private()->possibleKeys(e); + if(!possibleKeys.contains(c.unicode())) + possibleKeys += c.unicode(); + for(int i = 0; i < d->actions.size(); ++i) { if (d->actionRects.at(i).isNull()) continue; @@ -1209,14 +1215,20 @@ if(!s.isEmpty()) { int ampersand = s.indexOf(QLatin1Char('&')); if(ampersand >= 0) { - if(s[ampersand+1].toUpper() == c) { - clashCount++; - if(!first) - first = act; - if(act == d->currentAction) - currentSelected = act; - else if (!firstAfterCurrent && currentSelected) - firstAfterCurrent = act; + QListIterator k(possibleKeys); + while (k.hasNext()) { + int key_e = k.next(); + + if(s[ampersand+1].toUpper().unicode() == key_e) { + clashCount++; + if(!first) + first = act; + if(act == d->currentAction) + currentSelected = act; + else if (!firstAfterCurrent && currentSelected) + firstAfterCurrent = act; + break; + } } } } diff -Naur qt-orig/src/gui/widgets/qmenu.cpp qt/src/gui/widgets/qmenu.cpp --- qt-orig/src/gui/widgets/qmenu.cpp 2010-07-01 07:13:35 +0400 +++ qt/src/gui/widgets/qmenu.cpp 2010-07-01 07:19:35 +0400 @@ -82,6 +82,7 @@ # include #endif +#include QT_BEGIN_NAMESPACE @@ -2719,20 +2720,31 @@ int clashCount = 0; QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0; QChar c = e->text().at(0).toUpper(); + + QList possibleKeys = qt_keymapper_private()->possibleKeys(e); + if(!possibleKeys.contains(c.unicode())) + possibleKeys += c.unicode(); + for(int i = 0; i < d->actions.size(); ++i) { if (d->actionRects.at(i).isNull()) continue; QAction *act = d->actions.at(i); QKeySequence sequence = QKeySequence::mnemonic(act->text()); int key = sequence[0] & 0xffff; - if (key == c.unicode()) { - clashCount++; - if (!first) - first = act; - if (act == d->currentAction) - currentSelected = act; - else if (!firstAfterCurrent && currentSelected) - firstAfterCurrent = act; + + QListIterator k(possibleKeys); + while (k.hasNext()) { + int key_e = k.next(); + if (key == key_e) { + clashCount++; + if (!first) + first = act; + if (act == d->currentAction) + currentSelected = act; + else if (!firstAfterCurrent && currentSelected) + firstAfterCurrent = act; + break; + } } } if (clashCount == 1)