diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2011-10-13 09:47:23 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-21 15:53:16 +0100 |
commit | 479f3c6b1124bc830ee60e764ea50d14db526f7e (patch) | |
tree | b25ee7f28b66759a7512c35a7868fa1f7e36563e /src/gui | |
parent | 6e7f08182ea9a6e0e4f89c6b13ff8dcae1d3b87c (diff) |
Pass all key events through the shortcutmap
This has to happen in QGuiApp, not QApp.
Change-Id: If8a6e81df3ae9b601733d077cce57d2d21572f74
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 28 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication_p.h | 4 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 8f74e3d3db..1101764512 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -512,6 +512,18 @@ int QGuiApplication::exec() bool QGuiApplication::notify(QObject *object, QEvent *event) { +#ifndef QT_NO_SHORTCUT + if (event->type() == QEvent::KeyPress) { + // Try looking for a Shortcut before sending key events + QWindow *w = qobject_cast<QWindow *>(object); + QObject *focus = w ? w->focusObject() : 0; + if (!focus) + focus = object; + if (QGuiApplicationPrivate::instance()->shortcutMap.tryShortcutEvent(focus, static_cast<QKeyEvent *>(event))) + return true; + } +#endif + return QCoreApplication::notify(object, event); } @@ -700,18 +712,10 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE if (!window) return; - QObject *target = window; - - if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) { - QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount, - e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers); - ev.setTimestamp(e->timestamp); - QGuiApplication::sendSpontaneousEvent(target, &ev); - } else { - QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount); - ev.setTimestamp(e->timestamp); - QGuiApplication::sendSpontaneousEvent(target, &ev); - } + QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount, + e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers); + ev.setTimestamp(e->timestamp); + QGuiApplication::sendSpontaneousEvent(window, &ev); } void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index af1c71d478..255a1587f5 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -53,6 +53,7 @@ #include "private/qwindowsysteminterface_qpa_p.h" #include <QtGui/qplatformintegration_qpa.h> #include <QtGui/qplatformtheme_qpa.h> +#include "private/qshortcutmap_p.h" QT_BEGIN_HEADER @@ -183,6 +184,9 @@ public: static bool quitOnLastWindowClosed; static QList<QObject *> generic_plugin_list; +#ifndef QT_NO_SHORTCUT + QShortcutMap shortcutMap; +#endif private: void init(); |