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>bb10
parent
0cf6297c15
commit
4c4ac0d976
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue