diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-02-15 14:41:45 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-27 19:31:50 +0100 |
commit | 079aaa9b0754db9b7b2a97cb2ea22042c6f50738 (patch) | |
tree | a5e6f9d745114546cece44ef4540e98e2a5bc82b /src/plugins | |
parent | 245352fa45f4913716d23d98fa099097357beff1 (diff) | |
download | qtdeclarative-079aaa9b0754db9b7b2a97cb2ea22042c6f50738.tar.gz qtdeclarative-079aaa9b0754db9b7b2a97cb2ea22042c6f50738.tar.bz2 qtdeclarative-079aaa9b0754db9b7b2a97cb2ea22042c6f50738.zip |
Accessibility: Use factory function instead of plugin
[ChangeLog][QtQuick] Accessibility for Qt Quick is now included in the
qtquick library instead of being a separate plugin.
Change-Id: I26a7ed14b8a387662cea8f89218485be50033e34
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/accessible/accessible.pro | 2 | ||||
-rw-r--r-- | src/plugins/accessible/quick/accessible.json | 3 | ||||
-rw-r--r-- | src/plugins/accessible/quick/main.cpp | 105 | ||||
-rw-r--r-- | src/plugins/accessible/quick/qaccessiblequickitem.cpp | 447 | ||||
-rw-r--r-- | src/plugins/accessible/quick/qaccessiblequickitem.h | 130 | ||||
-rw-r--r-- | src/plugins/accessible/quick/qaccessiblequickview.cpp | 187 | ||||
-rw-r--r-- | src/plugins/accessible/quick/qaccessiblequickview.h | 78 | ||||
-rw-r--r-- | src/plugins/accessible/quick/quick.pro | 22 | ||||
-rw-r--r-- | src/plugins/accessible/shared/qaccessiblebase.pri | 3 | ||||
-rw-r--r-- | src/plugins/accessible/shared/qqmlaccessible.cpp | 224 | ||||
-rw-r--r-- | src/plugins/accessible/shared/qqmlaccessible.h | 92 | ||||
-rw-r--r-- | src/plugins/plugins.pro | 3 |
12 files changed, 0 insertions, 1296 deletions
diff --git a/src/plugins/accessible/accessible.pro b/src/plugins/accessible/accessible.pro deleted file mode 100644 index b97d323a0..000000000 --- a/src/plugins/accessible/accessible.pro +++ /dev/null @@ -1,2 +0,0 @@ -TEMPLATE = subdirs -qtHaveModule(quick): SUBDIRS += quick diff --git a/src/plugins/accessible/quick/accessible.json b/src/plugins/accessible/quick/accessible.json deleted file mode 100644 index b21218f19..000000000 --- a/src/plugins/accessible/quick/accessible.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "Keys": [ "QQuickWindow", "QQuickItem" ] -} diff --git a/src/plugins/accessible/quick/main.cpp b/src/plugins/accessible/quick/main.cpp deleted file mode 100644 index 6c7be155c..000000000 --- a/src/plugins/accessible/quick/main.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - - -#include "qqmlaccessible.h" -#include "qaccessiblequickview.h" -#include "qaccessiblequickitem.h" - -#include <QtQuick/QQuickWindow> -#include <QtQuick/QQuickItem> -#include <QtQuick/private/qquickitem_p.h> -#include <QtQuick/private/qquickaccessibleattached_p.h> - -#include <qaccessibleplugin.h> -#include <qvariant.h> -#include <qplugin.h> -#include <qaccessible.h> - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -class AccessibleQuickFactory : public QAccessiblePlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QAccessibleFactoryInterface" FILE "accessible.json") - -public: - AccessibleQuickFactory(); - - QStringList keys() const; - QAccessibleInterface *create(const QString &classname, QObject *object); -}; - -AccessibleQuickFactory::AccessibleQuickFactory() -{ -} - -QStringList AccessibleQuickFactory::keys() const -{ - QStringList list; - list << QLatin1String("QQuickWindow"); - list << QLatin1String("QQuickItem"); - return list; -} - -QAccessibleInterface *AccessibleQuickFactory::create(const QString &classname, QObject *object) -{ - if (classname == QLatin1String("QQuickWindow")) { - return new QAccessibleQuickWindow(qobject_cast<QQuickWindow *>(object)); - } else if (classname == QLatin1String("QQuickItem")) { - QQuickItem *item = qobject_cast<QQuickItem *>(object); - Q_ASSERT(item); - QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); - if (!itemPrivate->isAccessible) - return 0; - return new QAccessibleQuickItem(item); - } - - return 0; -} - -QT_END_NAMESPACE - -#include "main.moc" - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/quick/qaccessiblequickitem.cpp b/src/plugins/accessible/quick/qaccessiblequickitem.cpp deleted file mode 100644 index 4b6857414..000000000 --- a/src/plugins/accessible/quick/qaccessiblequickitem.cpp +++ /dev/null @@ -1,447 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qaccessiblequickitem.h" - -#include <QtGui/qtextdocument.h> - -#include "QtQuick/private/qquickitem_p.h" -#include "QtQuick/private/qquicktext_p.h" -#include "QtQuick/private/qquickaccessibleattached_p.h" -#include "QtQuick/qquicktextdocument.h" - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -QAccessibleQuickItem::QAccessibleQuickItem(QQuickItem *item) - : QQmlAccessible(item), m_doc(textDocument()) -{ -} - -int QAccessibleQuickItem::childCount() const -{ - return childItems().count(); -} - -QRect QAccessibleQuickItem::rect() const -{ - const QRect r = itemScreenRect(item()); - - if (!r.isValid()) { - qWarning() << item()->metaObject()->className() << item()->property("accessibleText") << r; - } - return r; -} - -QRect QAccessibleQuickItem::viewRect() const -{ - // ### no window in some cases. - if (!item()->window()) { - return QRect(); - } - - QQuickWindow *window = item()->window(); - QPoint screenPos = window->mapToGlobal(QPoint(0,0)); - return QRect(screenPos, window->size()); -} - - -bool QAccessibleQuickItem::clipsChildren() const -{ - return static_cast<QQuickItem *>(item())->clip(); -} - -QAccessibleInterface *QAccessibleQuickItem::parent() const -{ - QQuickItem *parent = item()->parentItem(); - if (parent) { - QQuickWindow *window = item()->window(); - // Jump out to the scene widget if the parent is the root item. - // There are two root items, QQuickWindow::rootItem and - // QQuickView::declarativeRoot. The former is the true root item, - // but is not a part of the accessibility tree. Check if we hit - // it here and return an interface for the scene instead. - if (window && (parent == window->contentItem())) { - return QAccessible::queryAccessibleInterface(window); - } else { - return QAccessible::queryAccessibleInterface(parent); - } - } - return 0; -} - -QAccessibleInterface *QAccessibleQuickItem::child(int index) const -{ - QList<QQuickItem *> children = childItems(); - - if (index < 0 || index >= children.count()) - return 0; - - QQuickItem *child = children.at(index); - if (!child) // FIXME can this happen? - return 0; - - return QAccessible::queryAccessibleInterface(child); -} - -int QAccessibleQuickItem::indexOfChild(const QAccessibleInterface *iface) const -{ - QList<QQuickItem*> kids = childItems(); - return kids.indexOf(static_cast<QQuickItem*>(iface->object())); -} - -QList<QQuickItem *> QAccessibleQuickItem::childItems() const -{ - if ( role() == QAccessible::Button || - role() == QAccessible::CheckBox || - role() == QAccessible::RadioButton || - role() == QAccessible::SpinBox || - role() == QAccessible::EditableText || - role() == QAccessible::Slider || - role() == QAccessible::PageTab || - role() == QAccessible::ProgressBar) - return QList<QQuickItem *>(); - - QList<QQuickItem *> items; - Q_FOREACH (QQuickItem *child, item()->childItems()) { - QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(child); - if (itemPrivate->isAccessible) - items.append(child); - } - return items; -} - -QAccessible::State QAccessibleQuickItem::state() const -{ - QQuickAccessibleAttached *attached = QQuickAccessibleAttached::attachedProperties(item()); - if (!attached) - return QAccessible::State(); - - QAccessible::State st = attached->state(); - - if (!item()->window() || !item()->window()->isVisible() ||!item()->isVisible() || qFuzzyIsNull(item()->opacity())) - st.invisible = true; - - if (item()->activeFocusOnTab()) - st.focusable = true; - if (item()->hasActiveFocus()) - st.focused = true; - - if (role() == QAccessible::ComboBox) - st.editable = item()->property("editable").toBool(); - - return st; -} - -QAccessible::Role QAccessibleQuickItem::role() const -{ - // Workaround for setAccessibleRole() not working for - // Text items. Text items are special since they are defined - // entirely from C++ (setting the role from QML works.) - if (qobject_cast<QQuickText*>(const_cast<QQuickItem *>(item()))) - return QAccessible::StaticText; - - QVariant v = QQuickAccessibleAttached::property(item(), "role"); - bool ok; - QAccessible::Role role = (QAccessible::Role)v.toInt(&ok); - if (!ok) // Not sure if this check is needed. - role = QAccessible::Pane; - return role; -} - -bool QAccessibleQuickItem::isAccessible() const -{ - return item()->d_func()->isAccessible; -} - -QString QAccessibleQuickItem::text(QAccessible::Text textType) const -{ - // handles generic behavior not specific to an item - switch (textType) { - case QAccessible::Name: { - QVariant accessibleName = QQuickAccessibleAttached::property(object(), "name"); - if (!accessibleName.isNull()) - return accessibleName.toString(); - break;} - case QAccessible::Description: { - QVariant accessibleDecription = QQuickAccessibleAttached::property(object(), "description"); - if (!accessibleDecription.isNull()) - return accessibleDecription.toString(); - break;} -#ifdef Q_ACCESSIBLE_QUICK_ITEM_ENABLE_DEBUG_DESCRIPTION - case QAccessible::DebugDescription: { - QString debugString; - debugString = QString::fromLatin1(object()->metaObject()->className()) + QLatin1Char(' '); - debugString += isAccessible() ? QLatin1String("enabled") : QLatin1String("disabled"); - return debugString; - break; } -#endif - case QAccessible::Value: - case QAccessible::Help: - case QAccessible::Accelerator: - default: - break; - } - - // the following block handles item-specific behavior - if (role() == QAccessible::EditableText) { - if (textType == QAccessible::Value) { - if (QTextDocument *doc = textDocument()) { - return doc->toPlainText(); - } - QVariant text = object()->property("text"); - return text.toString(); - } - } - - return QString(); -} - -void *QAccessibleQuickItem::interface_cast(QAccessible::InterfaceType t) -{ - QAccessible::Role r = role(); - if (t == QAccessible::ValueInterface && - (r == QAccessible::Slider || - r == QAccessible::SpinBox || - r == QAccessible::Dial || - r == QAccessible::ScrollBar)) - return static_cast<QAccessibleValueInterface*>(this); - - if (t == QAccessible::TextInterface && - (r == QAccessible::EditableText)) - return static_cast<QAccessibleTextInterface*>(this); - - return QQmlAccessible::interface_cast(t); -} - -QVariant QAccessibleQuickItem::currentValue() const -{ - return item()->property("value"); -} - -void QAccessibleQuickItem::setCurrentValue(const QVariant &value) -{ - item()->setProperty("value", value); -} - -QVariant QAccessibleQuickItem::maximumValue() const -{ - return item()->property("maximumValue"); -} - -QVariant QAccessibleQuickItem::minimumValue() const -{ - return item()->property("minimumValue"); -} - -QVariant QAccessibleQuickItem::minimumStepSize() const -{ - return item()->property("stepSize"); -} - -/*! - \internal - Shared between QAccessibleQuickItem and QAccessibleQuickView -*/ -QRect itemScreenRect(QQuickItem *item) -{ - // ### no window in some cases. - // ### Should we really check for 0 opacity? - if (!item->window() ||!item->isVisible() || qFuzzyIsNull(item->opacity())) { - return QRect(); - } - - QSize itemSize((int)item->width(), (int)item->height()); - // ### If the bounding rect fails, we first try the implicit size, then we go for the - // parent size. WE MIGHT HAVE TO REVISIT THESE FALLBACKS. - if (itemSize.isEmpty()) { - itemSize = QSize((int)item->implicitWidth(), (int)item->implicitHeight()); - if (itemSize.isEmpty() && item->parentItem()) - // ### Seems that the above fallback is not enough, fallback to use the parent size... - itemSize = QSize((int)item->parentItem()->width(), (int)item->parentItem()->height()); - } - - QPointF scenePoint = item->mapToScene(QPointF(0, 0)); - QPoint screenPos = item->window()->mapToGlobal(scenePoint.toPoint()); - return QRect(screenPos, itemSize); -} - -QTextDocument *QAccessibleQuickItem::textDocument() const -{ - QVariant docVariant = item()->property("textDocument"); - if (docVariant.canConvert<QQuickTextDocument*>()) { - QQuickTextDocument *qqdoc = docVariant.value<QQuickTextDocument*>(); - return qqdoc->textDocument(); - } - return 0; -} - -int QAccessibleQuickItem::characterCount() const -{ - if (m_doc) { - QTextCursor cursor = QTextCursor(m_doc); - cursor.movePosition(QTextCursor::End); - return cursor.position(); - } - return text(QAccessible::Value).size(); -} - -int QAccessibleQuickItem::cursorPosition() const -{ - QVariant pos = item()->property("cursorPosition"); - return pos.toInt(); -} - -void QAccessibleQuickItem::setCursorPosition(int position) -{ - item()->setProperty("cursorPosition", position); -} - -QString QAccessibleQuickItem::text(int startOffset, int endOffset) const -{ - if (m_doc) { - QTextCursor cursor = QTextCursor(m_doc); - cursor.setPosition(startOffset); - cursor.setPosition(endOffset, QTextCursor::KeepAnchor); - return cursor.selectedText(); - } - return text(QAccessible::Value).mid(startOffset, endOffset - startOffset); -} - -QString QAccessibleQuickItem::textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const -{ - Q_ASSERT(startOffset); - Q_ASSERT(endOffset); - - if (m_doc) { - QTextCursor cursor = QTextCursor(m_doc); - cursor.setPosition(offset); - QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - cursor.setPosition(boundaries.first - 1); - boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); - } else { - return QAccessibleTextInterface::textBeforeOffset(offset, boundaryType, startOffset, endOffset); - } -} - -QString QAccessibleQuickItem::textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const -{ - Q_ASSERT(startOffset); - Q_ASSERT(endOffset); - - if (m_doc) { - QTextCursor cursor = QTextCursor(m_doc); - cursor.setPosition(offset); - QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - cursor.setPosition(boundaries.second); - boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - - return text(boundaries.first, boundaries.second); - } else { - return QAccessibleTextInterface::textAfterOffset(offset, boundaryType, startOffset, endOffset); - } -} - -QString QAccessibleQuickItem::textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const -{ - Q_ASSERT(startOffset); - Q_ASSERT(endOffset); - - if (m_doc) { - QTextCursor cursor = QTextCursor(m_doc); - cursor.setPosition(offset); - QPair<int, int> boundaries = QAccessible::qAccessibleTextBoundaryHelper(cursor, boundaryType); - - *startOffset = boundaries.first; - *endOffset = boundaries.second; - return text(boundaries.first, boundaries.second); - } else { - return QAccessibleTextInterface::textAtOffset(offset, boundaryType, startOffset, endOffset); - } -} - -void QAccessibleQuickItem::selection(int selectionIndex, int *startOffset, int *endOffset) const -{ - if (selectionIndex == 0) { - *startOffset = item()->property("selectionStart").toInt(); - *endOffset = item()->property("selectionEnd").toInt(); - } else { - *startOffset = 0; - *endOffset = 0; - } -} - -int QAccessibleQuickItem::selectionCount() const -{ - if (item()->property("selectionStart").toInt() != item()->property("selectionEnd").toInt()) - return 1; - return 0; -} - -void QAccessibleQuickItem::addSelection(int /* startOffset */, int /* endOffset */) -{ - -} -void QAccessibleQuickItem::removeSelection(int /* selectionIndex */) -{ - -} -void QAccessibleQuickItem::setSelection(int /* selectionIndex */, int /* startOffset */, int /* endOffset */) -{ - -} - - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE diff --git a/src/plugins/accessible/quick/qaccessiblequickitem.h b/src/plugins/accessible/quick/qaccessiblequickitem.h deleted file mode 100644 index d9eb65203..000000000 --- a/src/plugins/accessible/quick/qaccessiblequickitem.h +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QACCESSIBLEQUICKITEM_H -#define QACCESSIBLEQUICKITEM_H - -#include <QtQuick/QQuickItem> -#include <QtQuick/QQuickView> -#include "qqmlaccessible.h" - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -class QTextDocument; - -class QAccessibleQuickItem : public QQmlAccessible, public QAccessibleValueInterface, public QAccessibleTextInterface -{ -public: - QAccessibleQuickItem(QQuickItem *item); - - QRect rect() const; - QRect viewRect() const; - - bool clipsChildren() const; - - QAccessibleInterface *parent() const; - QAccessibleInterface *child(int index) const; - int childCount() const; - int indexOfChild(const QAccessibleInterface *iface) const; - QList<QQuickItem *> childItems() const; - - QAccessible::State state() const; - QAccessible::Role role() const; - QString text(QAccessible::Text) const; - - bool isAccessible() const; - - // Value Interface - QVariant currentValue() const; - void setCurrentValue(const QVariant &value); - QVariant maximumValue() const; - QVariant minimumValue() const; - QVariant minimumStepSize() const; - - - // Text Interface - void selection(int selectionIndex, int *startOffset, int *endOffset) const; - int selectionCount() const; - void addSelection(int startOffset, int endOffset); - void removeSelection(int selectionIndex); - void setSelection(int selectionIndex, int startOffset, int endOffset); - - // cursor - int cursorPosition() const; - void setCursorPosition(int position); - - // text - QString text(int startOffset, int endOffset) const; - QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const; - QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const; - QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType, - int *startOffset, int *endOffset) const; - int characterCount() const; - - // character <-> geometry - QRect characterRect(int /* offset */) const { return QRect(); } - int offsetAtPoint(const QPoint & /* point */) const { return -1; } - - void scrollToSubstring(int /* startIndex */, int /* endIndex */) {} - QString attributes(int /* offset */, int *startOffset, int *endOffset) const { *startOffset = 0; *endOffset = 0; return QString(); } - - QTextDocument *textDocument() const; - -protected: - QQuickItem *item() const { return static_cast<QQuickItem*>(object()); } - void *interface_cast(QAccessible::InterfaceType t); - -private: - QTextDocument *m_doc; -}; - -QRect itemScreenRect(QQuickItem *item); - - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // QACCESSIBLEQUICKITEM_H diff --git a/src/plugins/accessible/quick/qaccessiblequickview.cpp b/src/plugins/accessible/quick/qaccessiblequickview.cpp deleted file mode 100644 index 1240b2ef4..000000000 --- a/src/plugins/accessible/quick/qaccessiblequickview.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qaccessiblequickview.h" - -#include <QtGui/qguiapplication.h> - -#include <QtQuick/qquickitem.h> -#include <QtQuick/private/qquickitem_p.h> - -#include "qaccessiblequickitem.h" -#include "qqmlaccessible.h" - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -QAccessibleQuickWindow::QAccessibleQuickWindow(QQuickWindow *object) - :QAccessibleObject(object) -{ -} - -QQuickItem *QAccessibleQuickWindow::rootItem() const -{ - if (QQuickItem *ci = window()->contentItem()) { - const QList<QQuickItem *> &childItems = ci->childItems(); - if (!childItems.isEmpty()) - return childItems.first(); - } - return 0; -} - -int QAccessibleQuickWindow::childCount() const -{ - return rootItem() ? 1 : 0; -} - -QAccessibleInterface *QAccessibleQuickWindow::parent() const -{ - // FIXME: for now we assume to be a top level window... - return QAccessible::queryAccessibleInterface(qApp); -} - -QAccessibleInterface *QAccessibleQuickWindow::child(int index) const -{ - if (index == 0) - return QAccessible::queryAccessibleInterface(rootItem()); - return 0; -} - -QAccessible::Role QAccessibleQuickWindow::role() const -{ - return QAccessible::Window; // FIXME -} - -QAccessible::State QAccessibleQuickWindow::state() const -{ - QAccessible::State st; - if (window() == QGuiApplication::focusWindow()) - st.active = true; - if (!window()->isVisible()) - st.invisible = true; - return st; -} - -QRect QAccessibleQuickWindow::rect() const -{ - return QRect(window()->x(), window()->y(), window()->width(), window()->height()); -} - -QString QAccessibleQuickWindow::text(QAccessible::Text text) const -{ -#ifdef Q_ACCESSIBLE_QUICK_ITEM_ENABLE_DEBUG_DESCRIPTION - if (text == QAccessible::DebugDescription) { - return QString::fromLatin1(object()->metaObject()->className()) ; - } -#else - Q_UNUSED(text) -#endif - return window()->title(); -} - - -/*! - \internal - - Can also return \a item itself - */ -static QQuickItem *childAt_helper(QQuickItem *item, int x, int y) -{ - if (!item->isVisible() || !item->isEnabled()) - return 0; - - if (item->flags() & QQuickItem::ItemClipsChildrenToShape) { - if (!itemScreenRect(item).contains(x, y)) - return 0; - } - - QAccessibleInterface *accessibleInterface = QAccessible::queryAccessibleInterface(item); - // this item has no Accessible attached property - if (!accessibleInterface) - return 0; - - if (accessibleInterface->childCount() == 0) { - return (itemScreenRect(item).contains(x, y)) ? item : 0; - } - - QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); - - QList<QQuickItem *> children = itemPrivate->paintOrderChildItems(); - for (int i = children.count() - 1; i >= 0; --i) { - QQuickItem *child = children.at(i); - if (QQuickItem *childChild = childAt_helper(child, x, y)) - return childChild; - } - - QRect screenRect = itemScreenRect(item); - - if (screenRect.contains(x, y)) - return item; - - return 0; -} - -QAccessibleInterface *QAccessibleQuickWindow::childAt(int x, int y) const -{ - Q_ASSERT(window()); - QQuickItem *root = rootItem(); - if (root) { - if (QQuickItem *item = childAt_helper(root, x, y)) - return QAccessible::queryAccessibleInterface(item); - return QAccessible::queryAccessibleInterface(root); - } - return 0; -} - -int QAccessibleQuickWindow::indexOfChild(const QAccessibleInterface *iface) const -{ - if (iface) { - QQuickItem *declarativeRoot = rootItem(); - if (declarativeRoot == iface->object()) - return 0; - } - return -1; -} - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/quick/qaccessiblequickview.h b/src/plugins/accessible/quick/qaccessiblequickview.h deleted file mode 100644 index 41c34c543..000000000 --- a/src/plugins/accessible/quick/qaccessiblequickview.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QAccessibleQuickView_H -#define QAccessibleQuickView_H - -#include <QtGui/qaccessibleobject.h> -#include <QtQuick/qquickwindow.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -class QAccessibleQuickWindow : public QAccessibleObject -{ -public: - QAccessibleQuickWindow(QQuickWindow *object); - - QAccessibleInterface *parent() const; - QAccessibleInterface *child(int index) const; - - QAccessible::Role role() const; - QAccessible::State state() const; - QRect rect() const; - - int childCount() const; - int indexOfChild(const QAccessibleInterface *iface) const; - QString text(QAccessible::Text text) const; - QAccessibleInterface *childAt(int x, int y) const; - -private: - QQuickWindow *window() const { return static_cast<QQuickWindow*>(object()); } - QQuickItem *rootItem() const; -}; - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // QAccessibleQuickView_H diff --git a/src/plugins/accessible/quick/quick.pro b/src/plugins/accessible/quick/quick.pro deleted file mode 100644 index eeececae8..000000000 --- a/src/plugins/accessible/quick/quick.pro +++ /dev/null @@ -1,22 +0,0 @@ -TARGET = qtaccessiblequick - -PLUGIN_TYPE = accessible -PLUGIN_CLASS_NAME = AccessibleQuickFactory -load(qt_plugin) - -include ($$PWD/../shared/qaccessiblebase.pri) - -QT += core-private gui-private qml-private quick-private - -#DEFINES+=Q_ACCESSIBLE_QUICK_ITEM_ENABLE_DEBUG_DESCRIPTION - -SOURCES += \ - main.cpp \ - qaccessiblequickview.cpp \ - qaccessiblequickitem.cpp - -HEADERS += \ - qaccessiblequickview.h \ - qaccessiblequickitem.h - -OTHERFILES += accessible.json diff --git a/src/plugins/accessible/shared/qaccessiblebase.pri b/src/plugins/accessible/shared/qaccessiblebase.pri deleted file mode 100644 index 827df0f13..000000000 --- a/src/plugins/accessible/shared/qaccessiblebase.pri +++ /dev/null @@ -1,3 +0,0 @@ -INCLUDEPATH += $$PWD -SOURCES += $$PWD/qqmlaccessible.cpp -HEADERS += $$PWD/qqmlaccessible.h diff --git a/src/plugins/accessible/shared/qqmlaccessible.cpp b/src/plugins/accessible/shared/qqmlaccessible.cpp deleted file mode 100644 index ecf4e56ac..000000000 --- a/src/plugins/accessible/shared/qqmlaccessible.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include <qnamespace.h> -#include "qqmlaccessible.h" - -#ifndef QT_NO_ACCESSIBILITY - -QT_BEGIN_NAMESPACE - -QQmlAccessible::QQmlAccessible(QObject *object) - :QAccessibleObject(object) -{ -} - -void *QQmlAccessible::interface_cast(QAccessible::InterfaceType t) -{ - if (t == QAccessible::ActionInterface) - return static_cast<QAccessibleActionInterface*>(this); - return QAccessibleObject::interface_cast(t); -} - -QQmlAccessible::~QQmlAccessible() -{ -} - -QAccessibleInterface *QQmlAccessible::childAt(int x, int y) const -{ - // Note that this function will disregard stacking order. - // (QAccessibleQuickView::childAt() does this correctly and more efficient) - - // If the item clips its children, we can return early if the coordinate is outside its rect - if (clipsChildren()) { - if (!rect().contains(x, y)) - return 0; - } - - for (int i = childCount() - 1; i >= 0; --i) { - QAccessibleInterface *childIface = child(i); - if (childIface && !childIface->state().invisible) { - if (childIface->rect().contains(x, y)) - return childIface; - } - } - return 0; -} - -QAccessible::State QQmlAccessible::state() const -{ - QAccessible::State state; - - //QRect viewRect(QPoint(0, 0), m_implementation->size()); - //QRect itemRect(m_item->scenePos().toPoint(), m_item->boundingRect().size().toSize()); - - QRect viewRect_ = viewRect(); - QRect itemRect = rect(); - - // qDebug() << "viewRect" << viewRect << "itemRect" << itemRect; - // error case: - if (viewRect_.isNull() || itemRect.isNull()) { - state.invisible = true; - } - - if (!viewRect_.intersects(itemRect)) { - state.offscreen = true; - // state.invisible = true; // no set at this point to ease development - } - - if (!object()->property("visible").toBool() || qFuzzyIsNull(object()->property("opacity").toDouble())) { - state.invisible = true; - } - - if ((role() == QAccessible::CheckBox || role() == QAccessible::RadioButton) && object()->property("checked").toBool()) { - state.checked = true; - } - - if (role() == QAccessible::EditableText) - state.focusable = true; - - //qDebug() << "state?" << m_item->property("state").toString() << m_item->property("status").toString() << m_item->property("visible").toString(); - - return state; -} - -QStringList QQmlAccessible::actionNames() const -{ - QStringList actions; - switch (role()) { - case QAccessible::PushButton: - actions << QAccessibleActionInterface::pressAction(); - break; - case QAccessible::RadioButton: - case QAccessible::CheckBox: - actions << QAccessibleActionInterface::toggleAction() - << QAccessibleActionInterface::pressAction(); - break; - case QAccessible::Slider: - case QAccessible::SpinBox: - case QAccessible::ScrollBar: - actions << QAccessibleActionInterface::increaseAction() - << QAccessibleActionInterface::decreaseAction(); - break; - default: - break; - } - return actions; -} - -void QQmlAccessible::doAction(const QString &actionName) -{ - // Look for and call the accessible[actionName]Action() function on the item. - // This allows for overriding the default action handling. - const QByteArray functionName = "accessible" + actionName.toLatin1() + "Action"; - if (object()->metaObject()->indexOfMethod(functionName + "()") != -1) { - QMetaObject::invokeMethod(object(), functionName); - return; - } - - // Role-specific default action handling follows. Items are expected to provide - // properties according to role conventions. These will then be read and/or updated - // by the accessibility system. - // Checkable roles : checked - // Value-based roles : (via the value interface: value, minimumValue, maximumValue), stepSize - switch (role()) { - case QAccessible::RadioButton: - case QAccessible::CheckBox: { - QVariant checked = object()->property("checked"); - if (checked.isValid()) { - if (actionName == QAccessibleActionInterface::toggleAction() || - actionName == QAccessibleActionInterface::pressAction()) { - - object()->setProperty("checked", QVariant(!checked.toBool())); - } - } - break; - } - case QAccessible::Slider: - case QAccessible::SpinBox: - case QAccessible::Dial: - case QAccessible::ScrollBar: { - if (actionName != QAccessibleActionInterface::increaseAction() && - actionName != QAccessibleActionInterface::decreaseAction()) - break; - - // Update the value using QAccessibleValueInterface, respecting - // the minimum and maximum value (if set). Also check for and - // use the "stepSize" property on the item - if (QAccessibleValueInterface *valueIface = valueInterface()) { - QVariant valueV = valueIface->currentValue(); - qreal newValue = valueV.toReal(); - - QVariant stepSizeV = object()->property("stepSize"); - qreal stepSize = stepSizeV.isValid() ? stepSizeV.toReal() : qreal(1.0); - if (actionName == QAccessibleActionInterface::increaseAction()) { - newValue += stepSize; - } else { - newValue -= stepSize; - } - - QVariant minimumValueV = valueIface->minimumValue(); - if (minimumValueV.isValid()) { - newValue = qMax(newValue, minimumValueV.toReal()); - } - QVariant maximumValueV = valueIface->maximumValue(); - if (maximumValueV.isValid()) { - newValue = qMin(newValue, maximumValueV.toReal()); - } - - valueIface->setCurrentValue(QVariant(newValue)); - } - break; - } - default: - break; - } -} - -QStringList QQmlAccessible::keyBindingsForAction(const QString &actionName) const -{ - Q_UNUSED(actionName) - return QStringList(); -} - -QT_END_NAMESPACE - -#endif // QT_NO_ACCESSIBILITY diff --git a/src/plugins/accessible/shared/qqmlaccessible.h b/src/plugins/accessible/shared/qqmlaccessible.h deleted file mode 100644 index b6da016b2..000000000 --- a/src/plugins/accessible/shared/qqmlaccessible.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#ifndef QQMLACCESSIBLE_H -#define QQMLACCESSIBLE_H - -#include <QtGui/qaccessibleobject.h> -#include <QtQml/qqmlproperty.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_NO_ACCESSIBILITY - -/* - -- Declarative Accessibility Overview. -- - - * Item interface classes: - QAccessibleDeclarativeItem for Qt Quick 1 - QAccessibleQuickItem for for Qt Quick 2 - Common base class: QQmlAccessible - - * View interface classes. - - These are the root of the QML accessible tree and connects it to the widget hierarchy. - - QAccessbileDeclarativeView is the root for the QGraphicsView implementation - QAccessbileQuickView is the root for the SceneGraph implementation - -*/ -class QQmlAccessible: public QAccessibleObject, public QAccessibleActionInterface -{ -public: - ~QQmlAccessible(); - void *interface_cast(QAccessible::InterfaceType t); - - virtual QRect viewRect() const = 0; - QAccessibleInterface *childAt(int, int) const; - QAccessible::State state() const; - - QStringList actionNames() const; - void doAction(const QString &actionName); - QStringList keyBindingsForAction(const QString &actionName) const; - -protected: - virtual bool clipsChildren() const = 0; - // For subclasses, use instantiateObject factory method outside the class. - QQmlAccessible(QObject *object); -}; - -#endif // QT_NO_ACCESSIBILITY - -QT_END_NAMESPACE - -#endif // QQMLACCESSIBLE_H diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index 9ef8c7ab7..664a45760 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -1,5 +1,2 @@ TEMPLATE = subdirs SUBDIRS += qmltooling -contains(QT_CONFIG, accessibility) { - SUBDIRS += accessible -} |