Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwasmintegration.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWASMINTEGRATION_H
5#define QWASMINTEGRATION_H
6
7#include "qwasmwindow.h"
8
10
11#include <qpa/qplatformintegration.h>
12#include <qpa/qplatformscreen.h>
13#include <qpa/qplatforminputcontext.h>
14
15#include <QtCore/qhash.h>
16
17#include <private/qstdweb_p.h>
18
19#include <emscripten.h>
20#include <emscripten/html5.h>
21#include <emscripten/val.h>
22
24
25class QWasmEventTranslator;
26class QWasmFontDatabase;
27class QWasmWindow;
28class QWasmEventDispatcher;
29class QWasmScreen;
30class QWasmCompositor;
32class QWasmClipboard;
33class QWasmAccessibility;
34class QWasmServices;
35class QWasmDrag;
36
38{
40public:
43
44 bool hasCapability(QPlatformIntegration::Capability cap) const override;
45 QPlatformWindow *createPlatformWindow(QWindow *window) const override;
46 QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
47#ifndef QT_NO_OPENGL
48 QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
49#endif
50 QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override;
51 QPlatformFontDatabase *fontDatabase() const override;
53 QVariant styleHint(QPlatformIntegration::StyleHint hint) const override;
54 Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override;
55 QStringList themeNames() const override;
56 QPlatformTheme *createPlatformTheme(const QString &name) const override;
57 QPlatformServices *services() const override;
58 QPlatformClipboard *clipboard() const override;
59#ifndef QT_NO_ACCESSIBILITY
60 QPlatformAccessibility *accessibility() const override;
61#endif
62 void initialize() override;
63 QPlatformInputContext *inputContext() const override;
64 QWasmInputContext *wasmInputContext() const { return m_wasmInputContext; }
65
66#if QT_CONFIG(draganddrop)
68#endif
69
70 QWasmClipboard *getWasmClipboard() { return m_clipboard; }
71 static QWasmIntegration *get() { return s_instance; }
72
73 void setContainerElements(emscripten::val elementArray);
74 void addContainerElement(emscripten::val elementArray);
75 void removeContainerElement(emscripten::val elementArray);
76 void resizeScreen(const emscripten::val &canvas);
77 void updateDpi();
78 void resizeAllScreens();
79 void loadLocalFontFamilies(emscripten::val families);
80 void removeBackingStore(QWindow* window);
82 static quint64 getTimestamp();
83
85
86private:
87 struct ScreenMapping {
88 emscripten::val emscriptenVal;
89 QWasmScreen *wasmScreen;
90 };
91
92 mutable QWasmFontDatabase *m_fontDb;
93 mutable QWasmServices *m_desktopServices;
94 mutable QHash<QWindow *, QWasmBackingStore *> m_backingStores;
95 QList<ScreenMapping> m_screens;
96 mutable QWasmClipboard *m_clipboard;
97 mutable QWasmAccessibility *m_accessibility;
98
99 qreal m_fontDpi = -1;
100 mutable QScopedPointer<QPlatformInputContext> m_inputContext;
101 static QWasmIntegration *s_instance;
102
103 QWasmInputContext *m_wasmInputContext = nullptr;
104
105#if QT_CONFIG(draganddrop)
107#endif
108
109};
110
111QT_END_NAMESPACE
112
113#endif // QWASMINTEGRATION_H
QWasmCompositor(QWasmScreen *screen)
QPlatformInputContext * inputContext() const override
Returns the platforms input context.
void setContainerElements(emscripten::val elementArray)
static QWasmIntegration * get()
Qt::WindowState defaultWindowState(Qt::WindowFlags flags) const override
QPlatformFontDatabase * fontDatabase() const override
Accessor for the platform integration's fontdatabase.
QPlatformOffscreenSurface * createPlatformOffscreenSurface(QOffscreenSurface *surface) const override
Factory function for QOffscreenSurface.
void addContainerElement(emscripten::val elementArray)
void initialize() override
Performs initialization steps that depend on having an event dispatcher available.
QWasmClipboard * getWasmClipboard()
void removeContainerElement(emscripten::val elementArray)
QAbstractEventDispatcher * createEventDispatcher() const override
Factory function for the GUI event dispatcher.
QStringList themeNames() const override
void loadLocalFontFamilies(emscripten::val families)
QPlatformOpenGLContext * createPlatformOpenGLContext(QOpenGLContext *context) const override
Factory function for QPlatformOpenGLContext.
QWasmInputContext * wasmInputContext() const
static quint64 getTimestamp()
QPlatformServices * services() const override
QPlatformClipboard * clipboard() const override
Accessor for the platform integration's clipboard.
QPlatformTheme * createPlatformTheme(const QString &name) const override
void resizeScreen(const emscripten::val &canvas)
QVariant styleHint(QPlatformIntegration::StyleHint hint) const override
bool hasCapability(QPlatformIntegration::Capability cap) const override
QPlatformAccessibility * accessibility() const override
friend class QWasmCompositor
Combined button and popup list for selecting options.