summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/wasm/qwasmclipboard.cpp
diff options
context:
space:
mode:
authorMikolaj Boc <mikolaj.boc@qt.io>2022-09-16 15:34:03 +0200
committerMikolaj Boc <mikolaj.boc@qt.io>2022-09-18 21:44:35 +0200
commit38049164c370dd424afe0c4574b458f7bd79083b (patch)
tree3ee33506ad9ace404f57d58842efbdec9db5c0fe /src/plugins/platforms/wasm/qwasmclipboard.cpp
parent9536a0ad48a54fef504689cc7a1e65ab865c5ff4 (diff)
Make the clipboard paste from the outside work correctly
During the previous refactoring, two exceptions that triggered native copy/paste events were omitted. Fixes: QTBUG-106668 Pick-to: 6.4.0 6.4 Change-Id: Ie61dd6a0c1d9d2fdd47bd94be055d0221feae25b Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmclipboard.cpp')
-rw-r--r--src/plugins/platforms/wasm/qwasmclipboard.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/plugins/platforms/wasm/qwasmclipboard.cpp b/src/plugins/platforms/wasm/qwasmclipboard.cpp
index d290fe245b1..4f4538eec6f 100644
--- a/src/plugins/platforms/wasm/qwasmclipboard.cpp
+++ b/src/plugins/platforms/wasm/qwasmclipboard.cpp
@@ -183,19 +183,21 @@ void QWasmClipboard::setMimeData(QMimeData *mimeData, QClipboard::Mode mode)
isPaste = false;
}
-bool QWasmClipboard::processKeyboard(const QWasmEventTranslator::TranslatedEvent &event,
- const QFlags<Qt::KeyboardModifier> &modifiers)
+QWasmClipboard::ProcessKeyboardResult
+QWasmClipboard::processKeyboard(const QWasmEventTranslator::TranslatedEvent &event,
+ const QFlags<Qt::KeyboardModifier> &modifiers)
{
- // Clipboard path: cut/copy/paste are handled by clipboard event or direct clipboard
- // access.
- if (hasClipboardApi)
- return false;
- if (event.type != QEvent::KeyPress || !modifiers.testFlag(Qt::ControlModifier)
- || (event.key != Qt::Key_C && event.key != Qt::Key_V && event.key != Qt::Key_X)) {
- return false;
- }
+ if (event.type != QEvent::KeyPress || !modifiers.testFlag(Qt::ControlModifier))
+ return ProcessKeyboardResult::Ignored;
+
+ if (event.key != Qt::Key_C && event.key != Qt::Key_V && event.key != Qt::Key_X)
+ return ProcessKeyboardResult::Ignored;
+
isPaste = event.key == Qt::Key_V;
- return true;
+
+ return hasClipboardApi && !isPaste
+ ? ProcessKeyboardResult::NativeClipboardEventAndCopiedDataNeeded
+ : ProcessKeyboardResult::NativeClipboardEventNeeded;
}
bool QWasmClipboard::supportsMode(QClipboard::Mode mode) const