From f484c7ff9868e5e5e090da43f12774ac4295ab47 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Thu, 24 Mar 2011 13:15:00 +0100 Subject: Doc: Work on a11y docs Task-number: QTBUG-8078 --- doc/src/frameworks-technologies/accessible.qdoc | 57 +++++++++++++----------- doc/src/snippets/accessibilityfactorysnippet.cpp | 5 +-- doc/src/snippets/accessibilitypluginsnippet.cpp | 6 +-- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/doc/src/frameworks-technologies/accessible.qdoc b/doc/src/frameworks-technologies/accessible.qdoc index e7bf171..3f63353 100644 --- a/doc/src/frameworks-technologies/accessible.qdoc +++ b/doc/src/frameworks-technologies/accessible.qdoc @@ -52,12 +52,12 @@ An application does not usually communicate directly with assistive tools but through an assistive technology, which is a bridge for exchange of information between the applications and - the tools. Information about user interface elements, such - as buttons and scroll bars, is exposed to the assistive technologies. - Qt supports Microsoft Active Accessibility (MSAA) on Windows and - Mac OS X Accessibility on Mac OS X. - On Unix/X11, support is preliminary. The individual technologies - are abstracted from Qt, and there is only a single interface to + the tools. Information about user interface elements, such as + buttons and scroll bars, is exposed to the assistive technologies. + Qt supports Microsoft Active Accessibility (MSAA) on Windows, Mac + OS X Accessibility on Mac OS X, and AT-SPI on Unix/X11. On + Unix/X11, support is preliminary. The individual technologies are + abstracted from Qt, and there is only a single interface to consider. We will use MSAA throughout this document when we need to address technology related issues. @@ -333,10 +333,16 @@ \section2 QAccessibleWidget Example Instead of creating a custom widget and implementing an interface - for it, we will show how accessibility can be implemented for one of - Qt's standard widgets: QSlider. Making this widget accessible - demonstrates many of the issues that need to be faced when making - a custom widget accessible. + for it, we will show how accessibility is implemented for one of + Qt's standard widgets: QSlider. The accessible interface, + QAccessibleSlider, inherits from QAccessibleAbstractSlider, which + in turn inherits QAccessibleWidget. You do not need to examine the + QAccessibleAbstractSlider class to read this section. If you want + to take a look, the code for all of Qt's accessible interfaces are + found in src/plugins/accessible/widgets. Here is the + QAccessibleSlider's constructor: + + \snippet doc/src/snippets/accessibilityslidersnippet.cpp 0 The slider is a complex control that functions as a \l{QAccessible::}{Controller} for its accessible children. @@ -346,8 +352,6 @@ using a controlling signal, which is a mechanism provided by QAccessibleWidget. We do this in the constructor: - \snippet doc/src/snippets/accessibilityslidersnippet.cpp 0 - The choice of signal shown is not important; the same principles apply to all signals that are declared in this way. Note that we use QLatin1String to ensure that the signal name is correctly @@ -507,10 +511,10 @@ plugin template, and the library containing the plugin must be placed on a path where Qt searches for accessible plugins. - We will go through the implementation of \c SliderPlugin, which is an - accessible plugin that produces interfaces for the - QAccessibleSlider we implemented in the \l{QAccessibleWidget Example}. - We start with the \c key() function: + We will go through the implementation of \c SliderPlugin, which is + an accessible plugin that produces the QAccessibleSlider interface + from the \l{QAccessibleWidget Example}. We start with the \c key() + function: \snippet doc/src/snippets/accessibilitypluginsnippet.cpp 0 @@ -521,13 +525,12 @@ \snippet doc/src/snippets/accessibilitypluginsnippet.cpp 1 - We check whether the interface requested is for the QSlider; if it - is, we create and return an interface for it. Note that \c object - will always be an instance of \c classname. You must return 0 if - you do not support the class. - \l{QAccessible::}{updateAccessibility()} checks with the - available accessibility plugins until it finds one that does not - return 0. + We check whether the interface requested is for QSlider; if it is, + we create and return an interface for it. Note that \c object will + always be an instance of \c classname. You must return 0 if you do + not support the class. \l{QAccessible::}{updateAccessibility()} + checks with the available accessibility plugins until it finds one + that does not return 0. Finally, you need to include macros in the cpp file: @@ -536,9 +539,9 @@ The Q_EXPORT_PLUGIN2 macro exports the plugin in the \c SliderPlugin class into the \c acc_sliderplugin library. The first argument is the name of the plugin library file, excluding the - file suffix, and the second is the class name. For more information - on plugins, consult the plugins \l{How to Create Qt - Plugins}{overview document}. + file suffix, and the second is the class name. For more + information on plugins, you can consult the plugins \l{How to + Create Qt Plugins}{overview document}. You can omit the first macro unless you want the plugin to be statically linked with the application. @@ -555,7 +558,7 @@ \l{QAccessiblePlugin::}{create()} - a QString and a QObject. It also works the same way. You install the factory with the \l{QAccessible::}{installFactory()} function. We give an example - of how to create a factory for the \c SliderPlugin class: + of how to create a factory for the \c QAccessibleSlider interface: \snippet doc/src/snippets/accessibilityfactorysnippet.cpp 0 \dots diff --git a/doc/src/snippets/accessibilityfactorysnippet.cpp b/doc/src/snippets/accessibilityfactorysnippet.cpp index a378db7..6dc6b2a 100644 --- a/doc/src/snippets/accessibilityfactorysnippet.cpp +++ b/doc/src/snippets/accessibilityfactorysnippet.cpp @@ -45,9 +45,8 @@ QAccessibleInterface *sliderFactory(const QString &classname, QObject *object) { QAccessibleInterface *interface = 0; - if (classname == "QSlider" && object && object->isWidgetType()) - interface = new SliderInterface(classname, - static_cast(object)); + if (classname == QLatin1String("QSlider") && object && object->isWidgetType()) + interface = new QAccessibleSlider(static_cast(object)); return interface; } diff --git a/doc/src/snippets/accessibilitypluginsnippet.cpp b/doc/src/snippets/accessibilitypluginsnippet.cpp index a7e25f0..5c28468 100644 --- a/doc/src/snippets/accessibilitypluginsnippet.cpp +++ b/doc/src/snippets/accessibilitypluginsnippet.cpp @@ -52,7 +52,7 @@ public: //! [0] QStringList SliderPlugin::keys() const { - return QStringList() << "QSlider"; + return QStringList() << QLatin1String("QSlider"); } //! [0] @@ -61,8 +61,8 @@ QAccessibleInterface *SliderPlugin::create(const QString &classname, QObject *ob { QAccessibleInterface *interface = 0; - if (classname == "QSlider" && object && object->isWidgetType()) - interface = new AccessibleSlider(classname, static_cast(object)); + if (classname == QLatin1String("QSlider") && object && object->isWidgetType()) + interface = new QAccessibleSlider(static_cast(object)); return interface; } -- cgit v0.12