Fix ShortcutOverrid for Qt Quick

The tryShortcutOverride function needs to be called with the
focus object. The same logic is in QGuiApplication::notify.
Applications with QGuiApplication would therefore handle
ShortcutOverride correctly where QApplication would not allow the
override.

ChangeLog: Fixed ShortcutOverrid for QtQuickControls.
Now it is possible to assign a shortcut such as "b" and still type "b" in text inputs.

Task-number: QTBUG-32928

Change-Id: I4f4ab82fd11f45174a4483a01bbbe8143dfe0724
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
bb10
Frederik Gladhorn 2013-08-12 20:25:42 +02:00 committed by The Qt Project
parent 0819c48e1b
commit 0e3ede3d17
1 changed files with 8 additions and 1 deletions

View File

@ -2858,7 +2858,14 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QKeyEvent* key = static_cast<QKeyEvent*>(e);
#ifndef QT_NO_SHORTCUT
// Try looking for a Shortcut before sending key events
if (qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key))
QObject *shortcutReceiver = receiver;
if (!isWidget && isWindow) {
QWindow *w = qobject_cast<QWindow *>(receiver);
QObject *focus = w ? w->focusObject() : 0;
if (focus)
shortcutReceiver = focus;
}
if (qApp->d_func()->shortcutMap.tryShortcutEvent(shortcutReceiver, key))
return true;
#endif
qt_in_tab_key_event = (key->key() == Qt::Key_Backtab