summaryrefslogtreecommitdiffstats
path: root/src/gui/accessible/qaccessible.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/accessible/qaccessible.cpp')
-rw-r--r--src/gui/accessible/qaccessible.cpp111
1 files changed, 91 insertions, 20 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 954c8564f0..7584e23f2e 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -97,6 +97,15 @@ QT_BEGIN_NAMESPACE
Accessibility, and the Unix/X11 AT-SPI standard. Other backends
can be supported using QAccessibleBridge.
+ In the Unix/X11 AT-SPI implementation, applications become accessible
+ when two conditions are met:
+ \list
+ \li org.a11y.Status.IsEnabled DBus property is true
+ \li org.a11y.Status.ScreenReaderEnabled DBus property is true
+ \endlist
+ An alternative to setting the DBus AT-SPI properties is to set
+ the QT_LINUX_ACCESSIBILITY_ALWAYS_ON environment variable.
+
In addition to QAccessible's static functions, Qt offers one
generic interface, QAccessibleInterface, that can be used to wrap
all widgets and objects (e.g., QPushButton). This single
@@ -167,7 +176,7 @@ QT_BEGIN_NAMESPACE
\value readOnly The object can usually be edited, but is explicitly set to read-only.
\value selectable The object is selectable.
\value selectableText The object has text which can be selected. This is different from selectable which refers to the object's children.
- \value selected The object is selected.
+ \value selected The object is selected, this is independent of text selection.
\value selfVoicing The object describes itself through speech or sound.
\value sizeable The object can be resized, e.g. top-level windows.
\value summaryElement The object summarizes the state of the window and should be treated with priority.
@@ -317,8 +326,8 @@ QT_BEGIN_NAMESPACE
\value Desktop The object represents the desktop or workspace.
\value Dial An object that represents a dial or knob.
\value Dialog A dialog box.
- \value Document A document window, usually in an MDI environment.
- \value EditableText Editable text
+ \value Document A document, for example in an office application.
+ \value EditableText Editable text such as a line or text edit.
\value Equation An object that represents a mathematical equation.
\value Graphic A graphic or picture, e.g. an icon.
\value Grip A grip that the user can drag to change the size of widgets.
@@ -335,6 +344,7 @@ QT_BEGIN_NAMESPACE
\value NoRole The object has no role. This usually indicates an invalid object.
\value PageTab A page tab that the user can select to switch to a different page in a dialog.
\value PageTabList A list of page tabs.
+ \value Paragraph A paragraph of text (usually found in documents).
\value Pane A generic container.
\value PopupMenu A menu which lists options that the user can select to perform an action.
\value ProgressBar The object displays the progress of an operation in progress.
@@ -344,6 +354,7 @@ QT_BEGIN_NAMESPACE
\value Row A row of cells, usually within a table.
\value RowHeader A header for a row of data.
\value ScrollBar A scroll bar, which allows the user to scroll the visible area.
+ \value Section A section (in a document).
\value Separator A separator that divides space into logical areas.
\value Slider A slider that allows the user to select a value within a given range.
\value Sound An object that represents a sound.
@@ -359,6 +370,7 @@ QT_BEGIN_NAMESPACE
\value Tree A list of items in a tree structure.
\value TreeItem An item in a tree structure.
\value UserRole The first value to be used for user defined roles.
+ \value WebDocument HTML document, usually in a browser.
\value Whitespace Blank space between other objects.
\value Window A top level window.
*/
@@ -453,9 +465,11 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
#endif
#endif
+// FIXME turn this into one global static struct
Q_GLOBAL_STATIC(QList<QAccessible::InterfaceFactory>, qAccessibleFactories)
typedef QHash<QString, QAccessiblePlugin*> QAccessiblePluginsHash;
-Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins);
+Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins)
+Q_GLOBAL_STATIC(QList<QAccessible::ActivationObserver *>, qAccessibleActivationObservers)
QAccessible::UpdateHandler QAccessible::updateHandler = 0;
QAccessible::RootObjectHandler QAccessible::rootObjectHandler = 0;
@@ -492,6 +506,7 @@ void QAccessible::cleanup()
static void qAccessibleCleanup()
{
+ qAccessibleActivationObservers()->clear();
qAccessibleFactories()->clear();
}
@@ -592,6 +607,44 @@ QAccessible::RootObjectHandler QAccessible::installRootObjectHandler(RootObjectH
}
/*!
+ \class QAccessible::ActivationObserver
+ \internal
+
+ Interface to listen to activation or deactivation of the accessibility framework.
+ \sa installActivationObserver()
+*/
+
+/*!
+ \internal
+
+ Install \a observer to get notified of activation or deactivation (global accessibility has been enabled or disabled).
+*/
+void QAccessible::installActivationObserver(QAccessible::ActivationObserver *observer)
+{
+ if (!observer)
+ return;
+
+ if (!cleanupAdded) {
+ qAddPostRoutine(qAccessibleCleanup);
+ cleanupAdded = true;
+ }
+ if (qAccessibleActivationObservers()->contains(observer))
+ return;
+ qAccessibleActivationObservers()->append(observer);
+}
+
+/*!
+ \internal
+
+ Remove an \a observer to no longer get notified of state changes.
+ \sa installActivationObserver()
+*/
+void QAccessible::removeActivationObserver(ActivationObserver *observer)
+{
+ qAccessibleActivationObservers()->removeAll(observer);
+}
+
+/*!
If a QAccessibleInterface implementation exists for the given \a object,
this function returns a pointer to the implementation; otherwise it
returns 0.
@@ -744,6 +797,15 @@ bool QAccessible::isActive()
return false;
}
+/*!
+ \internal
+*/
+void QAccessible::setActive(bool active)
+{
+ for (int i = 0; i < qAccessibleActivationObservers()->count() ;++i)
+ qAccessibleActivationObservers()->at(i)->accessibilityActiveChanged(active);
+}
+
/*!
Sets the root object of the accessible objects of this application
@@ -2060,7 +2122,6 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible::TextBoun
\class QAccessibleEditableTextInterface
\ingroup accessibility
\inmodule QtGui
- \internal
\brief The QAccessibleEditableTextInterface class implements support for objects with editable text.
@@ -2478,6 +2539,23 @@ struct QAccessibleActionStrings
const QString showMenuAction;
const QString setFocusAction;
const QString toggleAction;
+
+ QString localizedDescription(const QString &actionName)
+ {
+ if (actionName == pressAction)
+ return QAccessibleActionInterface::tr("Triggers the action");
+ else if (actionName == increaseAction)
+ return QAccessibleActionInterface::tr("Increase the value");
+ else if (actionName == decreaseAction)
+ return QAccessibleActionInterface::tr("Decrease the value");
+ else if (actionName == showMenuAction)
+ return QAccessibleActionInterface::tr("Shows the menu");
+ else if (actionName == setFocusAction)
+ return QAccessibleActionInterface::tr("Sets the focus");
+ else if (actionName == toggleAction)
+ return QAccessibleActionInterface::tr("Toggles the state");
+ return QString();
+ }
};
Q_GLOBAL_STATIC(QAccessibleActionStrings, accessibleActionStrings)
@@ -2489,21 +2567,7 @@ QString QAccessibleActionInterface::localizedActionName(const QString &actionNam
QString QAccessibleActionInterface::localizedActionDescription(const QString &actionName) const
{
- const QAccessibleActionStrings *strings = accessibleActionStrings();
- if (actionName == strings->pressAction)
- return tr("Triggers the action");
- else if (actionName == strings->increaseAction)
- return tr("Increase the value");
- else if (actionName == strings->decreaseAction)
- return tr("Decrease the value");
- else if (actionName == strings->showMenuAction)
- return tr("Shows the menu");
- else if (actionName == strings->setFocusAction)
- return tr("Sets the focus");
- else if (actionName == strings->toggleAction)
- return tr("Toggles the state");
-
- return QString();
+ return accessibleActionStrings()->localizedDescription(actionName);
}
/*!
@@ -2560,6 +2624,13 @@ const QString &QAccessibleActionInterface::toggleAction()
return accessibleActionStrings()->toggleAction;
}
+/*! \internal */
+QString qAccessibleLocalizedActionDescription(const QString &actionName)
+{
+ return accessibleActionStrings()->localizedDescription(actionName);
+}
+
+
#endif
QT_END_NAMESPACE