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
qaccessibleobject.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qaccessibleobject.h"
5
6#if QT_CONFIG(accessibility)
7
8#include <QtGui/QGuiApplication>
9#include <QtGui/QWindow>
10
11#include "qpointer.h"
12#include "qmetaobject.h"
13
15
16class QAccessibleObjectPrivate
17{
18public:
19 QPointer<QObject> object;
20};
21
42QAccessibleObject::QAccessibleObject(QObject *object)
43{
44 d = new QAccessibleObjectPrivate;
45 d->object = object;
46}
47
54QAccessibleObject::~QAccessibleObject()
55{
56 delete d;
57}
58
62QObject *QAccessibleObject::object() const
63{
64 return d->object;
65}
66
70bool QAccessibleObject::isValid() const
71{
72 return !d->object.isNull();
73}
74
76QRect QAccessibleObject::rect() const
77{
78 return QRect();
79}
80
82void QAccessibleObject::setText(QAccessible::Text, const QString &)
83{
84}
85
87QAccessibleInterface *QAccessibleObject::childAt(int x, int y) const
88{
89 for (int i = 0; i < childCount(); ++i) {
90 QAccessibleInterface *childIface = child(i);
91 Q_ASSERT(childIface);
92 if (childIface->isValid() && childIface->rect().contains(x,y))
93 return childIface;
94 }
95 return nullptr;
96}
97
110QAccessibleApplication::QAccessibleApplication()
111: QAccessibleObject(qApp)
112{
113}
114
115QWindow *QAccessibleApplication::window() const
116{
117 // an application can have several windows, and AFAIK we don't need
118 // to notify about changes on the application.
119 return nullptr;
120}
121
122// all toplevel windows except popups and the desktop
123static QObjectList topLevelObjects()
124{
127 for (int i = 0; i < tlw.size(); ++i) {
128 QWindow *w = tlw.at(i);
129 if (w->type() != Qt::Popup && w->type() != Qt::Desktop) {
130 if (QAccessibleInterface *root = w->accessibleRoot()) {
131 if (root->object())
132 list.append(root->object());
133 }
134 }
135 }
136
137 return list;
138}
139
141int QAccessibleApplication::childCount() const
142{
143 return topLevelObjects().size();
144}
145
147int QAccessibleApplication::indexOfChild(const QAccessibleInterface *child) const
148{
149 if (!child)
150 return -1;
151 const QObjectList tlw(topLevelObjects());
152 return tlw.indexOf(child->object());
153}
154
155QAccessibleInterface *QAccessibleApplication::parent() const
156{
157 return nullptr;
158}
159
160QAccessibleInterface *QAccessibleApplication::child(int index) const
161{
162 const QObjectList tlo(topLevelObjects());
163 if (index >= 0 && index < tlo.size())
164 return QAccessible::queryAccessibleInterface(tlo.at(index));
165 return nullptr;
166}
167
168
170QAccessibleInterface *QAccessibleApplication::focusChild() const
171{
173 return window->accessibleRoot();
174 return nullptr;
175}
176
178QString QAccessibleApplication::text(QAccessible::Text t) const
179{
180 switch (t) {
181 case QAccessible::Name:
183 case QAccessible::Description:
185 default:
186 break;
187 }
188 return QString();
189}
190
192QAccessible::Role QAccessibleApplication::role() const
193{
194 return QAccessible::Application;
195}
196
198QAccessible::State QAccessibleApplication::state() const
199{
200 return QAccessible::State();
201}
202
203
205
206#endif // QT_CONFIG(accessibility)
\inmodule QtGui
static QString applicationFilePath()
Returns the file path of the application executable.
QString applicationName
the name of this application
static QWindowList topLevelWindows()
Returns a list of the top-level windows in the application.
static QWindow * focusWindow()
Returns the QWindow that receives events tied to focus, such as key events.
qsizetype size() const noexcept
Definition qlist.h:397
void append(parameter_type t)
Definition qlist.h:458
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qrect.h:30
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtGui
Definition qwindow.h:63
Combined button and popup list for selecting options.
@ Desktop
Definition qnamespace.h:215
@ Popup
Definition qnamespace.h:211
#define qApp
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLuint index
[2]
GLuint object
[3]
GLint y
GLdouble GLdouble t
Definition qopenglext.h:243
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QList< int > list
[14]
QLayoutItem * child
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]