From 4d382636b0b1c555af2b98f2f41b4776fd7b5ffb Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Fri, 21 Sep 2018 10:20:09 +0200 Subject: qt5: Add basic a11y support Widget tree is displayed and basic role mapping is available. Still needs quite some work (positions, actions, texts, etc.) Change-Id: I9d26a762f1d9684f33bbb80a384cf2a0b8a905c0 Reviewed-on: https://gerrit.libreoffice.org/60853 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- vcl/inc/qt5/Qt5AccessibleWidget.hxx | 77 +++++++++++++++++++++++++++++++++++++ vcl/inc/qt5/Qt5VclWindow.hxx | 31 +++++++++++++++ vcl/inc/qt5/Qt5Widget.hxx | 3 +- 3 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 vcl/inc/qt5/Qt5AccessibleWidget.hxx create mode 100644 vcl/inc/qt5/Qt5VclWindow.hxx (limited to 'vcl/inc') diff --git a/vcl/inc/qt5/Qt5AccessibleWidget.hxx b/vcl/inc/qt5/Qt5AccessibleWidget.hxx new file mode 100644 index 000000000000..df6862567dd0 --- /dev/null +++ b/vcl/inc/qt5/Qt5AccessibleWidget.hxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +class Qt5Frame; +class Qt5Widget; + +class VCLPLUG_QT5_PUBLIC Qt5AccessibleWidget : public QObject, public QAccessibleInterface +//public QAccessibleActionInterface +{ + Q_OBJECT + +public: + Qt5AccessibleWidget(Qt5Widget* pFrame, vcl::Window* pWindow); + Qt5AccessibleWidget(vcl::Window* pWindow); + QWindow* window() const override; + int childCount() const override; + int indexOfChild(const QAccessibleInterface* child) const override; + QVector> + relations(QAccessible::Relation match = QAccessible::AllRelations) const override; + QAccessibleInterface* focusChild() const override; + + QRect rect() const override; + + QAccessibleInterface* parent() const override; + QAccessibleInterface* child(int index) const override; + + QString text(QAccessible::Text t) const override; + QAccessible::Role role() const override; + QAccessible::State state() const override; + + QColor foregroundColor() const override; + QColor backgroundColor() const override; + + bool isValid() const override; + QObject* object() const override; + void setText(QAccessible::Text t, const QString& text) override; + QAccessibleInterface* childAt(int x, int y) const override; + + void* interface_cast(QAccessible::InterfaceType t) override; + + // QAccessibleActionInterface + /* QStringList actionNames() const override; + void doAction(const QString& actionName) override; + QStringList keyBindingsForAction(const QString& actionName) const override; */ + + // Factory + static QAccessibleInterface* customFactory(const QString& classname, QObject* object); + +private: + Qt5Widget* m_pFrame; + VclPtr m_pWindow; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/Qt5VclWindow.hxx b/vcl/inc/qt5/Qt5VclWindow.hxx new file mode 100644 index 000000000000..f7883aa67c4d --- /dev/null +++ b/vcl/inc/qt5/Qt5VclWindow.hxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include + +#include + +#include + +class Qt5Frame; +class Qt5Widget; + +// Wrapper class to hold a vcl::Window while being able to pass it as a QObject +class VCLPLUG_QT5_PUBLIC Qt5VclWindow : public QObject +{ + Q_OBJECT + +public: + Qt5VclWindow(vcl::Window* pWindow); + VclPtr m_pWindow; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx index ba558f82be38..101ae6d68f67 100644 --- a/vcl/inc/qt5/Qt5Widget.hxx +++ b/vcl/inc/qt5/Qt5Widget.hxx @@ -36,8 +36,6 @@ class Qt5Widget : public QWidget { Q_OBJECT - Qt5Frame* m_pFrame; - bool handleKeyEvent(QKeyEvent*, bool); void handleMouseButtonEvent(QMouseEvent*, bool); @@ -57,6 +55,7 @@ class Qt5Widget : public QWidget public: Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags()); + Qt5Frame* m_pFrame; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit