diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-11-02 15:01:21 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-11-02 15:24:39 +0000 |
commit | b02a9febe602662d30f5e9b4169b461bbf2cbc0c (patch) | |
tree | ef571f2b82f0016671ad91d7cd9eb3d6b52beeb7 | |
parent | ee7151d5ab29ba812a93c1231ddc59c9129a7af0 (diff) |
SwipeView: fix accessibility support
Don't specify the role in QML, because using the Accessible attached
property creates a hard dependency to the accessibility feature (the
QML code won't run when QT_NO_ACCESSIBILITY is defined).
Change-Id: Ie540c915547fae94705873292368652e3608c9e7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/imports/controls/SwipeView.qml | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickswipeview.cpp | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickswipeview_p.h | 4 | ||||
-rw-r--r-- | tests/auto/accessibility/data/swipeview.qml | 4 | ||||
-rw-r--r-- | tests/auto/accessibility/tst_accessibility.cpp | 2 |
5 files changed, 16 insertions, 3 deletions
diff --git a/src/imports/controls/SwipeView.qml b/src/imports/controls/SwipeView.qml index 48147d86..c4e5a570 100644 --- a/src/imports/controls/SwipeView.qml +++ b/src/imports/controls/SwipeView.qml @@ -46,8 +46,6 @@ T.SwipeView { implicitHeight: Math.max(background ? background.implicitHeight : 0, contentItem.implicitHeight + topPadding + bottomPadding) - Accessible.role: Accessible.PageTabList - contentItem: ListView { model: control.contentModel currentIndex: control.currentIndex diff --git a/src/quicktemplates2/qquickswipeview.cpp b/src/quicktemplates2/qquickswipeview.cpp index 37115c0a..82d05fbe 100644 --- a/src/quicktemplates2/qquickswipeview.cpp +++ b/src/quicktemplates2/qquickswipeview.cpp @@ -146,6 +146,13 @@ void QQuickSwipeView::itemAdded(int, QQuickItem *item) item->setSize(QSizeF(d->contentItem->width(), d->contentItem->height())); } +#ifndef QT_NO_ACCESSIBILITY +QAccessible::Role QQuickSwipeView::accessibleRole() const +{ + return QAccessible::PageTabList; +} +#endif + /*! \qmlattachedproperty int QtQuick.Controls::SwipeView::index \readonly diff --git a/src/quicktemplates2/qquickswipeview_p.h b/src/quicktemplates2/qquickswipeview_p.h index 49d3b840..c6cb62ba 100644 --- a/src/quicktemplates2/qquickswipeview_p.h +++ b/src/quicktemplates2/qquickswipeview_p.h @@ -68,6 +68,10 @@ protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; void itemAdded(int index, QQuickItem *item) override; +#ifndef QT_NO_ACCESSIBILITY + QAccessible::Role accessibleRole() const override; +#endif + private: Q_DISABLE_COPY(QQuickSwipeView) Q_DECLARE_PRIVATE(QQuickSwipeView) diff --git a/tests/auto/accessibility/data/swipeview.qml b/tests/auto/accessibility/data/swipeview.qml new file mode 100644 index 00000000..018ab772 --- /dev/null +++ b/tests/auto/accessibility/data/swipeview.qml @@ -0,0 +1,4 @@ +import QtQuick 2.5 +import QtQuick.Controls 2.0 + +SwipeView { } diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp index bb2f9c0a..22aae1f2 100644 --- a/tests/auto/accessibility/tst_accessibility.cpp +++ b/tests/auto/accessibility/tst_accessibility.cpp @@ -87,6 +87,7 @@ void tst_accessibility::a11y_data() QTest::newRow("Slider") << "slider" << 0x00000033 << ""; //QAccessible::Slider QTest::newRow("SpinBox") << "spinbox" << 0x00000034 << ""; //QAccessible::SpinBox QTest::newRow("StackView") << "stackview" << 0x00000080 << ""; //QAccessible::LayeredPane + QTest::newRow("SwipeView") << "swipeview" << 0x0000003C << ""; //QAccessible::Pane QTest::newRow("Switch") << "switch" << 0x0000002B << "Switch"; //QAccessible::Button QTest::newRow("SwitchDelegate") << "switchdelegate" << 0x00000022 << "SwitchDelegate"; //QAccessible::ListItem QTest::newRow("TabBar") << "tabbar" << 0x0000003C << ""; //QAccessible::PageTabList @@ -99,7 +100,6 @@ void tst_accessibility::a11y_data() QTest::newRow("Dial") << "dial" << 0x00000031 << ""; //QAccessible::Dial // Drawer - // SwipeView // Tumbler QTest::newRow("DayOfWeekRow") << "dayofweekrow" << 0x0 << "DayOfWeekRow"; //QAccessible::NoRole |