summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-02-07 17:56:25 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-02-22 11:20:42 +0000
commit73e72f7b5f3dc9b08a18a2afc286576951b424b9 (patch)
tree23015726e820edf0505aa33b0517d0669420b271
parentb6d0d11916a0b1f1edc913aafd8220d3e0253482 (diff)
Replace accessibility private API usage with QQmlPropertyv5.11.0-beta1
Previously enabling accessibility for the QtQuick WebEngineView was done by calling QuickAccessibleAttached::qmlAttachedProperties() which is a private API call. Instead of that, set the Accessibility attached properties by using QQmlProperty. Task-number: QTBUG-63098 Change-Id: Ibc927c1fce121dee56d8a21af412056d98c82c4d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/webengine/api/qquickwebengineview.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 85681bfef..42121ceb2 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -89,9 +89,6 @@
#include <QTimer>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
-#ifndef QT_NO_ACCESSIBILITY
-#include <private/qquickaccessibleattached_p.h>
-#endif // QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
@@ -768,11 +765,6 @@ QQuickWebEngineView::QQuickWebEngineView(QQuickItem *parent)
d->q_ptr = this;
this->setActiveFocusOnTab(true);
this->setFlags(QQuickItem::ItemIsFocusScope | QQuickItem::ItemAcceptsDrops);
-
-#ifndef QT_NO_ACCESSIBILITY
- QQuickAccessibleAttached *accessible = QQuickAccessibleAttached::qmlAttachedProperties(this);
- accessible->setRole(QAccessible::Grouping);
-#endif // QT_NO_ACCESSIBILITY
}
QQuickWebEngineView::~QQuickWebEngineView()
@@ -1777,6 +1769,16 @@ void QQuickWebEngineViewPrivate::userScripts_clear(QQmlListProperty<QQuickWebEng
void QQuickWebEngineView::componentComplete()
{
QQuickItem::componentComplete();
+
+#ifndef QT_NO_ACCESSIBILITY
+ // Enable accessibility via a dynamic QQmlProperty, instead of using private API call
+ // QQuickAccessibleAttached::qmlAttachedProperties(this). The qmlContext is required, otherwise
+ // it is not possible to reference attached properties.
+ QQmlContext *qmlContext = QQmlEngine::contextForObject(this);
+ QQmlProperty role(this, QStringLiteral("Accessible.role"), qmlContext);
+ role.write(QAccessible::Grouping);
+#endif // QT_NO_ACCESSIBILITY
+
QTimer::singleShot(0, this, &QQuickWebEngineView::lazyInitialize);
}