From d707acfc9e357ffc86feb5d9219372c30c5ff157 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 19 May 2014 12:28:32 +0200 Subject: Accessibility iOS This lays the foundation for iOS accessibility. The approach is slightly different from other a11y bridges in that we completely flaten the hierarchy of wigets/quick items to a list. This works well with VoiceOver since there are comparatively few elements. The cache implementation for OS X is re-used. With this patch VoiceOver on iOS works on many applications out of the box. For now it sends the screen changed notfification somewhat overzealous, that will need revisiting and potentially new API in QAccessible. Device orientation changes are not yet supported. [ChangeLog][iOS] Accessibility was added to the iOS platform port. This enables Qt applications to be read by VoiceOver on iOS devices. Task-number: QTBUG-39097 Change-Id: I441e844652d528cc2fdcc444f43b54ed6fa04f0c Reviewed-by: Richard Moe Gustavsen --- src/gui/accessible/qaccessiblecache.cpp | 2 +- src/gui/accessible/qaccessiblecache_mac.mm | 10 +++------- src/gui/accessible/qaccessiblecache_p.h | 14 ++++++++------ 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'src/gui') diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp index 09c155515e..96dde1ea3f 100644 --- a/src/gui/accessible/qaccessiblecache.cpp +++ b/src/gui/accessible/qaccessiblecache.cpp @@ -121,7 +121,7 @@ void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj) objectToId.remove(obj); delete iface; -#ifdef Q_OS_MACX +#ifdef Q_OS_MAC removeCocoaElement(id); #endif } diff --git a/src/gui/accessible/qaccessiblecache_mac.mm b/src/gui/accessible/qaccessiblecache_mac.mm index 861423af7d..bc6d0712d6 100644 --- a/src/gui/accessible/qaccessiblecache_mac.mm +++ b/src/gui/accessible/qaccessiblecache_mac.mm @@ -41,27 +41,23 @@ #include "qaccessiblecache_p.h" -#ifdef Q_OS_OSX - QT_BEGIN_NAMESPACE -void QAccessibleCache::insertElement(QAccessible::Id axid, QCocoaAccessibleElement *element) const +void QAccessibleCache::insertElement(QAccessible::Id axid, QMacAccessibilityElement *element) const { cocoaElements[axid] = element; } void QAccessibleCache::removeCocoaElement(QAccessible::Id axid) { - QCocoaAccessibleElement *element = elementForId(axid); + QMacAccessibilityElement *element = elementForId(axid); [element invalidate]; cocoaElements.remove(axid); } -QCocoaAccessibleElement *QAccessibleCache::elementForId(QAccessible::Id axid) const +QMacAccessibilityElement *QAccessibleCache::elementForId(QAccessible::Id axid) const { return cocoaElements.value(axid); } QT_END_NAMESPACE - -#endif diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h index 30b023cfbd..3ca62709b1 100644 --- a/src/gui/accessible/qaccessiblecache_p.h +++ b/src/gui/accessible/qaccessiblecache_p.h @@ -59,7 +59,9 @@ #include "qaccessible.h" -Q_FORWARD_DECLARE_OBJC_CLASS(QCocoaAccessibleElement); +#ifdef Q_OS_MAC + Q_FORWARD_DECLARE_OBJC_CLASS(QMacAccessibilityElement); +#endif QT_BEGIN_NAMESPACE @@ -73,9 +75,9 @@ public: QAccessible::Id insert(QObject *object, QAccessibleInterface *iface) const; void deleteInterface(QAccessible::Id id, QObject *obj = 0); -#ifdef Q_OS_OSX - QCocoaAccessibleElement *elementForId(QAccessible::Id axid) const; - void insertElement(QAccessible::Id axid, QCocoaAccessibleElement *element) const; +#ifdef Q_OS_MAC + QMacAccessibilityElement *elementForId(QAccessible::Id axid) const; + void insertElement(QAccessible::Id axid, QMacAccessibilityElement *element) const; #endif private Q_SLOTS: @@ -87,9 +89,9 @@ private: mutable QHash idToInterface; mutable QHash objectToId; -#ifdef Q_OS_OSX +#ifdef Q_OS_MAC void removeCocoaElement(QAccessible::Id axid); - mutable QHash cocoaElements; + mutable QHash cocoaElements; #endif friend class QAccessible; -- cgit v1.2.3