aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/quick-accessibility
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@digia.com>2013-08-12 17:53:40 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-13 14:52:27 +0200
commit6cd8b6830039aea7f748527882942752f900cefd (patch)
tree6151f16615fedc72030b370b3f8e421a10f9ee4a /examples/quick/quick-accessibility
parentf0e285381800c0809e5bfd3a4871a2283ea10fb9 (diff)
Doc: Renamed accessibility example to "quick-accessibility".
-Generated HTML file name conflicted with accessibility group. Task-number: QTBUG-32580 Change-Id: I5f5a4bb8134268c58105ea61d5ae3bbdd35c0d50 Reviewed-by: Martin Smith <martin.smith@digia.com>
Diffstat (limited to 'examples/quick/quick-accessibility')
-rw-r--r--examples/quick/quick-accessibility/accessibility.qml152
-rw-r--r--examples/quick/quick-accessibility/accessibility.qmlproject16
-rw-r--r--examples/quick/quick-accessibility/accessibility.qrc8
-rw-r--r--examples/quick/quick-accessibility/content/Button.qml88
-rw-r--r--examples/quick/quick-accessibility/content/Checkbox.qml82
-rw-r--r--examples/quick/quick-accessibility/content/Slider.qml90
-rw-r--r--examples/quick/quick-accessibility/doc/src/accessibility.qdoc40
-rw-r--r--examples/quick/quick-accessibility/main.cpp41
-rw-r--r--examples/quick/quick-accessibility/quick-accessibility.pro8
9 files changed, 525 insertions, 0 deletions
diff --git a/examples/quick/quick-accessibility/accessibility.qml b/examples/quick/quick-accessibility/accessibility.qml
new file mode 100644
index 0000000000..6fb25e37d7
--- /dev/null
+++ b/examples/quick/quick-accessibility/accessibility.qml
@@ -0,0 +1,152 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "content"
+
+Rectangle {
+ id: window
+
+ width: 320; height: 480
+ color: "white"
+
+ Column {
+ id: column
+ spacing: 6
+ anchors.fill: parent
+ anchors.margins: 10
+ width: parent.width
+
+ Row {
+ spacing: 6
+ width: column.width
+
+ Text {
+ id: subjectLabel
+ //! [text]
+ Accessible.role: Accessible.StaticText
+ Accessible.name: text
+ //! [text]
+ text: "Subject:"
+ y: 3
+ }
+
+ Rectangle {
+ id: subjectBorder
+ Accessible.role: Accessible.EditableText
+ Accessible.name: subjectEdit.text
+ border.width: 1
+ border.color: "black"
+ height: subjectEdit.height + 6
+ width: 240
+ TextInput {
+ focus: true
+ y: 3
+ x: 3
+ width: parent.width - 6
+ id: subjectEdit
+ text: "Vacation plans"
+ KeyNavigation.tab: textEdit
+ }
+ }
+ }
+
+ Rectangle {
+ id: textBorder
+ Accessible.role: Accessible.EditableText
+ property alias text: textEdit.text
+ border.width: 1
+ border.color: "black"
+ width: parent.width - 2
+ height: 200
+
+ TextEdit {
+ id: textEdit
+ y: 3
+ x: 3
+ width: parent.width - 6
+ height: parent.height - 6
+ text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nBest wishes, your friend Luke"
+ wrapMode: TextEdit.WordWrap
+ KeyNavigation.tab: sendButton
+ KeyNavigation.priority: KeyNavigation.BeforeItem
+ }
+ }
+
+ Text {
+ id : status
+ width: column.width
+ }
+
+ Row {
+ spacing: 6
+ Button {
+ id: sendButton
+ width: 100; height: 20
+ text: "Send"
+ onClicked: { status.text = "Send" }
+ KeyNavigation.tab: discardButton
+ }
+ Button { id: discardButton
+ width: 100; height: 20
+ text: "Discard"
+ onClicked: { status.text = "Discard" }
+ KeyNavigation.tab: checkBox
+ }
+ }
+
+ Row {
+ spacing: 6
+
+ Checkbox {
+ id: checkBox
+ checked: false
+ KeyNavigation.tab: slider
+ }
+
+ Slider {
+ id: slider
+ value: 10
+ KeyNavigation.tab: subjectEdit
+ }
+ }
+ }
+}
diff --git a/examples/quick/quick-accessibility/accessibility.qmlproject b/examples/quick/quick-accessibility/accessibility.qmlproject
new file mode 100644
index 0000000000..04a3190914
--- /dev/null
+++ b/examples/quick/quick-accessibility/accessibility.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "accessibility.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}
diff --git a/examples/quick/quick-accessibility/accessibility.qrc b/examples/quick/quick-accessibility/accessibility.qrc
new file mode 100644
index 0000000000..462a9a590c
--- /dev/null
+++ b/examples/quick/quick-accessibility/accessibility.qrc
@@ -0,0 +1,8 @@
+<RCC>
+ <qresource prefix="/accessibility">
+ <file>accessibility.qml</file>
+ <file>content/Button.qml</file>
+ <file>content/Checkbox.qml</file>
+ <file>content/Slider.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/quick/quick-accessibility/content/Button.qml b/examples/quick/quick-accessibility/content/Button.qml
new file mode 100644
index 0000000000..4034f074a9
--- /dev/null
+++ b/examples/quick/quick-accessibility/content/Button.qml
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ id: button
+
+ property bool checked: false
+ property alias text : buttonText.text
+ //! [button]
+ Accessible.name: text
+ Accessible.description: "This button does " + text
+ Accessible.role: Accessible.Button
+ function accessiblePressAction() {
+ button.clicked()
+ }
+ //! [button]
+
+ signal clicked
+
+ width: buttonText.width + 20
+ height: 30
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "lightsteelblue" }
+ GradientStop { position: 1.0;
+ color: button.focus ? "red" : "blue" }
+ }
+
+ radius: 5
+ antialiasing: true
+
+ Text {
+ id: buttonText
+ text: parent.description
+ anchors.centerIn: parent
+ font.pixelSize: parent.height * .5
+ style: Text.Sunken
+ color: "white"
+ styleColor: "black"
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: parent.clicked()
+ }
+
+ Keys.onSpacePressed: clicked()
+}
diff --git a/examples/quick/quick-accessibility/content/Checkbox.qml b/examples/quick/quick-accessibility/content/Checkbox.qml
new file mode 100644
index 0000000000..c4b8e8e380
--- /dev/null
+++ b/examples/quick/quick-accessibility/content/Checkbox.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id: checkbox
+
+ Accessible.role: Accessible.CheckBox
+
+ property string text: "CheckBox"
+ property bool checked // required variable
+
+ width: 100
+ height: 30
+
+ Row {
+ spacing: 2
+
+ Rectangle {
+ width: 12
+ height: 12
+ border.width: checkbox.focus ? 2 : 1
+ border.color: "black"
+
+ Text {
+ id: checkboxText
+ text: checkbox.checked ? "x" : ""
+ anchors.centerIn: parent
+ }
+ }
+
+ Text {
+ text: checkbox.text
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: checkbox.checked = !checkbox.checked
+ }
+
+ Keys.onSpacePressed: checkbox.checked = !checkbox.checked
+}
diff --git a/examples/quick/quick-accessibility/content/Slider.qml b/examples/quick/quick-accessibility/content/Slider.qml
new file mode 100644
index 0000000000..1a71e515f6
--- /dev/null
+++ b/examples/quick/quick-accessibility/content/Slider.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Quick module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+// Minimal slider implementation
+Rectangle {
+ id: slider
+
+ property alias text: buttonText.text
+ Accessible.role: Accessible.Slider
+
+ property int value: 5 // required
+ property int minimumValue: 0 // optional (default INT_MIN)
+ property int maximumValue: 20 // optional (default INT_MAX)
+ property int stepSize: 1 // optional (default 1)
+
+ width: 100
+ height: 30
+ border.color: "black"
+ border.width: 1
+
+ Rectangle {
+ id: indicator
+ x: 1
+ y: 1
+ height: parent.height - 2
+ width: ((parent.width - 2) / maximumValue) * value
+ color: "lightgrey"
+ Behavior on width {
+ NumberAnimation { duration: 50 }
+ }
+ }
+
+ Text {
+ id: buttonText
+ text: parent.value
+ anchors.centerIn: parent
+ font.pixelSize: parent.height * .5
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ var pos = mouse.x / slider.width * (maximumValue - minimumValue) + minimumValue
+ slider.value = pos
+ }
+ }
+
+ Keys.onLeftPressed: value > minimumValue ? value = value - stepSize : minimumValue
+ Keys.onRightPressed: value < maximumValue ? value = value + stepSize : maximumValue
+}
diff --git a/examples/quick/quick-accessibility/doc/src/accessibility.qdoc b/examples/quick/quick-accessibility/doc/src/accessibility.qdoc
new file mode 100644
index 0000000000..2a2af1f159
--- /dev/null
+++ b/examples/quick/quick-accessibility/doc/src/accessibility.qdoc
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*!
+ \title Qt Quick Examples - Accessibility
+ \example quick-accessibility
+ \brief This example has accessible buttons.
+ \ingroup qtquickexamples
+
+ Types in this example are augmented with meta-data for accessiblity systems.
+
+ For example, the button identifies itself and its functionality to the accessibility system:
+ \snippet accessibility/content/Button.qml button
+
+ As do Text types inside the example:
+ \snippet accessibility/accessibility.qml text
+*/
diff --git a/examples/quick/quick-accessibility/main.cpp b/examples/quick/quick-accessibility/main.cpp
new file mode 100644
index 0000000000..aee428a1ab
--- /dev/null
+++ b/examples/quick/quick-accessibility/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
+** of its contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(accessibility/accessibility)
diff --git a/examples/quick/quick-accessibility/quick-accessibility.pro b/examples/quick/quick-accessibility/quick-accessibility.pro
new file mode 100644
index 0000000000..70cf34b54c
--- /dev/null
+++ b/examples/quick/quick-accessibility/quick-accessibility.pro
@@ -0,0 +1,8 @@
+TEMPLATE = app
+
+QT += quick qml
+SOURCES += main.cpp
+RESOURCES += accessibility.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/quick-accessibility
+INSTALLS += target