diff options
Diffstat (limited to 'src/widgets/accessible/simplewidgets.cpp')
-rw-r--r-- | src/widgets/accessible/simplewidgets.cpp | 124 |
1 files changed, 67 insertions, 57 deletions
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 3ecd938039..fbbbab857d 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the plugins 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 The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "simplewidgets_p.h" @@ -79,6 +43,9 @@ #ifndef QT_NO_PICTURE #include <QtGui/qpicture.h> #endif +#if QT_CONFIG(messagebox) +#include <qmessagebox.h> +#endif #include <qstyle.h> #include <qstyleoption.h> #include <qtextdocument.h> @@ -93,9 +60,11 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_ACCESSIBILITY +using namespace Qt::StringLiterals; + +#if QT_CONFIG(accessibility) -extern QList<QWidget*> childWidgets(const QWidget *widget); +QWidgetList _q_ac_childWidgets(const QWidget *widget); QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); @@ -120,9 +89,9 @@ QAccessibleButton::QAccessibleButton(QWidget *w) // FIXME: The checkable state of the button is dynamic, // while we only update the controlling signal once :( if (button()->isCheckable()) - addControllingSignal(QLatin1String("toggled(bool)")); + addControllingSignal("toggled(bool)"_L1); else - addControllingSignal(QLatin1String("clicked()")); + addControllingSignal("clicked()"_L1); } /*! Returns the button. */ @@ -247,11 +216,9 @@ QStringList QAccessibleButton::actionNames() const names << toggleAction(); break; default: - if (button()->isCheckable()) { + if (button()->isCheckable()) names << toggleAction(); - } else { - names << pressAction(); - } + names << pressAction(); break; } } @@ -434,10 +401,10 @@ QAccessible::Role QAccessibleDisplay::role() const #if QT_CONFIG(label) QLabel *l = qobject_cast<QLabel*>(object()); if (l) { - if (!l->pixmap(Qt::ReturnByValue).isNull()) + if (!l->pixmap().isNull()) return QAccessible::Graphic; #ifndef QT_NO_PICTURE - if (!l->picture(Qt::ReturnByValue).isNull()) + if (!l->picture().isNull()) return QAccessible::Graphic; #endif #if QT_CONFIG(movie) @@ -562,7 +529,7 @@ QSize QAccessibleDisplay::imageSize() const #endif return QSize(); #if QT_CONFIG(label) - return label->pixmap(Qt::ReturnByValue).size(); + return label->pixmap().size(); #endif } @@ -575,7 +542,7 @@ QPoint QAccessibleDisplay::imagePosition() const #endif return QPoint(); #if QT_CONFIG(label) - if (label->pixmap(Qt::ReturnByValue).isNull()) + if (label->pixmap().isNull()) return QPoint(); return QPoint(label->mapToGlobal(label->pos())); @@ -638,7 +605,7 @@ QAccessibleGroupBox::relations(QAccessible::Relation match /* = QAccessible::All QAccessibleWidget::relations(match); if ((match & QAccessible::Labelled) && (!groupBox()->title().isEmpty())) { - const QList<QWidget*> kids = childWidgets(widget()); + const QList<QWidget*> kids = _q_ac_childWidgets(widget()); for (QWidget *kid : kids) { QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(kid); if (iface) @@ -687,8 +654,8 @@ QStringList QAccessibleGroupBox::keyBindingsForAction(const QString &) const QAccessibleLineEdit::QAccessibleLineEdit(QWidget *w, const QString &name) : QAccessibleWidget(w, QAccessible::EditableText, name) { - addControllingSignal(QLatin1String("textChanged(const QString&)")); - addControllingSignal(QLatin1String("returnPressed()")); + addControllingSignal("textChanged(const QString&)"_L1); + addControllingSignal("returnPressed()"_L1); } /*! Returns the line edit. */ @@ -705,7 +672,7 @@ QString QAccessibleLineEdit::text(QAccessible::Text t) const if (lineEdit()->echoMode() == QLineEdit::Normal) str = lineEdit()->text(); else if (lineEdit()->echoMode() != QLineEdit::NoEcho) - str = QString(lineEdit()->text().length(), QChar::fromLatin1('*')); + str = QString(lineEdit()->text().size(), QChar::fromLatin1('*')); break; default: break; @@ -811,7 +778,7 @@ void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *e return; *startOffset = lineEdit()->selectionStart(); - *endOffset = *startOffset + lineEdit()->selectedText().count(); + *endOffset = *startOffset + lineEdit()->selectedText().size(); } QString QAccessibleLineEdit::text(int startOffset, int endOffset) const @@ -884,7 +851,7 @@ void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int int QAccessibleLineEdit::characterCount() const { - return lineEdit()->text().count(); + return lineEdit()->text().size(); } void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex) @@ -985,6 +952,49 @@ QWindowContainer *QAccessibleWindowContainer::container() const return static_cast<QWindowContainer *>(widget()); } -#endif // QT_NO_ACCESSIBILITY +#if QT_CONFIG(messagebox) +/*! + \internal + Implements QAccessibleWidget for QMessageBox +*/ +QAccessibleMessageBox::QAccessibleMessageBox(QWidget *widget) + : QAccessibleWidget(widget, QAccessible::AlertMessage) +{ + Q_ASSERT(qobject_cast<QMessageBox *>(widget)); +} + +QMessageBox *QAccessibleMessageBox::messageBox() const +{ + return static_cast<QMessageBox *>(widget()); +} + +QString QAccessibleMessageBox::text(QAccessible::Text t) const +{ + QString str; + + switch (t) { + case QAccessible::Name: + str = QAccessibleWidget::text(t); + if (str.isEmpty()) // implies no title text is set + str = messageBox()->text(); + break; + case QAccessible::Description: + str = widget()->accessibleDescription(); + break; + case QAccessible::Value: + str = messageBox()->text(); + break; + case QAccessible::Help: + str = messageBox()->informativeText(); + break; + default: + break; + } + + return str; +} +#endif + +#endif // QT_CONFIG(accessibility) QT_END_NAMESPACE |