Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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#include <QtCore/qtconfigmacros.h>
8#include <QtGui/qtguiglobal.h>
9
10#if QT_CONFIG(accessibility)
11
12#include <QtCore/qhash.h>
13#include <private/qstdweb_p.h>
14#include <qpa/qplatformaccessibility.h>
15
16#include <emscripten/val.h>
17#include <QLoggingCategory>
18
19#include <map>
20#include <emscripten/bind.h>
21
22Q_DECLARE_LOGGING_CATEGORY(lcQpaAccessibility)
23
24class QWasmAccessibility : public QPlatformAccessibility
25{
26public:
27 QWasmAccessibility();
28 ~QWasmAccessibility();
29
30 static QWasmAccessibility* get();
31
32 static void addAccessibilityEnableButton(QWindow *window);
33 static void removeAccessibilityEnableButton(QWindow *window);
34
35private:
36 void addAccessibilityEnableButtonImpl(QWindow *window);
37 void removeAccessibilityEnableButtonImpl(QWindow *window);
38 void enableAccessibility();
39
40 static emscripten::val getContainer(QWindow *window);
41 static emscripten::val getContainer(QAccessibleInterface *iface);
42 static emscripten::val getDocument(const emscripten::val &container);
43 static emscripten::val getDocument(QAccessibleInterface *iface);
44 static QWindow *getWindow(QAccessibleInterface *iface);
45
46 emscripten::val createHtmlElement(QAccessibleInterface *iface);
47 void destroyHtmlElement(QAccessibleInterface *iface);
48 emscripten::val ensureHtmlElement(QAccessibleInterface *iface);
49 void setHtmlElementVisibility(QAccessibleInterface *iface, bool visible);
50 void setHtmlElementGeometry(QAccessibleInterface *iface);
51 void setHtmlElementGeometry(emscripten::val element, QRect geometry);
52 void setHtmlElementTextName(QAccessibleInterface *iface);
53 void setHtmlElementTextNameLE(QAccessibleInterface *iface);
54 void setHtmlElementDescription(QAccessibleInterface *iface);
55
56 void handleStaticTextUpdate(QAccessibleEvent *event);
57 void handleButtonUpdate(QAccessibleEvent *event);
58 void handleCheckBoxUpdate(QAccessibleEvent *event);
59 void handleDialogUpdate(QAccessibleEvent *event);
60 void handleMenuUpdate(QAccessibleEvent *event);
61 void handleToolUpdate(QAccessibleEvent *event);
62 void handleLineEditUpdate(QAccessibleEvent *event);
63 void handleRadioButtonUpdate(QAccessibleEvent *event);
64 void handleSpinBoxUpdate(QAccessibleEvent *event);
65 void handlePageTabUpdate(QAccessibleEvent *event);
66 void handleSliderUpdate(QAccessibleEvent *event);
67 void handleScrollBarUpdate(QAccessibleEvent *event);
68 void handlePageTabListUpdate(QAccessibleEvent *event);
69
70 void handleEventFromHtmlElement(const emscripten::val event);
71
72 void populateAccessibilityTree(QAccessibleInterface *iface);
73 void notifyAccessibilityUpdate(QAccessibleEvent *event) override;
74 void setRootObject(QObject *o) override;
75 void initialize() override;
76 void cleanup() override;
77
78public: // public for EMSCRIPTEN_BINDINGS
79 static void onHtmlEventReceived(emscripten::val event);
80
81private:
82 static QWasmAccessibility *s_instance;
83 QObject *m_rootObject = nullptr;
84 bool m_accessibilityEnabled = false;
85 std::map<QWindow *, std::tuple<emscripten::val, std::shared_ptr<qstdweb::EventCallback>>> m_enableButtons;
86 QHash<QAccessibleInterface *, emscripten::val> m_elements;
87
88};
89
90#endif // QT_CONFIG(accessibility)
91
92#endif
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtGui
Definition qwindow.h:63
static bool initialize()
Definition qctf.cpp:94
static QDBusError::ErrorType get(const char *name)
#define Q_DECLARE_LOGGING_CATEGORY(name)
struct _cl_event * event
aWidget window() -> setWindowTitle("New Window Title")
[2]