diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2018-02-22 04:35:25 +1000 |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@qt.io> | 2019-02-15 12:46:57 +0000 |
commit | 2c6c724949374b17bd3da2938fe8747b480d575a (patch) | |
tree | 6a2f6dfb2e291a2d2fdcf9fd4883fce9efb8601f /src/plugins/platforms/wasm/qwasmintegration.cpp | |
parent | ef2ddcf551dec13215cb45cb000731f94b2f8e34 (diff) |
wasm: add clipboard support
This feature uses the js Clipboard API and is supported only in Chrome,
as Firefox only supports reading the clipboard in browser extensions.
It also requires https or localhost access, otherwise access to the
clipboard is blocked by chrome.
Chrome users will be able to copy/paste text to and from the system
clipbaord.
Other browsers will be able to use the clipboard from within the same
application.
Currently only supports text and html.
Task-number: QTBUG-64638
Change-Id: Ie6de9d10812b776519bd6115593b433fe77059fe
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/plugins/platforms/wasm/qwasmintegration.cpp')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmintegration.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/plugins/platforms/wasm/qwasmintegration.cpp b/src/plugins/platforms/wasm/qwasmintegration.cpp index 7a44c47893..6f96ec69da 100644 --- a/src/plugins/platforms/wasm/qwasmintegration.cpp +++ b/src/plugins/platforms/wasm/qwasmintegration.cpp @@ -33,6 +33,7 @@ #include "qwasmcompositor.h" #include "qwasmopenglcontext.h" #include "qwasmtheme.h" +#include "qwasmclipboard.h" #include "qwasmwindow.h" #ifndef QT_NO_OPENGL @@ -65,17 +66,16 @@ EMSCRIPTEN_BINDINGS(my_module) function("browserBeforeUnload", &browserBeforeUnload); } -static QWasmIntegration *globalHtml5Integration; -QWasmIntegration *QWasmIntegration::get() { return globalHtml5Integration; } +QWasmIntegration *QWasmIntegration::s_instance; QWasmIntegration::QWasmIntegration() : m_fontDb(nullptr), m_compositor(new QWasmCompositor), m_screen(new QWasmScreen(m_compositor)), - m_eventDispatcher(nullptr) + m_eventDispatcher(nullptr), + m_clipboard(new QWasmClipboard) { - - globalHtml5Integration = this; + s_instance = this; updateQScreenAndCanvasRenderSize(); screenAdded(m_screen); @@ -93,6 +93,7 @@ QWasmIntegration::~QWasmIntegration() destroyScreen(m_screen); delete m_fontDb; delete m_eventTranslator; + s_instance = nullptr; } void QWasmIntegration::QWasmBrowserExit() @@ -211,4 +212,11 @@ void QWasmIntegration::updateQScreenAndCanvasRenderSize() QWasmIntegration::get()->m_compositor->redrawWindowContent(); } +QPlatformClipboard* QWasmIntegration::clipboard() const +{ + if (!m_clipboard) + m_clipboard = new QWasmClipboard; + return m_clipboard; +} + QT_END_NAMESPACE |