diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-04-20 21:22:53 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-04-20 21:22:53 +0200 |
commit | 6f45fda50b6dbb0704a71a15f38d44027b4b1816 (patch) | |
tree | 6a1c511cf233f1723c2b1758647f06c3bdaca7fb /src/widgets/kernel | |
parent | 7ee44dcb9c5c4ffaba0043d7d58e0d43ccc06195 (diff) | |
parent | ab6cc41968ec6eedd16e4305cf38ef937b2a8d56 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: I0bea38585382b5d9c8d7a013bf6bcb3a6008d159
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 16 | ||||
-rw-r--r-- | src/widgets/kernel/qshortcut.cpp | 9 | ||||
-rw-r--r-- | src/widgets/kernel/qtooltip.cpp | 12 |
3 files changed, 27 insertions, 10 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 8e9ce286de..122d94d152 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -130,6 +130,7 @@ QT_BEGIN_NAMESPACE } Q_CORE_EXPORT void qt_call_post_routines(); +Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1); QApplicationPrivate *QApplicationPrivate::self = 0; @@ -3075,8 +3076,19 @@ bool QApplication::notify(QObject *receiver, QEvent *e) switch (e->type()) { case QEvent::KeyPress: { - int key = static_cast<QKeyEvent*>(e)->key(); - qt_in_tab_key_event = (key == Qt::Key_Backtab + QKeyEvent* keyEvent = static_cast<QKeyEvent*>(e); + const int key = keyEvent->key(); + // When a key press is received which is not spontaneous then it needs to + // be manually sent as a shortcut override event to ensure that any + // matching shortcut is triggered first. This enables emulation/playback + // of recorded events to still have the same effect. + if (!e->spontaneous() && receiver->isWidgetType()) { + if (qt_sendShortcutOverrideEvent(qobject_cast<QWidget *>(receiver), keyEvent->timestamp(), + key, keyEvent->modifiers(), keyEvent->text(), + keyEvent->isAutoRepeat(), keyEvent->count())) + return true; + } + qt_in_tab_key_event = (key == Qt::Key_Backtab || key == Qt::Key_Tab || key == Qt::Key_Left || key == Qt::Key_Up diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index 32600d4152..fde039c75e 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -187,8 +187,15 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge active_window = active_window->parentWidget()->window(); } - if (active_window != tlw) + if (active_window != tlw) { +#if QT_CONFIG(menubar) + // If the tlw is a QMenuBar then we allow it to proceed as this indicates that + // the QMenuBar is a parentless one and is therefore used for multiple top level + // windows in the application. This is common on macOS platforms for example. + if (!qobject_cast<QMenuBar *>(tlw)) +#endif return false; + } /* if we live in a MDI subwindow, ignore the event if we are not the active document window */ diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index a53b87bd39..e9a682fabf 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -327,15 +327,13 @@ void QTipLabel::timerEvent(QTimerEvent *e) bool QTipLabel::eventFilter(QObject *o, QEvent *e) { switch (e->type()) { -#if 0 // Used to be included in Qt4 for Q_WS_MAC +#ifdef Q_OS_MACOS case QEvent::KeyPress: case QEvent::KeyRelease: { - int key = static_cast<QKeyEvent *>(e)->key(); - Qt::KeyboardModifiers mody = static_cast<QKeyEvent *>(e)->modifiers(); - if (!(mody & Qt::KeyboardModifierMask) - && key != Qt::Key_Shift && key != Qt::Key_Control - && key != Qt::Key_Alt && key != Qt::Key_Meta) - hideTip(); + const int key = static_cast<QKeyEvent *>(e)->key(); + // Anything except key modifiers or caps-lock, etc. + if (key < Qt::Key_Shift || key > Qt::Key_ScrollLock) + hideTipImmediately(); break; } #endif |