wasm: add Qt Virtual Keyboard support

Change-Id: I454ab677cad25b50ba7b03ef2c4b6046e1227ce8
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
This commit is contained in:
Dongmei Wang 2019-03-18 20:09:18 -07:00
parent 2a2f04205c
commit ad1d616033
2 changed files with 18 additions and 0 deletions

View File

@ -48,6 +48,7 @@
#include <QtGui/qscreen.h>
#include <qpa/qwindowsysteminterface.h>
#include <QtCore/qcoreapplication.h>
#include <qpa/qplatforminputcontextfactory_p.h>
#include <emscripten/bind.h>
#include <emscripten/val.h>
@ -180,6 +181,18 @@ QPlatformOpenGLContext *QWasmIntegration::createPlatformOpenGLContext(QOpenGLCon
}
#endif
void QWasmIntegration::initialize()
{
QString icStr = QPlatformInputContextFactory::requested();
if (!icStr.isNull())
m_inputContext.reset(QPlatformInputContextFactory::create(icStr));
}
QPlatformInputContext *QWasmIntegration::inputContext() const
{
return m_inputContext.data();
}
QPlatformFontDatabase *QWasmIntegration::fontDatabase() const
{
if (m_fontDb == nullptr)

View File

@ -34,6 +34,7 @@
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformscreen.h>
#include <qpa/qplatforminputcontext.h>
#include <QtCore/qhash.h>
@ -73,6 +74,9 @@ public:
QPlatformTheme *createPlatformTheme(const QString &name) const override;
QPlatformServices *services() const override;
QPlatformClipboard *clipboard() const override;
void initialize() override;
QPlatformInputContext *inputContext() const override;
QWasmClipboard *getWasmClipboard() { return m_clipboard; }
static QWasmIntegration *get() { return s_instance; }
@ -91,6 +95,7 @@ private:
QHash<QString, QWasmScreen *> m_screens;
mutable QWasmClipboard *m_clipboard;
qreal m_fontDpi = -1;
mutable QScopedPointer<QPlatformInputContext> m_inputContext;
static QWasmIntegration *s_instance;
};