diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-20 14:26:47 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-11-20 17:23:42 +0000 |
commit | 67398f037ebf9b36b88e870998eea5918832db2c (patch) | |
tree | 5e16e2d1dca676dc865aafe04bdc1c86e92d929a | |
parent | 6ca831b18f361924cab39b65d1a1e8b31e60b3fc (diff) |
Fix accessibility initialization
If accessibility is already enabled at construction time, QQuickControl
does not get a notification of accessibility activation change. This
patch fixes the issue that the attached property object was not created
at all, by calling accessibilityActiveChange(true) when appropriate at
component completion.
Change-Id: I5d763d66c97a540687b217b8ae453d073f6bfdb4
Task-number: QTBUG-49361
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
-rw-r--r-- | src/templates/qquickcontrol.cpp | 10 | ||||
-rw-r--r-- | src/templates/qquickcontrol_p.h | 1 | ||||
-rw-r--r-- | tests/auto/accessibility/tst_accessibility.cpp | 10 |
3 files changed, 18 insertions, 3 deletions
diff --git a/src/templates/qquickcontrol.cpp b/src/templates/qquickcontrol.cpp index c8b5287b..5f5e105e 100644 --- a/src/templates/qquickcontrol.cpp +++ b/src/templates/qquickcontrol.cpp @@ -700,6 +700,16 @@ void QQuickControl::setContentItem(QQuickItem *item) } } +void QQuickControl::componentComplete() +{ + Q_D(QQuickControl); + QQuickItem::componentComplete(); +#ifndef QT_NO_ACCESSIBILITY + if (!d->accessibleAttached && QAccessible::isActive()) + accessibilityActiveChanged(true); +#endif +} + void QQuickControl::mousePressEvent(QMouseEvent *event) { event->accept(); diff --git a/src/templates/qquickcontrol_p.h b/src/templates/qquickcontrol_p.h index d5024bae..82b91343 100644 --- a/src/templates/qquickcontrol_p.h +++ b/src/templates/qquickcontrol_p.h @@ -138,6 +138,7 @@ Q_SIGNALS: protected: QQuickControl(QQuickControlPrivate &dd, QQuickItem *parent); + void componentComplete() Q_DECL_OVERRIDE; void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE; void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp index a9e04d59..866d3b13 100644 --- a/tests/auto/accessibility/tst_accessibility.cpp +++ b/tests/auto/accessibility/tst_accessibility.cpp @@ -135,9 +135,13 @@ void tst_accessibility::a11y() if (name != QLatin1Literal("dayofweekrow") && name != QLatin1Literal("monthgrid") && name != QLatin1Literal("weeknumbercolumn")) { - QVERIFY(!acc); - QAccessible::setActive(true); - acc = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(item, false)); + if (QAccessible::isActive()) { + QVERIFY(acc); + } else { + QVERIFY(!acc); + QAccessible::setActive(true); + acc = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(item, false)); + } } QVERIFY(acc); QCOMPARE(acc->role(), (QAccessible::Role)role); |