1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include "qaccessiblewidgets.h"
43 #include "qaccessiblemenu.h"
44 #include "simplewidgets.h"
45 #include "rangecontrols.h"
46 #include "complexwidgets.h"
47 #include "itemviews.h"
49 #include <qaccessibleplugin.h>
51 #include <qpushbutton.h>
52 #include <qtoolbutton.h>
53 #include <qtreeview.h>
55 #include <qaccessible.h>
57 #ifndef QT_NO_ACCESSIBILITY
62 class AccessibleFactory : public QAccessiblePlugin
65 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QAccessibleFactoryInterface" FILE "widgets.json")
70 QStringList keys() const;
71 QAccessibleInterface *create(const QString &classname, QObject *object);
74 AccessibleFactory::AccessibleFactory()
78 QStringList AccessibleFactory::keys() const
81 #ifndef QT_NO_LINEEDIT
82 list << QLatin1String("QLineEdit");
84 #ifndef QT_NO_COMBOBOX
85 list << QLatin1String("QComboBox");
88 list << QLatin1String("QAbstractSpinBox");
89 list << QLatin1String("QSpinBox");
90 list << QLatin1String("QDoubleSpinBox");
92 #ifndef QT_NO_SCROLLBAR
93 list << QLatin1String("QScrollBar");
96 list << QLatin1String("QSlider");
98 list << QLatin1String("QAbstractSlider");
99 #ifndef QT_NO_TOOLBUTTON
100 list << QLatin1String("QToolButton");
102 list << QLatin1String("QCheckBox");
103 list << QLatin1String("QRadioButton");
104 list << QLatin1String("QPushButton");
105 list << QLatin1String("QAbstractButton");
106 list << QLatin1String("QDialog");
107 list << QLatin1String("QMessageBox");
108 list << QLatin1String("QMainWindow");
109 list << QLatin1String("QLabel");
110 list << QLatin1String("QLCDNumber");
111 list << QLatin1String("QGroupBox");
112 list << QLatin1String("QStatusBar");
113 list << QLatin1String("QProgressBar");
114 list << QLatin1String("QMenuBar");
115 list << QLatin1String("QMenu");
116 list << QLatin1String("QHeaderView");
117 list << QLatin1String("QTabBar");
118 list << QLatin1String("QToolBar");
119 list << QLatin1String("QWorkspaceChild");
120 list << QLatin1String("QSizeGrip");
121 list << QLatin1String("QAbstractItemView");
122 list << QLatin1String("QWidget");
123 #ifndef QT_NO_SPLITTER
124 list << QLatin1String("QSplitter");
125 list << QLatin1String("QSplitterHandle");
127 #ifndef QT_NO_TEXTEDIT
128 list << QLatin1String("QTextEdit");
130 list << QLatin1String("QTipLabel");
131 list << QLatin1String("QFrame");
132 list << QLatin1String("QStackedWidget");
133 list << QLatin1String("QToolBox");
134 list << QLatin1String("QMdiArea");
135 list << QLatin1String("QMdiSubWindow");
136 list << QLatin1String("QWorkspace");
137 list << QLatin1String("QDialogButtonBox");
139 list << QLatin1String("QDial");
141 #ifndef QT_NO_RUBBERBAND
142 list << QLatin1String("QRubberBand");
144 #ifndef QT_NO_TEXTBROWSER
145 list << QLatin1String("QTextBrowser");
147 #ifndef QT_NO_SCROLLAREA
148 list << QLatin1String("QAbstractScrollArea");
149 list << QLatin1String("QScrollArea");
151 #ifndef QT_NO_CALENDARWIDGET
152 list << QLatin1String("QCalendarWidget");
155 #ifndef QT_NO_DOCKWIDGET
156 list << QLatin1String("QDockWidget");
158 list << QLatin1String("QAccessibleWidget");
162 QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object)
164 QAccessibleInterface *iface = 0;
165 if (!object || !object->isWidgetType())
167 QWidget *widget = static_cast<QWidget*>(object);
170 #ifndef QT_NO_LINEEDIT
171 } else if (classname == QLatin1String("QLineEdit")) {
172 iface = new QAccessibleLineEdit(widget);
174 #ifndef QT_NO_COMBOBOX
175 } else if (classname == QLatin1String("QComboBox")) {
176 iface = new QAccessibleComboBox(widget);
178 #ifndef QT_NO_SPINBOX
179 } else if (classname == QLatin1String("QAbstractSpinBox")) {
180 iface = new QAccessibleAbstractSpinBox(widget);
181 } else if (classname == QLatin1String("QSpinBox")) {
182 iface = new QAccessibleSpinBox(widget);
183 } else if (classname == QLatin1String("QDoubleSpinBox")) {
184 iface = new QAccessibleDoubleSpinBox(widget);
186 #ifndef QT_NO_SCROLLBAR
187 } else if (classname == QLatin1String("QScrollBar")) {
188 iface = new QAccessibleScrollBar(widget);
190 } else if (classname == QLatin1String("QAbstractSlider")) {
191 iface = new QAccessibleAbstractSlider(widget);
193 } else if (classname == QLatin1String("QSlider")) {
194 iface = new QAccessibleSlider(widget);
196 #ifndef QT_NO_TOOLBUTTON
197 } else if (classname == QLatin1String("QToolButton")) {
198 QAccessible::Role role = QAccessible::NoRole;
200 QToolButton *tb = qobject_cast<QToolButton*>(widget);
202 role = tb->isCheckable() ? QAccessible::CheckBox : QAccessible::PushButton;
203 else if (!tb->popupMode() != QToolButton::DelayedPopup)
204 role = QAccessible::ButtonDropDown;
207 role = QAccessible::ButtonMenu;
208 iface = new QAccessibleToolButton(widget, role);
209 #endif // QT_NO_TOOLBUTTON
210 } else if (classname == QLatin1String("QCheckBox")) {
211 iface = new QAccessibleButton(widget, QAccessible::CheckBox);
212 } else if (classname == QLatin1String("QRadioButton")) {
213 iface = new QAccessibleButton(widget, QAccessible::RadioButton);
214 } else if (classname == QLatin1String("QPushButton")) {
215 QAccessible::Role role = QAccessible::NoRole;
216 QPushButton *pb = qobject_cast<QPushButton*>(widget);
219 role = QAccessible::ButtonMenu;
222 if (pb->isCheckable())
223 role = QAccessible::CheckBox;
225 role = QAccessible::PushButton;
226 iface = new QAccessibleButton(widget, role);
227 } else if (classname == QLatin1String("QAbstractButton")) {
228 iface = new QAccessibleButton(widget, QAccessible::PushButton);
229 } else if (classname == QLatin1String("QDialog")) {
230 iface = new QAccessibleWidget(widget, QAccessible::Dialog);
231 } else if (classname == QLatin1String("QMessageBox")) {
232 iface = new QAccessibleWidget(widget, QAccessible::AlertMessage);
233 #ifndef QT_NO_MAINWINDOW
234 } else if (classname == QLatin1String("QMainWindow")) {
235 iface = new QAccessibleMainWindow(widget);
237 } else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) {
238 iface = new QAccessibleDisplay(widget);
239 } else if (classname == QLatin1String("QGroupBox")) {
240 iface = new QAccessibleDisplay(widget, QAccessible::Grouping);
241 } else if (classname == QLatin1String("QStatusBar")) {
242 iface = new QAccessibleWidget(widget, QAccessible::StatusBar);
243 #ifndef QT_NO_PROGRESSBAR
244 } else if (classname == QLatin1String("QProgressBar")) {
245 iface = new QAccessibleProgressBar(widget);
247 } else if (classname == QLatin1String("QToolBar")) {
248 iface = new QAccessibleWidget(widget, QAccessible::ToolBar, widget->windowTitle());
249 #ifndef QT_NO_MENUBAR
250 } else if (classname == QLatin1String("QMenuBar")) {
251 iface = new QAccessibleMenuBar(widget);
254 } else if (classname == QLatin1String("QMenu")) {
255 iface = new QAccessibleMenu(widget);
257 #ifndef QT_NO_ITEMVIEWS
258 } else if (classname == QLatin1String("QAbstractItemView")) {
259 if (qobject_cast<const QTreeView*>(widget)) {
260 iface = new QAccessibleTree(widget);
262 iface = new QAccessibleTable(widget);
264 } else if (classname == QLatin1String("QWidget")
265 && widget->objectName() == QLatin1String("qt_scrollarea_viewport")
266 && qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
267 if (qobject_cast<const QTreeView*>(widget->parentWidget())) {
268 iface = new QAccessibleTree(widget->parentWidget());
270 iface = new QAccessibleTable(widget->parentWidget());
272 #endif // QT_NO_ITEMVIEWS
274 } else if (classname == QLatin1String("QTabBar")) {
275 iface = new QAccessibleTabBar(widget);
277 } else if (classname == QLatin1String("QWorkspaceChild")) {
278 iface = new QAccessibleWidget(widget, QAccessible::Window);
279 } else if (classname == QLatin1String("QSizeGrip")) {
280 iface = new QAccessibleWidget(widget, QAccessible::Grip);
281 #ifndef QT_NO_SPLITTER
282 } else if (classname == QLatin1String("QSplitter")) {
283 iface = new QAccessibleWidget(widget, QAccessible::Splitter);
284 } else if (classname == QLatin1String("QSplitterHandle")) {
285 iface = new QAccessibleWidget(widget, QAccessible::Grip);
287 #ifndef QT_NO_TEXTEDIT
288 } else if (classname == QLatin1String("QTextEdit")) {
289 iface = new QAccessibleTextEdit(widget);
291 } else if (classname == QLatin1String("QTipLabel")) {
292 iface = new QAccessibleDisplay(widget, QAccessible::ToolTip);
293 } else if (classname == QLatin1String("QFrame")) {
294 iface = new QAccessibleWidget(widget, QAccessible::Border);
295 #ifndef QT_NO_STACKEDWIDGET
296 } else if (classname == QLatin1String("QStackedWidget")) {
297 iface = new QAccessibleStackedWidget(widget);
299 #ifndef QT_NO_TOOLBOX
300 } else if (classname == QLatin1String("QToolBox")) {
301 iface = new QAccessibleToolBox(widget);
303 #ifndef QT_NO_MDIAREA
304 } else if (classname == QLatin1String("QMdiArea")) {
305 iface = new QAccessibleMdiArea(widget);
306 } else if (classname == QLatin1String("QMdiSubWindow")) {
307 iface = new QAccessibleMdiSubWindow(widget);
309 #ifndef QT_NO_WORKSPACE
310 } else if (classname == QLatin1String("QWorkspace")) {
311 iface = new QAccessibleWorkspace(widget);
313 } else if (classname == QLatin1String("QDialogButtonBox")) {
314 iface = new QAccessibleDialogButtonBox(widget);
316 } else if (classname == QLatin1String("QDial")) {
317 iface = new QAccessibleDial(widget);
319 #ifndef QT_NO_RUBBERBAND
320 } else if (classname == QLatin1String("QRubberBand")) {
321 iface = new QAccessibleWidget(widget, QAccessible::Border);
323 #ifndef QT_NO_TEXTBROWSER
324 } else if (classname == QLatin1String("QTextBrowser")) {
325 iface = new QAccessibleTextBrowser(widget);
327 #ifndef QT_NO_SCROLLAREA
328 } else if (classname == QLatin1String("QAbstractScrollArea")) {
329 iface = new QAccessibleAbstractScrollArea(widget);
330 } else if (classname == QLatin1String("QScrollArea")) {
331 iface = new QAccessibleScrollArea(widget);
333 #ifndef QT_NO_CALENDARWIDGET
334 } else if (classname == QLatin1String("QCalendarWidget")) {
335 iface = new QAccessibleCalendarWidget(widget);
337 #ifndef QT_NO_DOCKWIDGET
338 } else if (classname == QLatin1String("QDockWidget")) {
339 iface = new QAccessibleDockWidget(widget);
342 iface = new QAccessibleWidget(widget);
353 #endif // QT_NO_ACCESSIBILITY