From 27a497b3a7581a0cd76407635afca91d1f42aeef Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 7 Dec 2011 07:48:22 +0100 Subject: Add accessibility to qml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This consists of two parts: An attached property for QML items and a plugin for the accessibility framework. The attached property simply takes care of some properties (name, role) that are needed in order to expose semantics of the application to assistive tools. The plugin exposes the hierarchy of QML items to the accessibility framework. Change-Id: I32f5603d0d9549b01b3645b205b710b9801762f7 Reviewed-by: Jan-Arve Sæther --- tests/manual/accessibility/animation.qml | 135 +++++++++++++++++ tests/manual/accessibility/behavior.qml | 67 +++++++++ tests/manual/accessibility/flickable.qml | 53 +++++++ tests/manual/accessibility/hittest.qml | 165 +++++++++++++++++++++ tests/manual/accessibility/numberanimation.qml | 76 ++++++++++ tests/manual/accessibility/qmltestfiles.qmlproject | 16 ++ tests/manual/accessibility/textandbuttons.qml | 94 ++++++++++++ tests/manual/accessibility/transition.qml | 73 +++++++++ 8 files changed, 679 insertions(+) create mode 100644 tests/manual/accessibility/animation.qml create mode 100644 tests/manual/accessibility/behavior.qml create mode 100644 tests/manual/accessibility/flickable.qml create mode 100644 tests/manual/accessibility/hittest.qml create mode 100644 tests/manual/accessibility/numberanimation.qml create mode 100644 tests/manual/accessibility/qmltestfiles.qmlproject create mode 100644 tests/manual/accessibility/textandbuttons.qml create mode 100644 tests/manual/accessibility/transition.qml (limited to 'tests/manual/accessibility') diff --git a/tests/manual/accessibility/animation.qml b/tests/manual/accessibility/animation.qml new file mode 100644 index 0000000000..21e0072466 --- /dev/null +++ b/tests/manual/accessibility/animation.qml @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: scene + width: 800; height: 600 + + Rectangle { + id: behavior + x : 50 + y : 100 + width: 100; height: 100 + color: "red" + + Text { + text : "Behavior" + } + + Behavior on x { + NumberAnimation { duration: 1000 } + } + + MouseArea { + anchors.fill: parent + onClicked: behavior.x += 50 + } + } + + Rectangle { + id: transition + x : 400 + y : 100 + width: 100; height: 100 + color: "red" + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + Text { + text : "Transition" + } + + states: State { + name: "moved"; when: mouseArea.pressed + PropertyChanges { target: transition; x: 500; y: 200 } + } + + transitions: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 1000 } + } + } + + Rectangle { + id : animatee + width: 100; height: 100 + x : 50 + y : 300 + color: "blue" + opacity: 0.5 + Text { + anchors.centerIn: parent + text : "NumberAnimation" + } + + MouseArea { + anchors.fill: parent + onClicked: { + animatePosition.start() + } + } + + NumberAnimation { + id: animatePosition + target: animatee + properties: "x" + from: animatee.x + to: animatee.x + 50 + loops: 1 + easing {type: Easing.Linear;} + } + } + + ListView { + id : content + x : 400 + y : 300 + width: 300 + height: 200 + + model : 200 + delegate : Text { text : "Flickable" + index; height : 50 } + } +} diff --git a/tests/manual/accessibility/behavior.qml b/tests/manual/accessibility/behavior.qml new file mode 100644 index 0000000000..889b88029b --- /dev/null +++ b/tests/manual/accessibility/behavior.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: scene + width: 400; height: 400 + + Rectangle { + id: rect + y : 100 + width: 100; height: 100 + color: "red" + + Text { + text : "Behavior animation" + } + + Behavior on x { + NumberAnimation { duration: 1000 } + } + + MouseArea { + anchors.fill: parent + onClicked: rect.x += 50 + } + } + } diff --git a/tests/manual/accessibility/flickable.qml b/tests/manual/accessibility/flickable.qml new file mode 100644 index 0000000000..741777a18c --- /dev/null +++ b/tests/manual/accessibility/flickable.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + + + ListView { + id : content + width: 300 + height: 200 +// KeyNavigation.up: gridMenu; KeyNavigation.left: contextMenu; KeyNavigation.right: list2 + + model : 200 + delegate : Text { text : "foo" + index; height : 50 } + } diff --git a/tests/manual/accessibility/hittest.qml b/tests/manual/accessibility/hittest.qml new file mode 100644 index 0000000000..522ed649b3 --- /dev/null +++ b/tests/manual/accessibility/hittest.qml @@ -0,0 +1,165 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + + +import QtQuick 2.0 +Rectangle { + id: page + width: 640 + height: 480 + color: "white" + Rectangle { + id: header + color: "#c0c0c0" + height: usage.height + chkClip.height + anchors.left: parent.left + anchors.right: parent.right + Text { + id: usage + text: "Use an a11y inspect tool to see if all visible rectangles can be found with hit testing." + } + Rectangle { + id: chkClip + property bool checked: true + + color: (checked ? "#f0f0f0" : "#c0c0c0") + height: label.height + width: label.width + anchors.left: parent.left + anchors.bottom: parent.bottom + + MouseArea { + anchors.fill: parent + onClicked: chkClip.checked = !chkClip.checked + } + Text { + id: label + text: "Click here to toggle clipping" + } + } + } + Rectangle { + clip: chkClip.checked + z: 2 + Accessible.role: Accessible.Button + id: rect1 + width: 100 + height: 100 + color: "#ffc0c0" + anchors.top: header.bottom + Rectangle { + id: rect2 + width: 100 + height: 100 + x: 50 + y: 50 + color: "#ffa0a0" + Rectangle { + id: rect31 + width: 100 + height: 100 + x: 80 + y: 80 + color: "#ff8080" + } + Rectangle { + id: rect32 + x: 100 + y: 70 + z: 3 + width: 100 + height: 100 + color: "#e06060" + } + Rectangle { + id: rect33 + width: 100 + height: 100 + x: 150 + y: 60 + color: "#c04040" + } + } + } + + Rectangle { + x: 0 + y: 50 + id: recta1 + width: 100 + height: 100 + color: "#c0c0ff" + Rectangle { + id: recta2 + width: 100 + height: 100 + x: 50 + y: 50 + color: "#a0a0ff" + Rectangle { + id: recta31 + width: 100 + height: 100 + x: 80 + y: 80 + color: "#8080ff" + } + Rectangle { + id: recta32 + x: 100 + y: 70 + z: 100 + width: 100 + height: 100 + color: "#6060e0" + } + Rectangle { + id: recta33 + width: 100 + height: 100 + x: 150 + y: 60 + color: "#4040c0" + } + } + } + +} diff --git a/tests/manual/accessibility/numberanimation.qml b/tests/manual/accessibility/numberanimation.qml new file mode 100644 index 0000000000..425491bcd5 --- /dev/null +++ b/tests/manual/accessibility/numberanimation.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: flashingblob + width: 300; height: 300 + + MouseArea { + anchors.fill: parent + onClicked: { + animatePosition.start() + } + } + + Rectangle { + id : animatee + width: 100; height: 100 + y : 100 + color: "blue" + opacity: 0.5 + Text { + anchors.centerIn: parent + text : "Be Well" + } + } + + NumberAnimation { + id: animatePosition + target: animatee + properties: "x" + from: animatee.x + to: animatee.x + 50 + loops: 1 + easing {type: Easing.Linear;} + } +} diff --git a/tests/manual/accessibility/qmltestfiles.qmlproject b/tests/manual/accessibility/qmltestfiles.qmlproject new file mode 100644 index 0000000000..9062c6a412 --- /dev/null +++ b/tests/manual/accessibility/qmltestfiles.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.0 + +Project { + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } + /* List of plugin directories passed to QML runtime */ + // importPaths: [ "../exampleplugin" ] +} diff --git a/tests/manual/accessibility/textandbuttons.qml b/tests/manual/accessibility/textandbuttons.qml new file mode 100644 index 0000000000..c646275815 --- /dev/null +++ b/tests/manual/accessibility/textandbuttons.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id : rect + width: 300 + height: 200 + + Rectangle { + width : 200 + height : 20 + + id: button + anchors.top : rect.top + anchors.topMargin: 30 + property string text : "Click to activate" + property int counter : 0 + + Accessible.role : Accessible.Button + + function accessibleAction(action) { + if (action == Qt.Press) + buttonAction() + } + + function buttonAction() { + ++counter + text = "clicked " + counter + + text2.x += 20 + } + + Text { + id : text1 + anchors.fill: parent + text : parent.text + } + + MouseArea { + id : mouseArea + anchors.fill: parent + onClicked: parent.buttonAction() + } + } + + Text { + id : text2 + anchors.top: button.bottom + anchors.topMargin: 50 + text : "Hello World " + x + + Behavior on x { PropertyAnimation { duration: 500 } } + } +} diff --git a/tests/manual/accessibility/transition.qml b/tests/manual/accessibility/transition.qml new file mode 100644 index 0000000000..640b00663e --- /dev/null +++ b/tests/manual/accessibility/transition.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 + +Rectangle { + id: scene + width: 300; height: 300 + + Rectangle { + id: rect + x : 100 + y : 100 + width: 100; height: 100 + color: "red" + + MouseArea { + id: mouseArea + anchors.fill: parent + } + + Text { + text : "Transition" + } + + states: State { + name: "moved"; when: mouseArea.pressed + PropertyChanges { target: rect; x: 150; y: 150 } + } + + transitions: Transition { + NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad; duration: 1000 } + } + } +} -- cgit v1.2.3