mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-26 20:03:13 +00:00
354 lines
12 KiB
C++
354 lines
12 KiB
C++
/****************************************************************************
|
|
**
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
** Copyright (C) 2016-2021 Ivailo Monev
|
|
**
|
|
** This file is part of the plugins of the Katie Toolkit.
|
|
**
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
**
|
|
** GNU Lesser General Public License Usage
|
|
** This file may be used under the terms of the GNU Lesser
|
|
** General Public License version 2.1 as published by the Free Software
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
** packaging of this file. Please review the following information to
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
**
|
|
** As a special exception, The Qt Company gives you certain additional
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
**
|
|
** GNU General Public License Usage
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
** General Public License version 3.0 as published by the Free Software
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
** packaging of this file. Please review the following information to
|
|
** ensure the GNU General Public License version 3.0 requirements will be
|
|
** met: http://www.gnu.org/copyleft/gpl.html.
|
|
**
|
|
** $QT_END_LICENSE$
|
|
**
|
|
****************************************************************************/
|
|
|
|
#include "qaccessiblewidgets.h"
|
|
#include "qaccessiblemenu.h"
|
|
#include "simplewidgets.h"
|
|
#include "rangecontrols.h"
|
|
#include "complexwidgets.h"
|
|
#include "itemviews.h"
|
|
|
|
#include "qaccessibleplugin.h"
|
|
#include "qplugin.h"
|
|
#include "qpushbutton.h"
|
|
#include "qtoolbutton.h"
|
|
#include "qtreeview.h"
|
|
#include "qvariant.h"
|
|
#include "qaccessible.h"
|
|
|
|
#ifndef QT_NO_ACCESSIBILITY
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
class AccessibleFactory : public QAccessiblePlugin
|
|
{
|
|
public:
|
|
AccessibleFactory();
|
|
|
|
QStringList keys() const;
|
|
QAccessibleInterface *create(const QString &classname, QObject *object);
|
|
};
|
|
|
|
AccessibleFactory::AccessibleFactory()
|
|
{
|
|
}
|
|
|
|
QStringList AccessibleFactory::keys() const
|
|
{
|
|
static const QStringList list = QStringList()
|
|
#ifndef QT_NO_LINEEDIT
|
|
<< QLatin1String("QLineEdit")
|
|
#endif
|
|
#ifndef QT_NO_COMBOBOX
|
|
<< QLatin1String("QComboBox")
|
|
#endif
|
|
#ifndef QT_NO_SPINBOX
|
|
<< QLatin1String("QAbstractSpinBox")
|
|
<< QLatin1String("QSpinBox")
|
|
<< QLatin1String("QDoubleSpinBox")
|
|
#endif
|
|
#ifndef QT_NO_SCROLLBAR
|
|
<< QLatin1String("QScrollBar")
|
|
#endif
|
|
#ifndef QT_NO_SLIDER
|
|
<< QLatin1String("QSlider")
|
|
#endif
|
|
<< QLatin1String("QAbstractSlider")
|
|
#ifndef QT_NO_TOOLBUTTON
|
|
<< QLatin1String("QToolButton")
|
|
#endif
|
|
#ifndef QT_NO_SPLITTER
|
|
<< QLatin1String("QSplitter")
|
|
<< QLatin1String("QSplitterHandle")
|
|
#endif
|
|
#ifndef QT_NO_TEXTEDIT
|
|
<< QLatin1String("QTextEdit")
|
|
#endif
|
|
#ifndef QT_NO_DIAL
|
|
<< QLatin1String("QDial")
|
|
#endif
|
|
#ifndef QT_NO_RUBBERBAND
|
|
<< QLatin1String("QRubberBand")
|
|
#endif
|
|
#ifndef QT_NO_TEXTBROWSER
|
|
<< QLatin1String("QTextBrowser")
|
|
#endif
|
|
#ifndef QT_NO_SCROLLAREA
|
|
<< QLatin1String("QAbstractScrollArea")
|
|
<< QLatin1String("QScrollArea")
|
|
#endif
|
|
#ifndef QT_NO_CALENDARWIDGET
|
|
<< QLatin1String("QCalendarWidget")
|
|
#endif
|
|
|
|
#ifndef QT_NO_DOCKWIDGET
|
|
<< QLatin1String("QDockWidget")
|
|
#endif
|
|
<< QLatin1String("QPlainTextEdit")
|
|
<< QLatin1String("QTipLabel")
|
|
<< QLatin1String("QFrame")
|
|
<< QLatin1String("QStackedWidget")
|
|
<< QLatin1String("QToolBox")
|
|
<< QLatin1String("QMdiArea")
|
|
<< QLatin1String("QMdiSubWindow")
|
|
<< QLatin1String("QWorkspace")
|
|
<< QLatin1String("QDialogButtonBox")
|
|
<< QLatin1String("QCheckBox")
|
|
<< QLatin1String("QRadioButton")
|
|
<< QLatin1String("QPushButton")
|
|
<< QLatin1String("QAbstractButton")
|
|
<< QLatin1String("QDialog")
|
|
<< QLatin1String("QMessageBox")
|
|
<< QLatin1String("QMainWindow")
|
|
<< QLatin1String("QLabel")
|
|
<< QLatin1String("QLCDNumber")
|
|
<< QLatin1String("QGroupBox")
|
|
<< QLatin1String("QStatusBar")
|
|
<< QLatin1String("QProgressBar")
|
|
<< QLatin1String("QMenuBar")
|
|
<< QLatin1String("QMenu")
|
|
<< QLatin1String("QHeaderView")
|
|
<< QLatin1String("QTabBar")
|
|
<< QLatin1String("QToolBar")
|
|
<< QLatin1String("QWorkspaceChild")
|
|
<< QLatin1String("QSizeGrip")
|
|
<< QLatin1String("QAbstractItemView")
|
|
<< QLatin1String("QWidget");
|
|
return list;
|
|
}
|
|
|
|
QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object)
|
|
{
|
|
QAccessibleInterface *iface = 0;
|
|
if (!object || !object->isWidgetType())
|
|
return iface;
|
|
QWidget *widget = static_cast<QWidget*>(object);
|
|
|
|
if (false) {
|
|
#ifndef QT_NO_LINEEDIT
|
|
} else if (classname == QLatin1String("QLineEdit")) {
|
|
iface = new QAccessibleLineEdit(widget);
|
|
#endif
|
|
#ifndef QT_NO_COMBOBOX
|
|
} else if (classname == QLatin1String("QComboBox")) {
|
|
iface = new QAccessibleComboBox(widget);
|
|
#endif
|
|
#ifndef QT_NO_SPINBOX
|
|
} else if (classname == QLatin1String("QAbstractSpinBox")) {
|
|
iface = new QAccessibleAbstractSpinBox(widget);
|
|
} else if (classname == QLatin1String("QSpinBox")) {
|
|
iface = new QAccessibleSpinBox(widget);
|
|
} else if (classname == QLatin1String("QDoubleSpinBox")) {
|
|
iface = new QAccessibleDoubleSpinBox(widget);
|
|
#endif
|
|
#ifndef QT_NO_SCROLLBAR
|
|
} else if (classname == QLatin1String("QScrollBar")) {
|
|
iface = new QAccessibleScrollBar(widget);
|
|
#endif
|
|
} else if (classname == QLatin1String("QAbstractSlider")) {
|
|
iface = new QAccessibleAbstractSlider(widget);
|
|
#ifndef QT_NO_SLIDER
|
|
} else if (classname == QLatin1String("QSlider")) {
|
|
iface = new QAccessibleSlider(widget);
|
|
#endif
|
|
#ifndef QT_NO_TOOLBUTTON
|
|
} else if (classname == QLatin1String("QToolButton")) {
|
|
Role role = NoRole;
|
|
#ifndef QT_NO_MENU
|
|
QToolButton *tb = qobject_cast<QToolButton*>(widget);
|
|
if (!tb->menu())
|
|
role = tb->isCheckable() ? CheckBox : PushButton;
|
|
else if (tb->popupMode() != QToolButton::DelayedPopup)
|
|
role = ButtonDropDown;
|
|
else
|
|
#endif
|
|
role = ButtonMenu;
|
|
iface = new QAccessibleToolButton(widget, role);
|
|
#endif // QT_NO_TOOLBUTTON
|
|
} else if (classname == QLatin1String("QCheckBox")) {
|
|
iface = new QAccessibleButton(widget, CheckBox);
|
|
} else if (classname == QLatin1String("QRadioButton")) {
|
|
iface = new QAccessibleButton(widget, RadioButton);
|
|
} else if (classname == QLatin1String("QPushButton")) {
|
|
Role role = NoRole;
|
|
QPushButton *pb = qobject_cast<QPushButton*>(widget);
|
|
#ifndef QT_NO_MENU
|
|
if (pb->menu())
|
|
role = ButtonMenu;
|
|
else
|
|
#endif
|
|
if (pb->isCheckable())
|
|
role = CheckBox;
|
|
else
|
|
role = PushButton;
|
|
iface = new QAccessibleButton(widget, role);
|
|
} else if (classname == QLatin1String("QAbstractButton")) {
|
|
iface = new QAccessibleButton(widget, PushButton);
|
|
} else if (classname == QLatin1String("QDialog")) {
|
|
iface = new QAccessibleWidget(widget, Dialog);
|
|
} else if (classname == QLatin1String("QMessageBox")) {
|
|
iface = new QAccessibleWidget(widget, AlertMessage);
|
|
#ifndef QT_NO_MAINWINDOW
|
|
} else if (classname == QLatin1String("QMainWindow")) {
|
|
iface = new QAccessibleMainWindow(widget);
|
|
#endif
|
|
} else if (classname == QLatin1String("QLabel") || classname == QLatin1String("QLCDNumber")) {
|
|
iface = new QAccessibleDisplay(widget);
|
|
#ifndef QT_NO_GROUPBOX
|
|
} else if (classname == QLatin1String("QGroupBox")) {
|
|
iface = new QAccessibleGroupBox(widget);
|
|
#endif
|
|
} else if (classname == QLatin1String("QStatusBar")) {
|
|
iface = new QAccessibleDisplay(widget);
|
|
#ifndef QT_NO_PROGRESSBAR
|
|
} else if (classname == QLatin1String("QProgressBar")) {
|
|
iface = new QAccessibleProgressBar(widget);
|
|
#endif
|
|
} else if (classname == QLatin1String("QToolBar")) {
|
|
iface = new QAccessibleWidget(widget, ToolBar, widget->windowTitle());
|
|
#ifndef QT_NO_MENUBAR
|
|
} else if (classname == QLatin1String("QMenuBar")) {
|
|
iface = new QAccessibleMenuBar(widget);
|
|
#endif
|
|
#ifndef QT_NO_MENU
|
|
} else if (classname == QLatin1String("QMenu")) {
|
|
iface = new QAccessibleMenu(widget);
|
|
#endif
|
|
#ifndef QT_NO_ITEMVIEWS
|
|
#ifdef Q_WS_X11
|
|
} else if (classname == QLatin1String("QAbstractItemView")) {
|
|
if (qobject_cast<const QTreeView*>(widget)) {
|
|
iface = new QAccessibleTree(widget);
|
|
} else {
|
|
iface = new QAccessibleTable2(widget);
|
|
}
|
|
} else if (classname == QLatin1String("QWidget")
|
|
&& widget->objectName() == QLatin1String("qt_scrollarea_viewport")
|
|
&& qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
|
|
if (qobject_cast<const QTreeView*>(widget->parentWidget())) {
|
|
iface = new QAccessibleTree(widget->parentWidget());
|
|
} else {
|
|
iface = new QAccessibleTable2(widget->parentWidget());
|
|
}
|
|
#else
|
|
} else if (classname == QLatin1String("QHeaderView")) {
|
|
iface = new QAccessibleHeader(widget);
|
|
} else if (classname == QLatin1String("QAbstractItemView")) {
|
|
iface = new QAccessibleItemView(widget);
|
|
} else if (classname == QLatin1String("QWidget")
|
|
&& widget->objectName() == QLatin1String("qt_scrollarea_viewport")
|
|
&& qobject_cast<QAbstractItemView*>(widget->parentWidget())) {
|
|
iface = new QAccessibleItemView(widget);
|
|
#endif // Q_WS_X11
|
|
#endif // QT_NO_ITEMVIEWS
|
|
#ifndef QT_NO_TABBAR
|
|
} else if (classname == QLatin1String("QTabBar")) {
|
|
iface = new QAccessibleTabBar(widget);
|
|
#endif
|
|
} else if (classname == QLatin1String("QWorkspaceChild")) {
|
|
iface = new QAccessibleWidget(widget, Window);
|
|
} else if (classname == QLatin1String("QSizeGrip")) {
|
|
iface = new QAccessibleWidget(widget, Grip);
|
|
#ifndef QT_NO_SPLITTER
|
|
} else if (classname == QLatin1String("QSplitter")) {
|
|
iface = new QAccessibleWidget(widget, Splitter);
|
|
} else if (classname == QLatin1String("QSplitterHandle")) {
|
|
iface = new QAccessibleWidget(widget, Grip);
|
|
#endif
|
|
#ifndef QT_NO_TEXTEDIT
|
|
} else if (classname == QLatin1String("QTextEdit")) {
|
|
iface = new QAccessibleTextEdit(widget);
|
|
#endif
|
|
} else if (classname == QLatin1String("QPlainTextEdit")) {
|
|
iface = new QAccessiblePlainTextEdit(widget);
|
|
} else if (classname == QLatin1String("QTipLabel")) {
|
|
iface = new QAccessibleDisplay(widget, ToolTip);
|
|
} else if (classname == QLatin1String("QFrame")) {
|
|
iface = new QAccessibleWidget(widget, Border);
|
|
#ifndef QT_NO_STACKEDWIDGET
|
|
} else if (classname == QLatin1String("QStackedWidget")) {
|
|
iface = new QAccessibleStackedWidget(widget);
|
|
#endif
|
|
#ifndef QT_NO_TOOLBOX
|
|
} else if (classname == QLatin1String("QToolBox")) {
|
|
iface = new QAccessibleToolBox(widget);
|
|
#endif
|
|
#ifndef QT_NO_MDIAREA
|
|
} else if (classname == QLatin1String("QMdiArea")) {
|
|
iface = new QAccessibleMdiArea(widget);
|
|
} else if (classname == QLatin1String("QMdiSubWindow")) {
|
|
iface = new QAccessibleMdiSubWindow(widget);
|
|
#endif
|
|
#ifndef QT_NO_WORKSPACE
|
|
} else if (classname == QLatin1String("QWorkspace")) {
|
|
iface = new QAccessibleWorkspace(widget);
|
|
#endif
|
|
} else if (classname == QLatin1String("QDialogButtonBox")) {
|
|
iface = new QAccessibleDialogButtonBox(widget);
|
|
#ifndef QT_NO_DIAL
|
|
} else if (classname == QLatin1String("QDial")) {
|
|
iface = new QAccessibleDial(widget);
|
|
#endif
|
|
#ifndef QT_NO_RUBBERBAND
|
|
} else if (classname == QLatin1String("QRubberBand")) {
|
|
iface = new QAccessibleWidget(widget, QAccessible::Border);
|
|
#endif
|
|
#ifndef QT_NO_TEXTBROWSER
|
|
} else if (classname == QLatin1String("QTextBrowser")) {
|
|
iface = new QAccessibleTextBrowser(widget);
|
|
#endif
|
|
#ifndef QT_NO_SCROLLAREA
|
|
} else if (classname == QLatin1String("QAbstractScrollArea")) {
|
|
iface = new QAccessibleAbstractScrollArea(widget);
|
|
} else if (classname == QLatin1String("QScrollArea")) {
|
|
iface = new QAccessibleScrollArea(widget);
|
|
#endif
|
|
#ifndef QT_NO_CALENDARWIDGET
|
|
} else if (classname == QLatin1String("QCalendarWidget")) {
|
|
iface = new QAccessibleCalendarWidget(widget);
|
|
#endif
|
|
#ifndef QT_NO_DOCKWIDGET
|
|
} else if (classname == QLatin1String("QDockWidget")) {
|
|
iface = new QAccessibleDockWidget(widget);
|
|
#endif
|
|
}
|
|
|
|
return iface;
|
|
}
|
|
|
|
Q_EXPORT_PLUGIN2(qtaccessiblewidgets, AccessibleFactory)
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
#endif // QT_NO_ACCESSIBILITY
|