summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJørgen Lind <jorgen.lind@digia.com>2013-06-20 09:53:22 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-21 09:26:45 +0200
commit531b7d303e96c8fbc54aad0775b99e04599f8642 (patch)
tree283ba0d3c750cdf0f46b261be7f966497221689b
parentad43d9a09779cf57410d0ae68513a8dc59187183 (diff)
downloadqtbase-531b7d303e96c8fbc54aad0775b99e04599f8642.tar.gz
Fix missing shortcuts for WindowContainers
Change-Id: Iee2d97e1ff2b1f0c56b1dde4f3ce22a427fbe554 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
-rw-r--r--src/widgets/kernel/qapplication.cpp49
-rw-r--r--src/widgets/kernel/qshortcut.cpp27
2 files changed, 58 insertions, 18 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index edd7cafd83..0da9460794 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2840,6 +2840,37 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
break;
}
+ switch (e->type()) {
+ case QEvent::KeyPress:
+ {
+ bool isWidget = receiver->isWidgetType();
+ bool isWindow = receiver->isWindowType();
+ bool isGraphicsWidget = false;
+#ifndef QT_NO_GRAPHICSVIEW
+ isGraphicsWidget = !isWidget && !isWindow && qobject_cast<QGraphicsWidget *>(receiver);
+#endif
+ if (!isWidget && !isGraphicsWidget && !isWindow) {
+ return d->notify_helper(receiver, 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))
+ return true;
+#endif
+ qt_in_tab_key_event = (key->key() == Qt::Key_Backtab
+ || key->key() == Qt::Key_Tab
+ || key->key() == Qt::Key_Left
+ || key->key() == Qt::Key_Up
+ || key->key() == Qt::Key_Right
+ || key->key() == Qt::Key_Down);
+
+ }
+ default:
+ break;
+ }
+
bool res = false;
if (!receiver->isWidgetType()) {
res = d->notify_helper(receiver, e);
@@ -2853,25 +2884,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
#ifndef QT_NO_GRAPHICSVIEW
isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver);
#endif
- if (!isWidget && !isGraphicsWidget) {
- res = d->notify_helper(receiver, e);
- break;
- }
-
QKeyEvent* key = static_cast<QKeyEvent*>(e);
- if (key->type()==QEvent::KeyPress) {
-#ifndef QT_NO_SHORTCUT
- // Try looking for a Shortcut before sending key events
- if ((res = qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key)))
- return res;
-#endif
- qt_in_tab_key_event = (key->key() == Qt::Key_Backtab
- || key->key() == Qt::Key_Tab
- || key->key() == Qt::Key_Left
- || key->key() == Qt::Key_Up
- || key->key() == Qt::Key_Right
- || key->key() == Qt::Key_Down);
- }
bool def = key->isAccepted();
QPointer<QObject> pr = receiver;
while (receiver) {
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index c5cdce3d60..471b054a99 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -51,6 +51,7 @@
#include <private/qapplication_p.h>
#include <private/qshortcutmap_p.h>
#include <private/qaction_p.h>
+#include <private/qwidgetwindow_qpa_p.h>
QT_BEGIN_NAMESPACE
@@ -86,6 +87,20 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
if (QApplication::activePopupWidget())
active_window = QApplication::activePopupWidget();
+ if (!active_window) {
+ QWindow *qwindow = QGuiApplication::focusWindow();
+ if (qwindow && qwindow->isActive()) {
+ while (qwindow) {
+ QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(qwindow);
+ if (widgetWindow) {
+ active_window = widgetWindow->widget();
+ break;
+ }
+ qwindow = qwindow->parent();
+ }
+ }
+ }
+
if (!active_window)
return false;
@@ -106,6 +121,18 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
w = s->parentWidget();
}
+ if (!w) {
+ QWindow *qwindow = qobject_cast<QWindow *>(object);
+ while (qwindow) {
+ QWidgetWindow *widget_window = qobject_cast<QWidgetWindow *>(qwindow);
+ if (widget_window) {
+ w = widget_window->widget();
+ break;
+ }
+ qwindow = qwindow->parent();
+ }
+ }
+
if (!w)
return false;