Development/Tutorials/Accessibility/Screen Reader Setup

From KDE TechBase

QAccessible

QAccessible is the Qt Accessible framework. Each Qt/KDE application supports QAccessible out of the box.

You need to call "export QT_ACCESSIBILITY=1" before you start the application that should be made accessible. Once the application is started and QT_ACCESSIBILITY set, then the application will load all installed accessibility-plugins (such as the Qt AT-SPI and KAccessible plugins) to provide accessibility-services.

Qt AT-SPI

qt-at-spi is a QAccessibleBridgePlugin that bridges the QAccessible API’s to the AT-SPI 2 protocol enabling Qt applications to be used with Orca, Accerciser, and GOK.

For a brief overview of how atk/at-spi accessibility works on linux platforms, take a look at http://a11y.org/atspi.

Setup a test environment

In order to set up a test environment to help improve qt-at-spi (or at-spi itself) You'll need a few things. Orca can be installed from your distribution, as can accerciser, however accerciser will need to be run in a particular way to work with at-spi2 as I'll mention later. You'll also need at-spi2-core and at-spi2-atk to test gtk applications. You'll also need pyatspi2. The simplest way to get these is to clone them from the following git urls:

git://git.gnome.org/at-spi2-core
git://git.gnome.org/at-spi2-atk
git://git.gnome.org/pyatspi2

Then proceed to build them by running

./autogen.sh --disable-relocate
make
make install 
(or sudo make install if your user doesn't have write privileges to /usr/local)

How to test at-spi2 with gtk

Once these are installed, you can then test at-spi2 by running gcalctool with a few environment variables set. As mentioned on the at-spi dbus site under "Instructions for Testing" you'll need some environment variables set.

To switch to AT-SPI 2, you should set two gconf variables:

gconftool-2 --set /desktop/gnome/interface/at-spi-dbus --type bool true
gconftool-2 --set /desktop/gnome/interface/at-spi-corba --type bool false


I use a file called ~/.a11ybashrc with the following contents:

export GTK_PATH=/usr/local/lib/gtk-2.0/
export PYTHONPATH=/usr/local/lib/python2.6/site-packages/
export QT_ACCESSIBILITY=1
export GTK_MODULES=gail:atk-bridge

then I just source ~/.a11ybashrc to set up my shell for testing accessibility.

Then to test just run gcalctool with gcalctool & from that shell. You should see at-spi2-registryd in your process table once gcalctool has started. If not you are likely still using at-spi instead of at-spi2. You can use d-feet or qdbusviewer, or just qdbus to inspect the dbus interface of the registry and the accessible methods of the application at this point. You should also be able to run orca and hear the text of the calculator tool at this point.

How to test at-spi2 with Qt

Once you have a gtk app running correctly with orca and/or accerciser you are ready to try qt-at-spi. In order to do so, just clone the repo from

git://gitorious.org/qt-at-spi

Then run

qmake
make
make install

There is a handy calculator in qt-at-spi under the test folder that can be used to test qt's at-spi plugin with. Make sure QT_ACCESSIBILITY is set in your environment and run

test/test

from the source folder of qt-at-spi. You should see some console message about the bridge initializing. You'll also see the calculator's dbus path in the org.a11y.atspi.Registry GetChildren output.

KAccessible

kaccessible implements a QAccessibleBridgePlugin to provide accessibility services like focus tracking and a screenreader.

Once you called "export QT_ACCESSIBILITY=1" and then started the application that should be made accessible the kaccessible icon should display in the icon system tray. Once the kaccessible bridge was loaded it will register a dbus service.

This kaccessible dbus service is used by kmagnifier and the KWin's zooming plugin to enable focus tracking in a application.

You can enable the screenreader (that uses speech dispatcher for text-to-speech atm) by 1. starting speech.dispatcher with "/etc/init.d/speech-dispatcher start" and 2. right-clicking the icon system tray and have "enable screenreader" checked.


Yet another set of instructions for the same

1 Get Orca to work in general - just grab the gnome-orca package that should be in pretty much any distro and try it with some gtk app. Test that it reacts to focus changes. 2 Make sure it's using dbus. That means having libatspi 2.0 (package name may vary, see also the settings here: http://labs.qt.nokia.com/2011/08/23/accessibility-on-linux/) 3 Have Qt 4.8 and the qt-at-spi bridge. 4 export QT_ACCESSIBILITY=1 (this is needed for Qt 4, fixed in Qt 5) 5 Run the KDE/Qt application you want to test with the Qt version for which you have the bridge installed. (This works even with Qt built separately in the home directory and the bridge installed there.)