diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-25 23:25:34 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-06-25 23:25:35 +0200 |
commit | 1867ad741abd8ea96feac3943edbb0848ae094cd (patch) | |
tree | 0d9dc665facdd7bbde10a7d58b8b311bdd676477 /src/widgets/kernel | |
parent | 851fae6dbe08785ebb8be3732c40fbe1a5a280a0 (diff) | |
parent | 3ffc86e0e6d327d71782cbf84f1d62d4ad484bb0 (diff) |
Merge remote-tracking branch 'origin/release' into stable
Change-Id: I4c0ae2ac1c10d4d50c03625c802d981b7850ed6f
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 49 | ||||
-rw-r--r-- | src/widgets/kernel/qshortcut.cpp | 27 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 2 |
3 files changed, 59 insertions, 19 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 080f4358f2..61f3b6b8eb 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2842,6 +2842,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); @@ -2855,25 +2886,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; diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index c19b617091..18dd3156c6 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -446,7 +446,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) if (!widget) widget = m_widget; - if (event->type() == QEvent::MouseButtonPress && !qt_button_down) + if (event->type() == QEvent::MouseButtonPress) qt_button_down = widget; QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(), |