diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-11 12:54:46 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-16 10:58:52 +0100 |
commit | 10c2a8315977e8eb5fc36cf793cfc74d8913dbb0 (patch) | |
tree | 67e7798501c0f6fb218201b87bc95677d9781326 /src/quick/items/qquickevents.cpp | |
parent | 40eff49251a0da87c7e7cb2959a353338d089d1e (diff) |
Don't copy QKeyEvent instances, store the data explicitly
QEvent is a polymorph type, and even though it has a copy constructor,
we shouldn't use it.
Use the pattern as in QQuickMouse/WheelEvent.
Change-Id: I26ab7b831e1e8dd156c32417f74bc7d800bcf71c
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickevents.cpp')
-rw-r--r-- | src/quick/items/qquickevents.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp index ab7b407af5..8df3c1b7dd 100644 --- a/src/quick/items/qquickevents.cpp +++ b/src/quick/items/qquickevents.cpp @@ -157,10 +157,10 @@ Item { */ /*! - \qmlmethod bool QtQuick::KeyEvent::matches(StandardKey key) + \qmlmethod bool QtQuick::KeyEvent::matches(StandardKey matchKey) \since 5.2 - Returns \c true if the key event matches the given standard \a key; otherwise returns \c false. + Returns \c true if the key event matches the given standard \a matchKey; otherwise returns \c false. \qml Item { @@ -176,6 +176,17 @@ Item { \sa QKeySequence::StandardKey */ +#if QT_CONFIG(shortcut) +bool QQuickKeyEvent::matches(QKeySequence::StandardKey matchKey) const +{ + // copying QKeyEvent::matches + uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier); + + const QList<QKeySequence> bindings = QKeySequence::keyBindings(matchKey); + return bindings.contains(QKeySequence(searchkey)); +} +#endif + /*! \qmltype MouseEvent |