diff options
author | Andre de la Rocha <andre.rocha@qt.io> | 2017-10-19 17:03:11 +0200 |
---|---|---|
committer | Andre de la Rocha <andre.rocha@qt.io> | 2017-11-14 23:39:24 +0000 |
commit | 4c4ac0d976bc5daa89d6f845fa1a28479b00847f (patch) | |
tree | 47a919d576e75c7c1735945362b068f58793d28b /src/widgets | |
parent | 0cf6297c15be45d852be98c862bd0211e6de1aa2 (diff) |
Fix accessibility info for tri-state checkboxes
The state information provided by QAccessibleInterface::state() was not
correctly reflecting the state of tri-state checkboxes: checkStateMixed
was never set. This change fixes this issue and also adds accessibility
update notifications for changes in checkStateMixed, which were missing.
Change-Id: Ia4a114559d5a957ca85bf2f169a6cece2c98d077
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/accessible/simplewidgets.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qcheckbox.cpp | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index 73de51ff45..2fd664e13a 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -170,7 +170,7 @@ QAccessible::State QAccessibleButton::state() const if (b->isChecked()) state.checked = true; #if QT_CONFIG(checkbox) - else if (cb && cb->checkState() == Qt::PartiallyChecked) + if (cb && cb->checkState() == Qt::PartiallyChecked) state.checkStateMixed = true; #endif if (b->isDown()) diff --git a/src/widgets/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp index 9b49916774..235508535d 100644 --- a/src/widgets/widgets/qcheckbox.cpp +++ b/src/widgets/widgets/qcheckbox.cpp @@ -45,6 +45,9 @@ #include "qstyle.h" #include "qstyleoption.h" #include "qevent.h" +#ifndef QT_NO_ACCESSIBILITY +#include "qaccessible.h" +#endif #include "private/qabstractbutton_p.h" @@ -243,6 +246,9 @@ Qt::CheckState QCheckBox::checkState() const void QCheckBox::setCheckState(Qt::CheckState state) { Q_D(QCheckBox); +#ifndef QT_NO_ACCESSIBILITY + bool noChange = d->noChange; +#endif if (state == Qt::PartiallyChecked) { d->tristate = true; d->noChange = true; @@ -257,6 +263,15 @@ void QCheckBox::setCheckState(Qt::CheckState state) d->publishedState = state; emit stateChanged(state); } + +#ifndef QT_NO_ACCESSIBILITY + if (noChange != d->noChange) { + QAccessible::State s; + s.checkStateMixed = true; + QAccessibleStateChangeEvent event(this, s); + QAccessible::updateAccessibility(&event); + } +#endif } |