Accessibility: Update ComboBox text on arrow keys

Use ValueChanged to notify of changes in the ComboBox.
On Linux we need to update name and then send selection-changed for
Orca.

Task-number: QTBUG-36814
Change-Id: Icdd34adddeac532476a6dd910d1e8bd33bcd590b
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
This commit is contained in:
Frederik Gladhorn 2014-05-07 16:06:22 +02:00 committed by The Qt Project
parent 94f9c9678a
commit 679cd99f3d
2 changed files with 26 additions and 13 deletions

View File

@ -1024,15 +1024,28 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
case QAccessible::ValueChanged: {
if (sendObject || sendObject_value_changed || sendObject_property_change_accessible_value) {
QAccessibleInterface * iface = event->accessibleInterface();
if (!iface || !iface->valueInterface()) {
qWarning() << "ValueChanged event from invalid accessible: " << iface;
if (!iface) {
qWarning() << "ValueChanged event from invalid accessible.";
return;
}
QString path = pathForInterface(iface);
QVariantList args = packDBusSignalArguments(QLatin1String("accessible-value"), 0, 0, variantForPath(path));
sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
QLatin1String("PropertyChange"), args);
if (iface->valueInterface()) {
QString path = pathForInterface(iface);
QVariantList args = packDBusSignalArguments(QLatin1String("accessible-value"), 0, 0, variantForPath(path));
sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
QLatin1String("PropertyChange"), args);
} else if (iface->role() == QAccessible::ComboBox) {
// Combo Box with AT-SPI likes to be special
// It requires a name-change to update caches and then selection-changed
QString path = pathForInterface(iface);
QVariantList args1 = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path));
sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
QLatin1String("PropertyChange"), args1);
QVariantList args2 = packDBusSignalArguments(QString(), 0, 0, QVariant::fromValue(QDBusVariant(QVariant(0))));
sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT),
QLatin1String("SelectionChanged"), args2);
} else {
qWarning() << "ValueChanged event and no ValueInterface or ComboBox: " << iface;
}
}
break;
}

View File

@ -1000,11 +1000,11 @@ void QComboBoxPrivate::_q_dataChanged(const QModelIndex &topLeft, const QModelIn
emit q->currentTextChanged(text);
}
q->update();
}
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(q, QAccessible::NameChanged);
QAccessibleValueChangeEvent event(q, text);
QAccessible::updateAccessibility(&event);
#endif
}
}
void QComboBoxPrivate::_q_rowsInserted(const QModelIndex &parent, int start, int end)
@ -1269,7 +1269,7 @@ void QComboBoxPrivate::_q_emitCurrentIndexChanged(const QModelIndex &index)
if (!lineEdit)
emit q->currentTextChanged(text);
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(q, QAccessible::NameChanged);
QAccessibleValueChangeEvent event(q, text);
QAccessible::updateAccessibility(&event);
#endif
}
@ -2757,7 +2757,7 @@ void QComboBox::clear()
Q_D(QComboBox);
d->model->removeRows(0, d->model->rowCount(d->root), d->root);
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessibleValueChangeEvent event(this, QString());
QAccessible::updateAccessibility(&event);
#endif
}
@ -2771,7 +2771,7 @@ void QComboBox::clearEditText()
if (d->lineEdit)
d->lineEdit->clear();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessibleValueChangeEvent event(this, QString());
QAccessible::updateAccessibility(&event);
#endif
}
@ -2785,7 +2785,7 @@ void QComboBox::setEditText(const QString &text)
if (d->lineEdit)
d->lineEdit->setText(text);
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent event(this, QAccessible::NameChanged);
QAccessibleValueChangeEvent event(this, text);
QAccessible::updateAccessibility(&event);
#endif
}