7#if QT_CONFIG(accessibility)
9#include <QtGui/qguiapplication.h>
10#include <QtGui/qwindow.h>
11#include <QtGui/private/qwindow_p.h>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31QAccessibleWindow::QAccessibleWindow(QWindow *window)
32 : QAccessibleObject(window)
36QWindow *QAccessibleWindow::window()
const
38 return static_cast<QWindow *>(object());
42
43
44
45
46
47
48
49
50
51QList<QAccessibleInterface *> QAccessibleWindow::childInterfaces()
const
53 QList<QAccessibleInterface *> interfaces;
58 const auto childWindows = window()->findChildren<QWindow *>(Qt::FindDirectChildrenOnly);
59 interfaces.reserve(childWindows.size());
60 for (QWindow *childWindow : childWindows) {
61 if (QAccessibleInterface *iface = childWindow->accessibleRoot())
62 interfaces.append(iface);
68int QAccessibleWindow::childCount()
const
70 return childInterfaces().size();
73int QAccessibleWindow::indexOfChild(
const QAccessibleInterface *child)
const
80 return childInterfaces().indexOf(
const_cast<QAccessibleInterface *>(child));
83QAccessibleInterface *QAccessibleWindow::child(
int index)
const
85 const QList<QAccessibleInterface *> children = childInterfaces();
86 if (index >= 0 && index < children.size())
87 return children.at(index);
91QAccessibleInterface *QAccessibleWindow::parent()
const
97 if (QObject *a11yParent = QWindowPrivate::get(window())->accessibleParent)
98 return QAccessible::queryAccessibleInterface(a11yParent);
102 if (QWindow *parentWindow = window()->parent()) {
103 if (QAccessibleInterface *iface = parentWindow->accessibleRoot())
107 return QAccessible::queryAccessibleInterface(qApp);
110QAccessibleInterface *QAccessibleWindow::focusChild()
const
112 const QWindow *focusWindow = QGuiApplication::focusWindow();
114 for (QAccessibleInterface *child : childInterfaces()) {
115 if (QAccessibleInterface *focus = child->focusChild())
119 if (child->window() == focusWindow)
126QString QAccessibleWindow::text(QAccessible::Text text)
const
131 if (text == QAccessible::Name && window()->isTopLevel())
132 return window()->title();
137QAccessible::Role QAccessibleWindow::role()
const
139 if (isValid() && window()->isTopLevel())
140 return QAccessible::Window;
144 return QAccessible::Client;
147QAccessible::State QAccessibleWindow::state()
const
149 QAccessible::State state;
152 state.invalid =
true;
156 state.invisible = !window()->isVisible();
157 state.focused = window() == QGuiApplication::focusWindow();
158 state.active = window()->isActive();
163QRect QAccessibleWindow::rect()
const
168 return QRect(window()->mapToGlobal(QPoint(0, 0)), window()->size());