Accessible: Improve value interface
The stepSize property was missing in Qt 4 and is a sensible addition to the value interface. Change-Id: I7571800d50ee7e4194c09c4db40300809a1ce45a Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
This commit is contained in:
parent
225a835777
commit
22c234a34e
@ -438,6 +438,19 @@ QString QAccessibleTextInterface::textAtOffset(int offset, QAccessible2::Boundar
|
||||
\sa maximumValue(), currentValue()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QVariant QAccessibleValueInterface::minimumStepSize() const
|
||||
|
||||
Returns the minimum step size for the accessible.
|
||||
This is the smalles increment that makes sense when changing the value.
|
||||
When programatically changing the value it should always be a multiple
|
||||
of the minimum step size.
|
||||
|
||||
Some tools use this value even when the setCurrentValue does not
|
||||
perform any action. Progress bars for example are read-only but
|
||||
should return their range divided by 100.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QAccessibleImageInterface
|
||||
\inmodule QtGui
|
||||
|
@ -117,6 +117,7 @@ public:
|
||||
virtual void setCurrentValue(const QVariant &value) = 0;
|
||||
virtual QVariant maximumValue() const = 0;
|
||||
virtual QVariant minimumValue() const = 0;
|
||||
virtual QVariant minimumStepSize() const = 0;
|
||||
};
|
||||
|
||||
class Q_GUI_EXPORT QAccessibleTableCellInterface
|
||||
|
@ -1049,7 +1049,7 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event)
|
||||
break;
|
||||
}
|
||||
case QAccessible::ValueChanged: {
|
||||
if (sendObject || sendObject_value_changed) {
|
||||
if (sendObject || sendObject_value_changed || sendObject_property_change_accessible_value) {
|
||||
QAIPointer iface = QAIPointer(event->accessibleInterface());
|
||||
Q_ASSERT(iface->valueInterface());
|
||||
QString path = pathForInterface(iface);
|
||||
@ -2093,44 +2093,34 @@ bool AtSpiAdaptor::editableTextInterface(const QAIPointer &interface, const QStr
|
||||
// Value interface
|
||||
bool AtSpiAdaptor::valueInterface(const QAIPointer &interface, const QString &function, const QDBusMessage &message, const QDBusConnection &connection)
|
||||
{
|
||||
if (0) {
|
||||
} else if (function == QLatin1String("SetCurrentValue")) {
|
||||
if (function == QLatin1String("SetCurrentValue")) {
|
||||
QDBusVariant v = message.arguments().at(2).value<QDBusVariant>();
|
||||
double value = v.variant().toDouble();
|
||||
//Temporary fix
|
||||
//See https://bugzilla.gnome.org/show_bug.cgi?id=652596
|
||||
interface->valueInterface()->setCurrentValue(value);
|
||||
connection.send(message.createReply()); // FIXME is the reply needed?
|
||||
} else if (function == QLatin1String("GetCurrentValue")) {
|
||||
bool success;
|
||||
double val = interface->valueInterface()->currentValue().toDouble(&success);
|
||||
if (!success) {
|
||||
qAtspiDebug ("AtSpiAdaptor::valueInterface: Could not convert current value to double.");
|
||||
}
|
||||
connection.send(message.createReply(
|
||||
QVariant::fromValue(QDBusVariant(QVariant::fromValue(val)))));
|
||||
} else if (function == QLatin1String("GetMaximumValue")) {
|
||||
bool success;
|
||||
double val = interface->valueInterface()->maximumValue().toDouble(&success);
|
||||
if (!success) {
|
||||
qAtspiDebug ("AtSpiAdaptor::valueInterface: Could not convert current value to double.");
|
||||
}
|
||||
connection.send(message.createReply(
|
||||
QVariant::fromValue(QDBusVariant(QVariant::fromValue(val)))));
|
||||
} else if (function == QLatin1String("GetMinimumIncrement")) {
|
||||
connection.send(message.createReply(
|
||||
QVariant::fromValue(QDBusVariant(QVariant::fromValue(0.0)))));
|
||||
} else if (function == QLatin1String("GetMinimumValue")) {
|
||||
bool success;
|
||||
double val = interface->valueInterface()->minimumValue().toDouble(&success);
|
||||
if (!success) {
|
||||
qAtspiDebug ("AtSpiAdaptor::valueInterface: Could not convert current value to double.");
|
||||
}
|
||||
connection.send(message.createReply(
|
||||
QVariant::fromValue(QDBusVariant(QVariant::fromValue(val)))));
|
||||
} else {
|
||||
qAtspiDebug() << "WARNING: AtSpiAdaptor::valueInterface does not implement " << function << message.path();
|
||||
return false;
|
||||
QVariant value;
|
||||
if (function == QLatin1String("GetCurrentValue"))
|
||||
value = interface->valueInterface()->currentValue();
|
||||
else if (function == QLatin1String("GetMaximumValue"))
|
||||
value = interface->valueInterface()->maximumValue();
|
||||
else if (function == QLatin1String("GetMinimumIncrement"))
|
||||
value = interface->valueInterface()->minimumStepSize();
|
||||
else if (function == QLatin1String("GetMinimumValue"))
|
||||
value = interface->valueInterface()->minimumValue();
|
||||
else {
|
||||
qAtspiDebug() << "WARNING: AtSpiAdaptor::valueInterface does not implement " << function << message.path();
|
||||
return false;
|
||||
}
|
||||
if (!value.canConvert(QVariant::Double))
|
||||
qAtspiDebug() << "AtSpiAdaptor::valueInterface: Could not convert to double: " << function;
|
||||
|
||||
// explicitly convert to dbus-variant containing one double since atspi expects that
|
||||
// everything else might fail to convert back on the other end
|
||||
connection.send(message.createReply(
|
||||
QVariant::fromValue(QDBusVariant(QVariant::fromValue(value.toDouble())))));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -122,6 +122,11 @@ QVariant QAccessibleAbstractSpinBox::minimumValue() const
|
||||
return abstractSpinBox()->property("minimum");
|
||||
}
|
||||
|
||||
QVariant QAccessibleAbstractSpinBox::minimumStepSize() const
|
||||
{
|
||||
return abstractSpinBox()->property("stepSize");
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QAccessibleSpinBox
|
||||
\brief The QAccessibleSpinBox class implements the QAccessibleInterface for spinbox widgets.
|
||||
@ -278,6 +283,11 @@ QVariant QAccessibleAbstractSlider::minimumValue() const
|
||||
return abstractSlider()->minimum();
|
||||
}
|
||||
|
||||
QVariant QAccessibleAbstractSlider::minimumStepSize() const
|
||||
{
|
||||
return abstractSlider()->singleStep();
|
||||
}
|
||||
|
||||
QAbstractSlider *QAccessibleAbstractSlider::abstractSlider() const
|
||||
{
|
||||
return static_cast<QAbstractSlider *>(object());
|
||||
|
@ -71,6 +71,7 @@ public:
|
||||
void setCurrentValue(const QVariant &value);
|
||||
QVariant maximumValue() const;
|
||||
QVariant minimumValue() const;
|
||||
QVariant minimumStepSize() const;
|
||||
|
||||
// FIXME Action interface
|
||||
|
||||
@ -110,6 +111,7 @@ public:
|
||||
void setCurrentValue(const QVariant &value);
|
||||
QVariant maximumValue() const;
|
||||
QVariant minimumValue() const;
|
||||
QVariant minimumStepSize() const;
|
||||
|
||||
protected:
|
||||
QAbstractSlider *abstractSlider() const;
|
||||
|
@ -832,6 +832,14 @@ QVariant QAccessibleProgressBar::minimumValue() const
|
||||
return progressBar()->minimum();
|
||||
}
|
||||
|
||||
QVariant QAccessibleProgressBar::minimumStepSize() const
|
||||
{
|
||||
// This is arbitrary since any value between min and max is valid.
|
||||
// Some screen readers (orca use it to calculate how many digits to display though,
|
||||
// so it makes sense to return a "sensible" value. Providing 100 increments seems ok.
|
||||
return (progressBar()->maximum() - progressBar()->minimum()) / 100.0;
|
||||
}
|
||||
|
||||
QProgressBar *QAccessibleProgressBar::progressBar() const
|
||||
{
|
||||
return qobject_cast<QProgressBar *>(object());
|
||||
|
@ -188,6 +188,7 @@ public:
|
||||
QVariant currentValue() const;
|
||||
QVariant maximumValue() const;
|
||||
QVariant minimumValue() const;
|
||||
QVariant minimumStepSize() const;
|
||||
inline void setCurrentValue(const QVariant &) {}
|
||||
|
||||
protected:
|
||||
|
@ -453,6 +453,7 @@ void tst_QAccessibility::sliderTest()
|
||||
QVERIFY(valueIface != 0);
|
||||
QCOMPARE(valueIface->minimumValue().toInt(), slider->minimum());
|
||||
QCOMPARE(valueIface->maximumValue().toInt(), slider->maximum());
|
||||
QCOMPARE(valueIface->minimumStepSize().toInt(), slider->singleStep());
|
||||
slider->setValue(50);
|
||||
QCOMPARE(valueIface->currentValue().toInt(), slider->value());
|
||||
slider->setValue(0);
|
||||
@ -461,6 +462,8 @@ void tst_QAccessibility::sliderTest()
|
||||
QCOMPARE(valueIface->currentValue().toInt(), slider->value());
|
||||
valueIface->setCurrentValue(77);
|
||||
QCOMPARE(77, slider->value());
|
||||
slider->setSingleStep(2);
|
||||
QCOMPARE(valueIface->minimumStepSize().toInt(), 2);
|
||||
|
||||
delete slider;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user