summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestkeyboard.h
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-09-04 17:56:20 +0200
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-10-07 13:24:45 +0000
commitc7e5e1d9e01849347a9e59b8285477a20d82002b (patch)
tree3e53068d1b421f935905cb4b60b29ed94cd0457a /src/testlib/qtestkeyboard.h
parent590c73bee2083c8dc8635123726e138a26dd3a97 (diff)
Move shortcut handling back into QPA and simplify delivery
Commit 7f5b94b47 moved shortcut handling into QGuiApplication (for all platforms except OS X), due to crashes on Android where the events are delivered from another thread. Now that we have synchronous event delivery (also across threads) from QPA, this is no longer needed, and we can move the code back to QPA, where the platform has more control over when and how shortcut events are delivered in relation to normal key events. Handling shortcuts is as before a two step process. We first send a QKeyEvent::ShortcutOverride event to the active window, which allows clients (widgets e.g.) to signal that they want to handle the shortcut themselves. If the override event is accepted, we treat it as the shortcut not being handled as a regular shortcut, and send the event as a key press instead, allowing the widget to handle the shortcut. If nothing accepted the shortcut override event we pass it along to the global shortcut map, which will treat the event as handled if an exact or partial match is found. The QShortcutMap::tryShortcutEvent() and nextState() implementation has been simplified to not use the events accepted state for its internal operation, which removes the need for saving the state of the incoming event. The QKeyEvent::ShortcutOverride event was also always sent with the accepted state set to false, by calling ignore() on it before sending it. This is now explicit by having shortcut override events being ignored by default in their constructor, and the documentation has been updated accordingly. Change-Id: I9afa29dbc00bef09fd22ee6bf09661b06340d715 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
Diffstat (limited to 'src/testlib/qtestkeyboard.h')
-rw-r--r--src/testlib/qtestkeyboard.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/testlib/qtestkeyboard.h b/src/testlib/qtestkeyboard.h
index d73658d8fc..d2b3ef240b 100644
--- a/src/testlib/qtestkeyboard.h
+++ b/src/testlib/qtestkeyboard.h
@@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
-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);
+Q_GUI_EXPORT bool qt_handleShortcutEvent(QObject *o, ulong timestamp, int k, Qt::KeyboardModifiers mods, const QString &text = QString(), bool autorep = false, ushort count = 1);
namespace QTest
{
@@ -97,7 +97,7 @@ namespace QTest
if (action == Shortcut) {
int timestamp = 0;
- qt_sendShortcutOverrideEvent(window, timestamp, code, modifier, text, repeat);
+ qt_handleShortcutEvent(window, timestamp, code, modifier, text, repeat);
return;
}
@@ -178,7 +178,7 @@ namespace QTest
QKeyEvent a(press ? QEvent::KeyPress : QEvent::KeyRelease, code, modifier, text, repeat);
QSpontaneKeyEvent::setSpontaneous(&a);
- if (press && qt_sendShortcutOverrideEvent(widget, a.timestamp(), code, modifier, text, repeat))
+ if (press && qt_handleShortcutEvent(widget, a.timestamp(), code, modifier, text, repeat))
return;
if (!qApp->notify(widget, &a))
QTest::qWarn("Keyboard event not accepted by receiving widget");