Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <jan-arve.saether@nokia.com>
- Loading branch information
Frederik Gladhorn
authored and
Qt by Nokia
committed
Jan 2, 2012
1 parent
017a82c
commit 27a497b
Showing
54 changed files
with
3,724 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/**************************************************************************** | ||
** | ||
** 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 | ||
import QtQuick.Window 2.0 | ||
import "widgets" | ||
|
||
Rectangle { | ||
id: window | ||
|
||
width: 360; height: 300 | ||
color: "white" | ||
|
||
Column { | ||
id: column | ||
spacing: 6 | ||
anchors.fill: parent | ||
width: parent.width | ||
Row { | ||
spacing: 6 | ||
width: column.width | ||
Button { width: 100; height: column.h + 20; text: "Send" } | ||
Button { width: 100; height: column.h + 20; text: "Discard" } | ||
} | ||
|
||
Row { | ||
spacing: 6 | ||
width: column.width | ||
height: column.h | ||
Text { | ||
id: subjectLabel | ||
Accessible.role: Accessible.StaticText | ||
Accessible.name: text | ||
text: "Subject:" | ||
width: 50 | ||
} | ||
Rectangle { | ||
id: subjectBorder | ||
Accessible.role: Accessible.EditableText | ||
Accessible.name: subjectEdit.text | ||
border.width: 1 | ||
border.color: "black" | ||
height: subjectEdit.height | ||
width: 304 | ||
TextInput { | ||
id: subjectEdit | ||
text: "Vacation plans" | ||
} | ||
} | ||
} | ||
Rectangle { | ||
id: textBorder | ||
Accessible.role: Accessible.EditableText | ||
property alias text : textEdit.text | ||
border.width: 1 | ||
border.color: "black" | ||
width: parent.width | ||
height: textEdit.height | ||
TextEdit { | ||
id: textEdit | ||
text: "Hi, we're going to the Dolomites this summer. Weren't you also going to northern Italy? \n\nbest wishes, your friend Luke" | ||
width: parent.width | ||
wrapMode: TextEdit.WordWrap | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/**************************************************************************** | ||
** | ||
** 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: button | ||
|
||
property alias text : buttonText.text | ||
Accessible.name: text | ||
Accessible.description: "This button does " + text | ||
Accessible.role: Accessible.Button | ||
|
||
signal clicked | ||
|
||
width: buttonText.width + 20 | ||
height: 30 | ||
gradient: Gradient { | ||
GradientStop { position: 0.0; color: "lightsteelblue" } | ||
GradientStop { position: 1.0; color: "blue" } | ||
} | ||
border.width: 2 | ||
border.color: "black"; | ||
radius: 10 | ||
|
||
Text { | ||
id: buttonText | ||
text: parent.description | ||
anchors.centerIn: parent | ||
font.pixelSize: parent.height * .5 | ||
style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true | ||
} | ||
|
||
MouseArea { | ||
id: mouseArea | ||
anchors.fill: parent | ||
onClicked: { | ||
checked = !checked; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
TEMPLATE = subdirs | ||
SUBDIRS += quick | ||
SUBDIRS += qtquick1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/**************************************************************************** | ||
** | ||
** 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$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include "qdeclarativeaccessible.h" | ||
#include "qaccessibledeclarativeview.h" | ||
#include "qaccessibledeclarativeitem.h" | ||
|
||
#include <QtQuick1/qdeclarativeitem.h> | ||
#include <QtWidgets/qgraphicsview.h> | ||
|
||
#include <qaccessibleplugin.h> | ||
#include <qplugin.h> | ||
#include <qvariant.h> | ||
#include <qaccessible.h> | ||
|
||
#ifndef QT_NO_ACCESSIBILITY | ||
|
||
QT_BEGIN_NAMESPACE | ||
|
||
class AccessibleQtQuick1Factory : public QAccessiblePlugin | ||
{ | ||
public: | ||
AccessibleQtQuick1Factory(); | ||
|
||
QStringList keys() const; | ||
QAccessibleInterface *create(const QString &classname, QObject *object); | ||
}; | ||
|
||
AccessibleQtQuick1Factory::AccessibleQtQuick1Factory() | ||
{ | ||
} | ||
|
||
QStringList AccessibleQtQuick1Factory::keys() const | ||
{ | ||
QStringList list; | ||
list << QLatin1String("QDeclarativeView"); | ||
list << QLatin1String("QDeclarativeItem"); | ||
return list; | ||
} | ||
|
||
QAccessibleInterface *AccessibleQtQuick1Factory::create(const QString &classname, QObject *object) | ||
{ | ||
if (classname == QLatin1String("QDeclarativeView")) { | ||
QWidget *widget = qobject_cast<QWidget*>(object); | ||
if (qobject_cast<QDeclarativeView *>(widget) != 0) | ||
return new QAccessibleDeclarativeView(widget); | ||
} else if (classname == QLatin1String("QDeclarativeItem")) { | ||
QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(object); | ||
if (!item->scene()) | ||
return 0; | ||
|
||
QList<QGraphicsView *> views = item->scene()->views(); | ||
if (views.isEmpty()) | ||
return 0; | ||
QGraphicsView *view = views.at(0); // Accessibility support for the first view only. | ||
// (Not a problem for QDeclarative) | ||
return new QAccessibleDeclarativeItem(item, view); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
Q_EXPORT_STATIC_PLUGIN(AccessibleQtQuick1Factory) | ||
Q_EXPORT_PLUGIN2(qtaccessibleqtquick1, AccessibleQtQuick1Factory) | ||
|
||
QT_END_NAMESPACE | ||
|
||
#endif // QT_NO_ACCESSIBILITY |
Oops, something went wrong.