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 <frederik.gladhorn@digia.com>
This commit is contained in:
Jan Arve Saether 2014-06-07 01:13:25 +02:00 committed by Frederik Gladhorn
parent e6a94778d0
commit b31c9d8c03

View File

@ -43,7 +43,7 @@
#include "qcocoahelpers.h" #include "qcocoahelpers.h"
#include "qcocoawindow.h" #include "qcocoawindow.h"
#include "private/qaccessiblecache_p.h" #include "private/qaccessiblecache_p.h"
#include <QtPlatformSupport/private/qaccessiblebridgeutils_p.h>
#include <QtGui/qaccessible.h> #include <QtGui/qaccessible.h>
#import <AppKit/NSAccessibility.h> #import <AppKit/NSAccessibility.h>
@ -430,15 +430,11 @@
if (!iface) if (!iface)
return nsActions; return nsActions;
QAccessibleActionInterface *actionInterface = iface->actionInterface(); const QStringList &supportedActionNames = QAccessibleBridgeUtils::effectiveActionNames(iface);
if (actionInterface) { foreach (const QString &qtAction, supportedActionNames) {
QStringList supportedActionNames = actionInterface->actionNames(); NSString *nsAction = QCocoaAccessible::getTranslatedAction(qtAction);
if (nsAction)
foreach (const QString &qtAction, supportedActionNames) { [nsActions addObject : nsAction];
NSString *nsAction = QCocoaAccessible::getTranslatedAction(qtAction);
if (nsAction)
[nsActions addObject : nsAction];
}
} }
return nsActions; return nsActions;
@ -448,27 +444,25 @@
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
if (!iface) if (!iface)
return nil; // FIXME is that the right return type?? return nil; // FIXME is that the right return type??
QAccessibleActionInterface *actionInterface = iface->actionInterface(); QString qtAction = QCocoaAccessible::translateAction(action);
if (actionInterface) { QString description;
QString qtAction = QCocoaAccessible::translateAction(action); // Return a description from the action interface if this action is not known to the OS.
if (qtAction.isEmpty()) {
// Return a description from the action interface if this action is not known to the OS. if (QAccessibleActionInterface *actionInterface = iface->actionInterface()) {
if (qtAction.isEmpty()) { qtAction = QString::fromNSString((NSString *)action);
QString description = actionInterface->localizedActionDescription(qtAction); description = actionInterface->localizedActionDescription(qtAction);
return QCFString::toNSString(description);
} }
} else {
description = qAccessibleLocalizedActionDescription(qtAction);
} }
return QCFString::toNSString(description);
return NSAccessibilityActionDescription(action);
} }
- (void)accessibilityPerformAction:(NSString *)action { - (void)accessibilityPerformAction:(NSString *)action {
QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); QAccessibleInterface *iface = QAccessible::accessibleInterface(axid);
if (iface) { if (iface) {
QAccessibleActionInterface *actionInterface = iface->actionInterface(); const QString qtAction = QCocoaAccessible::translateAction(action);
if (actionInterface) { QAccessibleBridgeUtils::performEffectiveAction(iface, qtAction);
actionInterface->doAction(QCocoaAccessible::translateAction(action));
}
} }
} }