Accessibility: Use factory function instead of plugin

This simplifies deployment and makes instantiating accessible interfaces
faster since no plugin needs to be loaded.

[ChangeLog][QtWidgets] Accessibility for widgets is now included in the
widget library instead of being a separate plugin. For static builds
this means that libqtaccessiblewidgets is no longer required.

Task-number: QTBUG-32888

Change-Id: Ie7347898868fd67c1fc568f0d251cbd2ef71e041
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
This commit is contained in:
Frederik Gladhorn 2014-02-05 11:44:42 +01:00 committed by The Qt Project
parent 55eec6829e
commit eaee2bd0d0
22 changed files with 89 additions and 98 deletions

View File

@ -1,5 +0,0 @@
TEMPLATE = subdirs
contains(QT_CONFIG, accessibility) {
SUBDIRS += widgets
}

View File

@ -1,54 +0,0 @@
{
"Keys": [
"QLineEdit",
"QComboBox",
"QAbstractSpinBox",
"QSpinBox",
"QDoubleSpinBox",
"QScrollBar",
"QSlider",
"QAbstractSlider",
"QToolButton",
"QCheckBox",
"QRadioButton",
"QPushButton",
"QAbstractButton",
"QDialog",
"QMessageBox",
"QMainWindow",
"QLabel",
"QLCDNumber",
"QGroupBox",
"QStatusBar",
"QProgressBar",
"QPlainTextEdit",
"QMenuBar",
"QMenu",
"QTabBar",
"QToolBar",
"QSizeGrip",
"QListView",
"QTreeView",
"QTableView",
"QWidget",
"QSplitter",
"QSplitterHandle",
"QTextEdit",
"QTipLabel",
"QFrame",
"QStackedWidget",
"QToolBox",
"QMdiArea",
"QMdiSubWindow",
"QDialogButtonBox",
"QDial",
"QRubberBand",
"QTextBrowser",
"QAbstractScrollArea",
"QScrollArea",
"QCalendarWidget",
"QDockWidget",
"QDesktopScreenWidget",
"QWindowContainer"
]
}

View File

@ -3,6 +3,5 @@ TEMPLATE = subdirs
SUBDIRS *= sqldrivers
!winrt:qtHaveModule(network): SUBDIRS += bearer
qtHaveModule(gui): SUBDIRS *= imageformats platforms platforminputcontexts platformthemes generic
qtHaveModule(widgets): SUBDIRS += accessible
!winrt:!wince*:qtHaveModule(widgets):SUBDIRS += printsupport

View File

@ -1,6 +1,23 @@
# Qt accessibility module
contains(QT_CONFIG, accessibility) {
HEADERS += accessible/qaccessiblewidget.h
SOURCES += accessible/qaccessiblewidget.cpp
HEADERS += \
accessible/qaccessiblewidget.h \
accessible/qaccessiblewidgetfactory_p.h \
accessible/complexwidgets.h \
accessible/itemviews.h \
accessible/qaccessiblemenu.h \
accessible/qaccessiblewidgets.h \
accessible/rangecontrols.h \
accessible/simplewidgets.h
SOURCES += \
accessible/qaccessiblewidget.cpp \
accessible/qaccessiblewidgetfactory.cpp \
accessible/complexwidgets.cpp \
accessible/itemviews.cpp \
accessible/qaccessiblemenu.cpp \
accessible/qaccessiblewidgets.cpp \
accessible/rangecontrols.cpp \
accessible/simplewidgets.cpp
}

View File

@ -66,7 +66,7 @@
QT_BEGIN_NAMESPACE
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
QString qt_accStripAmp(const QString &text);
#ifndef QT_NO_TABBAR
/*!

View File

@ -51,7 +51,7 @@
QT_BEGIN_NAMESPACE
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
QString qt_accStripAmp(const QString &text);
#ifndef QT_NO_ITEMVIEWS
/*

View File

@ -52,8 +52,8 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_MENU
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
QString Q_GUI_EXPORT qt_accHotKey(const QString &text);
QString qt_accStripAmp(const QString &text);
QString qt_accHotKey(const QString &text);
QAccessibleInterface *getOrCreateMenu(QWidget *menu, QAction *action)
{

View File

@ -134,7 +134,7 @@ static int qt_accAmpIndex(const QString &text)
#endif
}
QString Q_WIDGETS_EXPORT qt_accStripAmp(const QString &text)
QString qt_accStripAmp(const QString &text)
{
QString newText(text);
int ampIndex = qt_accAmpIndex(newText);
@ -144,7 +144,7 @@ QString Q_WIDGETS_EXPORT qt_accStripAmp(const QString &text)
return newText.replace(QLatin1String("&&"), QLatin1String("&"));
}
QString Q_WIDGETS_EXPORT qt_accHotKey(const QString &text)
QString qt_accHotKey(const QString &text)
{
int ampIndex = qt_accAmpIndex(text);
if (ampIndex != -1)

View File

@ -46,8 +46,6 @@
#include "complexwidgets.h"
#include "itemviews.h"
#include <qaccessibleplugin.h>
#include <qplugin.h>
#include <qpushbutton.h>
#include <qtoolbutton.h>
#include <qtreeview.h>
@ -58,23 +56,7 @@
QT_BEGIN_NAMESPACE
class AccessibleFactory : public QAccessiblePlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QAccessibleFactoryInterface" FILE "widgets.json")
public:
AccessibleFactory();
QAccessibleInterface *create(const QString &classname, QObject *object);
};
AccessibleFactory::AccessibleFactory()
{
}
QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObject *object)
QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *object)
{
QAccessibleInterface *iface = 0;
if (!object || !object->isWidgetType())
@ -254,9 +236,6 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec
return iface;
}
QT_END_NAMESPACE
#include "main.moc"
#endif // QT_NO_ACCESSIBILITY

View File

@ -0,0 +1,53 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt 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 <QtGui/qaccessible.h>
#ifndef QACCESSIBLEWIDGETFACTORY_H
#define QACCESSIBLEWIDGETFACTORY_H
QT_BEGIN_NAMESPACE
QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *object);
QT_END_NAMESPACE
#endif

View File

@ -72,8 +72,7 @@
QT_BEGIN_NAMESPACE
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
QString Q_GUI_EXPORT qt_accHotKey(const QString &text);
QString qt_accStripAmp(const QString &text);
QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel)
{

View File

@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_ACCESSIBILITY
extern QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
QString qt_accStripAmp(const QString &text);
#ifndef QT_NO_SCROLLBAR
extern QStyleOptionSlider Q_GUI_EXPORT qt_qscrollbarStyleOption(QScrollBar *scrollBar);
#endif

View File

@ -71,8 +71,8 @@ QT_BEGIN_NAMESPACE
extern QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel = false);
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
QString Q_GUI_EXPORT qt_accHotKey(const QString &text);
QString qt_accStripAmp(const QString &text);
QString qt_accHotKey(const QString &text);
/*!
\class QAccessibleButton

View File

@ -77,6 +77,7 @@
#endif
#include "private/qkeymapper_p.h"
#include "private/qaccessiblewidgetfactory_p.h"
#include <qthread.h>
#include <private/qthread_p.h>
@ -557,6 +558,11 @@ void QApplicationPrivate::construct()
qt_gui_eval_init(application_type);
#endif
#ifndef QT_NO_ACCESSIBILITY
// factory for accessible interfaces for widgets shipped with Qt
QAccessible::installFactory(&qAccessibleFactory);
#endif
#ifndef QT_NO_LIBRARY
if(load_testability) {
QLibrary testLib(QLatin1String("qttestability"));

View File

@ -8,9 +8,6 @@ DEFINES += QT_NO_USING_NAMESPACE
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000
irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused
MODULE_PLUGIN_TYPES += \
accessible/libqtaccessiblewidgets.so
QMAKE_DOCS = $$PWD/doc/qtwidgets.qdocconf
load(qt_module)