diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-03-25 18:07:17 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-19 17:52:45 +0200 |
commit | 0d57da067b47eac51ea725d267069d6e616cf586 (patch) | |
tree | 2af737bd8e8ea2063a485e9f66471a457d5eab3f /src/gui | |
parent | c2059ac80db30d0322f53bf0c224263a934c49bc (diff) |
Let platform plugin decide if accessibility is active
Change-Id: I881a8ff3fedf3db73ee37046a4363c70960a92a6
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/accessible/qaccessible.cpp | 21 | ||||
-rw-r--r-- | src/gui/accessible/qplatformaccessibility.cpp | 1 | ||||
-rw-r--r-- | src/gui/accessible/qplatformaccessibility.h | 5 |
3 files changed, 19 insertions, 8 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 4fd595ed5a..18157f8e2f 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -441,7 +441,6 @@ Q_GLOBAL_STATIC(QAccessiblePluginsHash, qAccessiblePlugins); QAccessible::UpdateHandler QAccessible::updateHandler = 0; QAccessible::RootObjectHandler QAccessible::rootObjectHandler = 0; -static bool accessibility_active = false; static bool cleanupAdded = false; #ifndef QT_NO_ACCESSIBILITY @@ -584,7 +583,6 @@ Q_GLOBAL_STATIC(QAccessibleCache, qAccessibleCache) */ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) { - accessibility_active = true; if (!object) return 0; @@ -699,19 +697,26 @@ QAccessibleInterface *QAccessible::accessibleInterface(Id id) /*! - Returns true if an accessibility implementation has been requested - during the runtime of the application; otherwise returns false. + Returns true if the platform requested accessibility information. - Use this function to prevent potentially expensive notifications via - updateAccessibility(). + This function will return false until a tool such as a screen reader + accessed the accessibility framework. It is still possible to use + \l QAccessible::queryAccessibleInterface even if accessibility is not + active. But there will be no notifications sent to the platform. + + It is recommended to use this function to prevent expensive notifications + via updateAccessibility() when they are not needed. */ bool QAccessible::isActive() { - return accessibility_active; +#ifndef QT_NO_ACCESSIBILITY + if (QPlatformAccessibility *pfAccessibility = platformAccessibility()) + return pfAccessibility->isActive(); +#endif + return false; } - /*! Sets the root object of the accessible objects of this application to \a object. All other accessible objects are reachable using object diff --git a/src/gui/accessible/qplatformaccessibility.cpp b/src/gui/accessible/qplatformaccessibility.cpp index 2e36e5ac71..490fb7a407 100644 --- a/src/gui/accessible/qplatformaccessibility.cpp +++ b/src/gui/accessible/qplatformaccessibility.cpp @@ -73,6 +73,7 @@ Q_GLOBAL_STATIC(QVector<QAccessibleBridge *>, bridges) \sa QAccessible */ QPlatformAccessibility::QPlatformAccessibility() + : m_active(false) { } diff --git a/src/gui/accessible/qplatformaccessibility.h b/src/gui/accessible/qplatformaccessibility.h index 26a22e492d..f86a9b6157 100644 --- a/src/gui/accessible/qplatformaccessibility.h +++ b/src/gui/accessible/qplatformaccessibility.h @@ -69,6 +69,11 @@ public: virtual void initialize(); virtual void cleanup(); + inline bool isActive() const { return m_active; } + inline void setActive(bool active) { m_active = active; } + +private: + bool m_active; }; QT_END_NAMESPACE |