From b31c9d8c03c471c9bb9296408f1f7ee6a512d3db Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Sat, 7 Jun 2014 01:13:25 +0200 Subject: [PATCH] Accessibility OS X: Publish synthetic increase and decrease actions Increase and decrease actions can be generally applied to any value interface. We therefore make them available regardless of the existence of any action interface. Change-Id: If5916c7cfd79812e2139e882a397ac1e040aca78 Reviewed-by: Frederik Gladhorn --- .../cocoa/qcocoaaccessibilityelement.mm | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index b309df6242..9f803e411d 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -43,7 +43,7 @@ #include "qcocoahelpers.h" #include "qcocoawindow.h" #include "private/qaccessiblecache_p.h" - +#include #include #import @@ -430,15 +430,11 @@ if (!iface) return nsActions; - QAccessibleActionInterface *actionInterface = iface->actionInterface(); - if (actionInterface) { - QStringList supportedActionNames = actionInterface->actionNames(); - - foreach (const QString &qtAction, supportedActionNames) { - NSString *nsAction = QCocoaAccessible::getTranslatedAction(qtAction); - if (nsAction) - [nsActions addObject : nsAction]; - } + const QStringList &supportedActionNames = QAccessibleBridgeUtils::effectiveActionNames(iface); + foreach (const QString &qtAction, supportedActionNames) { + NSString *nsAction = QCocoaAccessible::getTranslatedAction(qtAction); + if (nsAction) + [nsActions addObject : nsAction]; } return nsActions; @@ -448,27 +444,25 @@ QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); if (!iface) return nil; // FIXME is that the right return type?? - QAccessibleActionInterface *actionInterface = iface->actionInterface(); - if (actionInterface) { - QString qtAction = QCocoaAccessible::translateAction(action); - - // Return a description from the action interface if this action is not known to the OS. - if (qtAction.isEmpty()) { - QString description = actionInterface->localizedActionDescription(qtAction); - return QCFString::toNSString(description); + QString qtAction = QCocoaAccessible::translateAction(action); + QString description; + // Return a description from the action interface if this action is not known to the OS. + if (qtAction.isEmpty()) { + if (QAccessibleActionInterface *actionInterface = iface->actionInterface()) { + qtAction = QString::fromNSString((NSString *)action); + description = actionInterface->localizedActionDescription(qtAction); } + } else { + description = qAccessibleLocalizedActionDescription(qtAction); } - - return NSAccessibilityActionDescription(action); + return QCFString::toNSString(description); } - (void)accessibilityPerformAction:(NSString *)action { QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); if (iface) { - QAccessibleActionInterface *actionInterface = iface->actionInterface(); - if (actionInterface) { - actionInterface->doAction(QCocoaAccessible::translateAction(action)); - } + const QString qtAction = QCocoaAccessible::translateAction(action); + QAccessibleBridgeUtils::performEffectiveAction(iface, qtAction); } }