aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitem.cpp
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2011-12-07 07:48:22 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-02 15:33:52 +0100
commit27a497b3a7581a0cd76407635afca91d1f42aeef (patch)
treee4b65e5dcfc9a5be6053c24ec06d56fb82fe4c0d /src/quick/items/qquickitem.cpp
parent017a82c6702768aed68c34f319fa14da591f3df2 (diff)
Add accessibility to qml
This consists of two parts: An attached property for QML items and a plugin for the accessibility framework. The attached property simply takes care of some properties (name, role) that are needed in order to expose semantics of the application to assistive tools. The plugin exposes the hierarchy of QML items to the accessibility framework. Change-Id: I32f5603d0d9549b01b3645b205b710b9801762f7 Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r--src/quick/items/qquickitem.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index c95ae1a9c3..e9dc737e8a 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -66,6 +66,7 @@
#include <private/qlistmodelinterface_p.h>
#include <private/qquickitem_p.h>
#include <private/qdeclarativeaccessors_p.h>
+#include <QtQuick/private/qquickaccessibleattached_p.h>
#include <float.h>
@@ -1603,6 +1604,22 @@ void QQuickItemPrivate::setLayoutMirror(bool mirror)
}
}
+void QQuickItemPrivate::setAccessibleFlagAndListener()
+{
+ Q_Q(QQuickItem);
+ QQuickItem *item = q;
+ while (item) {
+ if (item->d_func()->isAccessible)
+ break; // already set - grandparents should have the flag set as well.
+
+ if (item->canvas() && item->canvas()->rootItem() == item)
+ break; // don't add a listener to the canvas root item
+
+ item->d_func()->isAccessible = true;
+ item = item->d_func()->parentItem;
+ }
+}
+
/*!
\class QQuickItem
\brief The QQuickItem class provides the most basic of all visual items in QML.
@@ -1804,6 +1821,7 @@ QQuickItem::~QQuickItem()
if (change.types & QQuickItemPrivate::Destroyed)
change.listener->itemDestroyed(this);
}
+
d->changeListeners.clear();
delete d->_anchorLines; d->_anchorLines = 0;
delete d->_anchors; d->_anchors = 0;
@@ -1913,6 +1931,10 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
d->itemChange(ItemParentHasChanged, d->parentItem);
d->parentNotifier.notify();
+ if (d->isAccessible && d->parentItem) {
+ d->parentItem->d_func()->setAccessibleFlagAndListener();
+ }
+
emit parentChanged(d->parentItem);
}
@@ -2251,6 +2273,7 @@ QQuickItemPrivate::QQuickItemPrivate()
inheritedLayoutMirror(false), effectiveLayoutMirror(false), isMirrorImplicit(true),
inheritMirrorFromParent(false), inheritMirrorFromItem(false), childrenDoNotOverlap(false),
staticSubtreeGeometry(false),
+ isAccessible(false),
canvas(0), parentItem(0), sortedChildItems(&childItems),
@@ -2886,6 +2909,11 @@ void QQuickItem::updatePolish()
{
}
+void QQuickItem::sendAccessibilityUpdate()
+{
+ Q_D(QQuickItem);
+}
+
void QQuickItemPrivate::removeItemChangeListener(QQuickItemChangeListener *listener, ChangeTypes types)
{
ChangeListener change(listener, types);
@@ -2931,6 +2959,7 @@ void QQuickItem::inputMethodEvent(QInputMethodEvent *event)
void QQuickItem::focusInEvent(QFocusEvent *)
{
+ QAccessible::updateAccessibility(this, 0, QAccessible::Focus);
}
void QQuickItem::focusOutEvent(QFocusEvent *)
@@ -3895,6 +3924,9 @@ void QQuickItemPrivate::setEffectiveVisibleRecur(bool newEffectiveVisible)
change.listener->itemVisibilityChanged(q);
}
+ if (isAccessible)
+ QAccessible::updateAccessibility(q, 0, effectiveVisible ? QAccessible::ObjectShow : QAccessible::ObjectHide );
+
emit q->visibleChanged();
}