summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-05-23 13:13:22 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-30 15:58:46 +0200
commite747324f68df827dcea15bd0e3ee6b023542fe01 (patch)
treedbc4aa3f49ad745ef92f80fa55ba4586057bf1e0
parentc040ba18aec6ef2b65d394e47b103fe14841dd88 (diff)
downloadqtbase-e747324f68df827dcea15bd0e3ee6b023542fe01.tar.gz
Accessibility: Fix rect for QComboBox and QRadioButton
This is especially relevant on mobile devices where screen readers often send mouse clicks to the middle of the object. Task-number: QTBUG-39100 Change-Id: I5972f21dd12434601d86136215ab9b61248c9691 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
-rw-r--r--src/widgets/accessible/simplewidgets.cpp20
-rw-r--r--src/widgets/accessible/simplewidgets.h1
-rw-r--r--src/widgets/widgets/qcheckbox.h1
-rw-r--r--src/widgets/widgets/qradiobutton.h1
4 files changed, 23 insertions, 0 deletions
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp
index 6e1428323f..2cd960cfcf 100644
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -158,6 +158,26 @@ QAccessible::State QAccessibleButton::state() const
return state;
}
+QRect QAccessibleButton::rect() const
+{
+ QAbstractButton *ab = button();
+ if (!ab->isVisible())
+ return QRect();
+
+ if (QCheckBox *cb = qobject_cast<QCheckBox *>(ab)) {
+ QPoint wpos = cb->mapToGlobal(QPoint(0, 0));
+ QStyleOptionButton opt;
+ cb->initStyleOption(&opt);
+ return cb->style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, cb).translated(wpos);
+ } else if (QRadioButton *rb = qobject_cast<QRadioButton *>(ab)) {
+ QPoint wpos = rb->mapToGlobal(QPoint(0, 0));
+ QStyleOptionButton opt;
+ rb->initStyleOption(&opt);
+ return rb->style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, rb).translated(wpos);
+ }
+ return QAccessibleWidget::rect();
+}
+
QStringList QAccessibleButton::actionNames() const
{
QStringList names;
diff --git a/src/widgets/accessible/simplewidgets.h b/src/widgets/accessible/simplewidgets.h
index be19d8324f..af67a1e669 100644
--- a/src/widgets/accessible/simplewidgets.h
+++ b/src/widgets/accessible/simplewidgets.h
@@ -63,6 +63,7 @@ public:
QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
QAccessible::State state() const Q_DECL_OVERRIDE;
+ QRect rect() const Q_DECL_OVERRIDE;
QStringList actionNames() const Q_DECL_OVERRIDE;
void doAction(const QString &actionName) Q_DECL_OVERRIDE;
diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h
index 9adf5f6567..db6be7d1c0 100644
--- a/src/widgets/widgets/qcheckbox.h
+++ b/src/widgets/widgets/qcheckbox.h
@@ -86,6 +86,7 @@ protected:
private:
Q_DECLARE_PRIVATE(QCheckBox)
Q_DISABLE_COPY(QCheckBox)
+ friend class QAccessibleButton;
};
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h
index 104d4a12e0..8888ccf86d 100644
--- a/src/widgets/widgets/qradiobutton.h
+++ b/src/widgets/widgets/qradiobutton.h
@@ -73,6 +73,7 @@ protected:
private:
Q_DECLARE_PRIVATE(QRadioButton)
Q_DISABLE_COPY(QRadioButton)
+ friend class QAccessibleButton;
};
QT_END_NAMESPACE