Windows a11y: 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: I82ba01965dc869439b9d741ce681e0c0687263ca
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
bb10
Jan Arve Saether 2014-06-05 13:29:24 +02:00 committed by Frederik Gladhorn
parent a14aff64a1
commit f360dc9297
3 changed files with 54 additions and 48 deletions

View File

@ -2491,6 +2491,23 @@ struct QAccessibleActionStrings
const QString showMenuAction;
const QString setFocusAction;
const QString toggleAction;
QString localizedDescription(const QString &actionName)
{
if (actionName == pressAction)
return QAccessibleActionInterface::tr("Triggers the action");
else if (actionName == increaseAction)
return QAccessibleActionInterface::tr("Increase the value");
else if (actionName == decreaseAction)
return QAccessibleActionInterface::tr("Decrease the value");
else if (actionName == showMenuAction)
return QAccessibleActionInterface::tr("Shows the menu");
else if (actionName == setFocusAction)
return QAccessibleActionInterface::tr("Sets the focus");
else if (actionName == toggleAction)
return QAccessibleActionInterface::tr("Toggles the state");
return QString();
}
};
Q_GLOBAL_STATIC(QAccessibleActionStrings, accessibleActionStrings)
@ -2502,21 +2519,7 @@ QString QAccessibleActionInterface::localizedActionName(const QString &actionNam
QString QAccessibleActionInterface::localizedActionDescription(const QString &actionName) const
{
const QAccessibleActionStrings *strings = accessibleActionStrings();
if (actionName == strings->pressAction)
return tr("Triggers the action");
else if (actionName == strings->increaseAction)
return tr("Increase the value");
else if (actionName == strings->decreaseAction)
return tr("Decrease the value");
else if (actionName == strings->showMenuAction)
return tr("Shows the menu");
else if (actionName == strings->setFocusAction)
return tr("Sets the focus");
else if (actionName == strings->toggleAction)
return tr("Toggles the state");
return QString();
return accessibleActionStrings()->localizedDescription(actionName);
}
/*!
@ -2573,6 +2576,13 @@ const QString &QAccessibleActionInterface::toggleAction()
return accessibleActionStrings()->toggleAction;
}
/*! \internal */
QString qAccessibleLocalizedActionDescription(const QString &actionName)
{
return accessibleActionStrings()->localizedDescription(actionName);
}
#endif
QT_END_NAMESPACE

View File

@ -889,6 +889,7 @@ Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid)
Q_GUI_EXPORT const char *qAccessibleRoleString(QAccessible::Role role);
Q_GUI_EXPORT const char *qAccessibleEventString(QAccessible::Event event);
Q_GUI_EXPORT QString qAccessibleLocalizedActionDescription(const QString &actionName);
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug d, const QAccessibleInterface *iface);

View File

@ -43,7 +43,7 @@
#include "iaccessible2.h"
#include "qwindowsaccessibility.h"
#include <QtPlatformSupport/private/qaccessiblebridgeutils_p.h>
#include <QtGui/qaccessible.h>
#include <QtGui/qclipboard.h>
#include <QtWidgets/qapplication.h>
@ -546,10 +546,7 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::nActions(long *nActions)
accessibleDebugClientCalls(accessible);
if (!accessible)
return E_FAIL;
*nActions = 0;
if (QAccessibleActionInterface *actionIface = actionInterface())
*nActions = actionIface->actionNames().count();
*nActions = QAccessibleBridgeUtils::effectiveActionNames(accessible).count();
return S_OK;
}
@ -559,15 +556,11 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::doAction(long actionIndex)
accessibleDebugClientCalls(accessible);
if (!accessible)
return E_FAIL;
if (QAccessibleActionInterface *actionIface = actionInterface()) {
const QStringList actionNames = actionIface->actionNames();
if (actionIndex < 0 || actionIndex >= actionNames.count())
return E_INVALIDARG;
const QString actionName = actionNames.at(actionIndex);
actionIface->doAction(actionName);
return S_OK;
}
return S_FALSE;
const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(accessible);
if (actionIndex < 0 || actionIndex >= actionNames.count())
return E_INVALIDARG;
const QString actionName = actionNames.at(actionIndex);
return QAccessibleBridgeUtils::performEffectiveAction(accessible, actionName) ? S_OK : S_FALSE;
}
HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_description(long actionIndex, BSTR *description)
@ -577,13 +570,15 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_description(long actionInde
if (!accessible)
return E_FAIL;
*description = 0;
if (QAccessibleActionInterface *actionIface = actionInterface()) {
const QStringList actionNames = actionIface->actionNames();
if (actionIndex < 0 || actionIndex >= actionNames.count())
return E_INVALIDARG;
const QString actionName = actionNames.at(actionIndex);
const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(accessible);
if (actionIndex < 0 || actionIndex >= actionNames.count())
return E_INVALIDARG;
const QString actionName = actionNames.at(actionIndex);
if (QAccessibleActionInterface *actionIface = actionInterface())
*description = QStringToBSTR(actionIface->localizedActionDescription(actionName));
}
else
*description = QStringToBSTR(qAccessibleLocalizedActionDescription(actionName));
return *description ? S_OK : S_FALSE;
}
@ -623,13 +618,11 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_name(long actionIndex, BSTR
if (!accessible)
return E_FAIL;
*name = 0;
if (QAccessibleActionInterface *actionIface = actionInterface()) {
const QStringList actionNames = actionIface->actionNames();
if (actionIndex < 0 || actionIndex >= actionNames.count())
return E_INVALIDARG;
const QString actionName = actionNames.at(actionIndex);
*name = QStringToBSTR(actionName);
}
const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(accessible);
if (actionIndex < 0 || actionIndex >= actionNames.count())
return E_INVALIDARG;
const QString actionName = actionNames.at(actionIndex);
*name = QStringToBSTR(actionName);
return *name ? S_OK : S_FALSE;
}
@ -640,14 +633,16 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::get_localizedName(long actionIn
if (!accessible)
return E_FAIL;
*localizedName = 0;
if (QAccessibleActionInterface *actionIface = actionInterface()) {
const QStringList actionNames = actionIface->actionNames();
if (actionIndex < 0 || actionIndex >= actionNames.count())
return E_INVALIDARG;
const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(accessible);
if (actionIndex < 0 || actionIndex >= actionNames.count())
return E_INVALIDARG;
const QString actionName = actionNames.at(actionIndex);
const QString actionName = actionNames.at(actionIndex);
if (QAccessibleActionInterface *actionIface = actionInterface())
*localizedName = QStringToBSTR(actionIface->localizedActionName(actionName));
}
else
*localizedName = QStringToBSTR(QAccessibleActionInterface::tr(qPrintable(actionName)));
return *localizedName ? S_OK : S_FALSE;
}