Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwasmaccessibility.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QWASMACCESIBILITY_H
5#define QWASMACCESIBILITY_H
6
7#if QT_CONFIG(accessibility)
8
9#include <QtCore/qhash.h>
10#include <private/qstdweb_p.h>
11#include <qpa/qplatformaccessibility.h>
12
13#include <emscripten/val.h>
14#include <QLoggingCategory>
15
16#include <map>
17#include <emscripten/bind.h>
18
19Q_DECLARE_LOGGING_CATEGORY(lcQpaAccessibility)
20
21class QWasmAccessibility : public QPlatformAccessibility
22{
23public:
24 QWasmAccessibility();
25 ~QWasmAccessibility();
26
27 static QWasmAccessibility* get();
28
29 static void addAccessibilityEnableButton(QWindow *window);
30 static void removeAccessibilityEnableButton(QWindow *window);
31
32private:
33 void addAccessibilityEnableButtonImpl(QWindow *window);
34 void removeAccessibilityEnableButtonImpl(QWindow *window);
35 void enableAccessibility();
36
37 static emscripten::val getContainer(QWindow *window);
38 static emscripten::val getContainer(QAccessibleInterface *iface);
39 static emscripten::val getDocument(const emscripten::val &container);
40 static emscripten::val getDocument(QAccessibleInterface *iface);
41 static QWindow *getWindow(QAccessibleInterface *iface);
42
43 emscripten::val createHtmlElement(QAccessibleInterface *iface);
44 void destroyHtmlElement(QAccessibleInterface *iface);
45 emscripten::val ensureHtmlElement(QAccessibleInterface *iface);
46 void setHtmlElementVisibility(QAccessibleInterface *iface, bool visible);
47 void setHtmlElementGeometry(QAccessibleInterface *iface);
48 void setHtmlElementGeometry(emscripten::val element, QRect geometry);
49 void setHtmlElementTextName(QAccessibleInterface *iface);
50 void setHtmlElementTextNameLE(QAccessibleInterface *iface);
51
52 void handleStaticTextUpdate(QAccessibleEvent *event);
53 void handleButtonUpdate(QAccessibleEvent *event);
54 void handleCheckBoxUpdate(QAccessibleEvent *event);
55 void handleDialogUpdate(QAccessibleEvent *event);
56 void handleMenuUpdate(QAccessibleEvent *event);
57 void handleToolUpdate(QAccessibleEvent *event);
58 void handleLineEditUpdate(QAccessibleEvent *event);
59 void handleRadioButtonUpdate(QAccessibleEvent *event);
60 void handleSpinBoxUpdate(QAccessibleEvent *event);
61 void handlePageTabUpdate(QAccessibleEvent *event);
62 void handleSliderUpdate(QAccessibleEvent *event);
63 void handleScrollBarUpdate(QAccessibleEvent *event);
64 void handlePageTabListUpdate(QAccessibleEvent *event);
65
66 void handleEventFromHtmlElement(const emscripten::val event);
67
68 void populateAccessibilityTree(QAccessibleInterface *iface);
69 void notifyAccessibilityUpdate(QAccessibleEvent *event) override;
70 void setRootObject(QObject *o) override;
71 void initialize() override;
72 void cleanup() override;
73
74public: // public for EMSCRIPTEN_BINDINGS
75 static void onHtmlEventReceived(emscripten::val event);
76
77private:
78 static QWasmAccessibility *s_instance;
79 QObject *m_rootObject = nullptr;
80 bool m_accessibilityEnabled = false;
81 std::map<QWindow *, std::tuple<emscripten::val, std::shared_ptr<qstdweb::EventCallback>>> m_enableButtons;
83
84};
85
86#endif // QT_CONFIG(accessibility)
87
88#endif
\inmodule QtCore
Definition qhash.h:818
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtGui
Definition qwindow.h:63
static bool initialize()
Definition qctf.cpp:67
static QDBusError::ErrorType get(const char *name)
#define Q_DECLARE_LOGGING_CATEGORY(name)
struct _cl_event * event
aWidget window() -> setWindowTitle("New Window Title")
[2]