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#ifndef QACCESSIBLEMENU_H
5#define QACCESSIBLEMENU_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include <QtWidgets/qaccessiblewidget.h>
20#include <QtCore/qpointer.h>
21
22QT_BEGIN_NAMESPACE
23
24#if QT_CONFIG(accessibility)
25
26#if QT_CONFIG(menu)
27class QMenu;
28class QMenuBar;
29class QAction;
30
31class QAccessibleMenu : public QAccessibleWidget
32{
33public:
34 explicit QAccessibleMenu(QWidget *w);
35
36 int childCount() const override;
37 QAccessibleInterface *childAt(int x, int y) const override;
38
39 QString text(QAccessible::Text t) const override;
40 QAccessible::Role role() const override;
41 QAccessibleInterface *child(int index) const override;
42 QAccessibleInterface *parent() const override;
43 int indexOfChild( const QAccessibleInterface *child ) const override;
44
45protected:
46 QMenu *menu() const;
47};
48
49#if QT_CONFIG(menubar)
50class QAccessibleMenuBar : public QAccessibleWidget
51{
52public:
53 explicit QAccessibleMenuBar(QWidget *w);
54
55 QAccessibleInterface *child(int index) const override;
56 int childCount() const override;
57
58 int indexOfChild(const QAccessibleInterface *child) const override;
59
60protected:
61 QMenuBar *menuBar() const;
62};
63#endif // QT_CONFIG(menubar)
64
65
66class QAccessibleMenuItem : public QAccessibleInterface, public QAccessibleActionInterface
67{
68public:
69 explicit QAccessibleMenuItem(QWidget *owner, QAction *w);
70
71 ~QAccessibleMenuItem();
72 void *interface_cast(QAccessible::InterfaceType t) override;
73
74 int childCount() const override;
75 QAccessibleInterface *childAt(int x, int y) const override;
76 bool isValid() const override;
77 int indexOfChild(const QAccessibleInterface * child) const override;
78
79 QAccessibleInterface *parent() const override;
80 QAccessibleInterface *child(int index) const override;
81 QObject * object() const override;
82 QWindow *window() const override;
83
84 QRect rect() const override;
85 QAccessible::Role role() const override;
86 void setText(QAccessible::Text t, const QString & text) override;
87 QAccessible::State state() const override;
88 QString text(QAccessible::Text t) const override;
89
90 // QAccessibleActionInterface
91 QStringList actionNames() const override;
92 void doAction(const QString &actionName) override;
93 QStringList keyBindingsForAction(const QString &actionName) const override;
94
95 QWidget *owner() const;
96protected:
97 QAction *action() const;
98private:
99 QAction *m_action;
100 QPointer<QWidget> m_owner; // can hold either QMenu or the QMenuBar that contains the action
101};
102
103#endif // QT_CONFIG(menu)
104
105QT_END_NAMESPACE
106#endif // QT_CONFIG(accessibility)
107#endif // QACCESSIBLEMENU_H
108

source code of qtbase/src/widgets/accessible/qaccessiblemenu_p.h