qt5base-lts/tests/auto/widgets/kernel
Tor Arne Vestbø cd4000a97d Use QtGui to match QWindow based shortcuts, even when QApplication is used
If a QShortcut is registered with a QWindow as its parent, but QApplication
is used, we end up in QApplicationPrivate::createShortcutPrivate(), and
create a QtWidgetsShortcutPrivate that implements shortcut context matching
via qWidgetShortcutContextMatcher.

The problem is that qWidgetShortcutContextMatcher expects the windows
to be QWidgetWindows, which meant that plain QWindow based shortcuts
would always fail.

This can happen for example if a QApplication is used in Qt Quick
to provide dialog fallbacks, but QShortcuts are otherwise used
with plain QWindows, or QQuickWindows e.g.

We now defer the check of whether there's an active (widget) window,
and fall back to QtGui's simpleContextMatcher in case we don't find
a QWidget, QAction, or QGraphicsWidget shortcut owner to handle
the matching for.

Note: We don't support shortcut matching for QAction in QtGui,
but this is left for another day. There is also a discrepancy
between how QtGui and QtWidgets handles Qt::ApplicationShortcut.
The former will treat it as a match even if there is no active
QWindow, while the latter requires that there's an active widget
window.

Fixes: QTBUG-116221
Change-Id: I487995f2e660a40f6556828b84a521d81a58f1b6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-11 20:32:05 +02:00
..
qaction CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qactiongroup CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qapplication Add QEXPECT_FAIL to tst_QApplication::sendEventsOnProcessEvents 2023-08-10 16:42:51 +03:00
qboxlayout CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qformlayout CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qgesturerecognizer tst_QGestureRecognizer: port away from Q_FOREACH 2023-08-07 23:56:10 +02:00
qgridlayout QtWidgets tests: port remaining users away from Q_FOREACH 2023-08-14 23:11:54 +03:00
qlayout CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qshortcut Use QtGui to match QWindow based shortcuts, even when QApplication is used 2023-10-11 20:32:05 +02:00
qsizepolicy CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qstackedlayout CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qtooltip QtWidgets tests: port remaining users away from Q_FOREACH 2023-08-14 23:11:54 +03:00
qwidget tests: blacklist tst_QWidget::render() on Wayland 2023-08-03 07:23:37 +02:00
qwidget_window CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qwidgetaction CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qwidgetmetatype CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qwidgetrepaintmanager CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qwidgetsvariant CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
qwindowcontainer CMake: Make widgets tests standalone projects 2023-07-05 15:09:32 +02:00
CMakeLists.txt tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00