diff options
author | Frederik Gladhorn <[email protected]> | 2012-11-04 12:54:30 +0100 |
---|---|---|
committer | The Qt Project <[email protected]> | 2012-12-19 14:59:06 +0100 |
commit | c8ef32e2b6cded37a6854b94a281464c1b7a298b (patch) | |
tree | 3f88b1184ba65c1bfe51ffae52c5fd28d98c48ae /src/plugins/accessible/quick/qaccessiblequickitem.cpp | |
parent | 29152ec5208261e3d1ad8fa7de4d22efce3de813 (diff) |
Accessibility: Improve interface handling in Quick
This changes how interfaces are handled:
the QAccessibleQuickItem will simply subclass
all interfaces and dynamically return 0 or the
appropriate interface_cast.
This makes our implementation a lot more flexible.
To make use of the value interface, only a value
property is needed (together with a corresponding role).
Since the implementation of the interfaces became simpler,
the value interface and some text interface improvements
go along with the change.
Change-Id: I003ec3016d48d730a4acac467bce322167842f4d
Reviewed-by: Jan Arve Sæther <[email protected]>
Diffstat (limited to 'src/plugins/accessible/quick/qaccessiblequickitem.cpp')
-rw-r--r-- | src/plugins/accessible/quick/qaccessiblequickitem.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/plugins/accessible/quick/qaccessiblequickitem.cpp b/src/plugins/accessible/quick/qaccessiblequickitem.cpp index 2d41379940..8d36834d48 100644 --- a/src/plugins/accessible/quick/qaccessiblequickitem.cpp +++ b/src/plugins/accessible/quick/qaccessiblequickitem.cpp @@ -228,7 +228,7 @@ QString QAccessibleQuickItem::text(QAccessible::Text textType) const break; } - // the following blocks handles item-specific behavior + // the following block handles item-specific behavior if (role() == QAccessible::EditableText) { if (textType == QAccessible::Value) { QVariant text = object()->property("text"); @@ -241,34 +241,44 @@ QString QAccessibleQuickItem::text(QAccessible::Text textType) const return QString(); } -void *QAccessibleQuickItemValueInterface::interface_cast(QAccessible::InterfaceType t) +void *QAccessibleQuickItem::interface_cast(QAccessible::InterfaceType t) { - if (t == QAccessible::ValueInterface) + QAccessible::Role r = role(); + if (t == QAccessible::ValueInterface && + (r == QAccessible::Slider || + r == QAccessible::SpinBox || + r == QAccessible::Dial || + r == QAccessible::ScrollBar)) return static_cast<QAccessibleValueInterface*>(this); - return QAccessibleQuickItem::interface_cast(t); + + if (t == QAccessible::TextInterface && + (r == QAccessible::EditableText)) + return static_cast<QAccessibleTextInterface*>(this); + + return QQmlAccessible::interface_cast(t); } -QVariant QAccessibleQuickItemValueInterface::currentValue() const +QVariant QAccessibleQuickItem::currentValue() const { return item()->property("value"); } -void QAccessibleQuickItemValueInterface::setCurrentValue(const QVariant &value) +void QAccessibleQuickItem::setCurrentValue(const QVariant &value) { item()->setProperty("value", value); } -QVariant QAccessibleQuickItemValueInterface::maximumValue() const +QVariant QAccessibleQuickItem::maximumValue() const { return item()->property("maximumValue"); } -QVariant QAccessibleQuickItemValueInterface::minimumValue() const +QVariant QAccessibleQuickItem::minimumValue() const { return item()->property("minimumValue"); } -QVariant QAccessibleQuickItemValueInterface::minimumStepSize() const +QVariant QAccessibleQuickItem::minimumStepSize() const { return item()->property("stepSize"); } |