Refactor QAccessibleActionInterface.
Some refinements done by Jan-Arve Sæther. Change-Id: I99195b3c7273316cfa9c46e451924bbcfddd11a9 Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
This commit is contained in:
parent
663cd17718
commit
4dc25c1f29
@ -1060,39 +1060,6 @@ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > QAccessibleInterfa
|
||||
\sa text(), role()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn int QAccessibleInterface::userActionCount(int child) const
|
||||
|
||||
Returns the number of custom actions of the object, or of the
|
||||
object's child if \a child is not 0.
|
||||
|
||||
The \c Action type enumerates predefined actions: these
|
||||
are not included in the returned value.
|
||||
|
||||
\sa actionText(), doAction()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QAccessibleInterface::actionText(int action, Text t, int child) const
|
||||
|
||||
Returns the text property \a t of the action \a action supported by
|
||||
the object, or of the object's child if \a child is not 0.
|
||||
|
||||
\sa text(), userActionCount()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn bool QAccessibleInterface::doAction(int action, int child, const QVariantList ¶ms)
|
||||
|
||||
Asks the object, or the object's \a child if \a child is not 0, to
|
||||
execute \a action using the parameters, \a params. Returns true if
|
||||
the action could be executed; otherwise returns false.
|
||||
|
||||
\a action can be a predefined or a custom action.
|
||||
|
||||
\sa userActionCount(), actionText()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QColor QAccessibleInterface::backgroundColor()
|
||||
\internal
|
||||
|
@ -389,11 +389,6 @@ public:
|
||||
virtual Role role(int child = 0) const = 0;
|
||||
virtual State state(int child = 0) const = 0;
|
||||
|
||||
// action
|
||||
virtual int userActionCount(int child = 0) const = 0;
|
||||
virtual QString actionText(int action, Text t, int child = 0) const = 0;
|
||||
virtual bool doAction(int action, int child = 0, const QVariantList ¶ms = QVariantList()) = 0;
|
||||
|
||||
virtual QVariant invokeMethod(Method method, int child = 0,
|
||||
const QVariantList ¶ms = QVariantList());
|
||||
|
||||
|
@ -109,18 +109,6 @@ QT_BEGIN_NAMESPACE
|
||||
\link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QAccessibleActionInterface
|
||||
\ingroup accessibility
|
||||
\internal
|
||||
\preliminary
|
||||
|
||||
\brief The QAccessibleActionInterface class implements support for
|
||||
the IAccessibleAction interface.
|
||||
|
||||
\link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QAccessibleImageInterface
|
||||
\ingroup accessibility
|
||||
@ -133,6 +121,131 @@ QT_BEGIN_NAMESPACE
|
||||
\link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class QAccessibleActionInterface
|
||||
\ingroup accessibility
|
||||
\internal
|
||||
\preliminary
|
||||
|
||||
\brief The QAccessibleActionInterface class implements support for
|
||||
invocable actions in the interface.
|
||||
|
||||
Each accessible should implement the action interface if it supports any actions.
|
||||
The supported actions should adhere to the naming scheme inside the QAccessible2 namespace.
|
||||
Custom actions can be added.
|
||||
|
||||
When subclassing QAccessibleActionInterface you need to provide a list of actionNames which
|
||||
is the primary means to discover the available actions. Action names are never localized.
|
||||
In order to present actions to the user there are two functions that need to return localized versions
|
||||
of the name and give a description of the action.
|
||||
|
||||
In order to invoke the action, doAction is called with an action name.
|
||||
|
||||
Most widgets will simply implement the PressAction. This is what happens when the widget is activated by
|
||||
being clicked on, space pressed or similar.
|
||||
|
||||
\link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList QAccessibleActionInterface::actionNames() const
|
||||
|
||||
Returns a list of valid actions. The actions returned should be in preferred order,
|
||||
i.e. the action that the user most likely wants to trigger should be returned first,
|
||||
while the least likely action should be returned last.
|
||||
|
||||
The list does only contain actions that *can* be invoked. Therefore it,
|
||||
won't return disabled actions, or actions associated with disabled UI
|
||||
controls.
|
||||
|
||||
The list can also be empty.
|
||||
|
||||
\sa localizedActionName(), doAction()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QAccessibleActionInterface::localizedActionName(const QString &name) const
|
||||
|
||||
Returns a localized action name of \a name.
|
||||
|
||||
\sa actionNames(), localizedActionDescription()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QString QAccessibleActionInterface::localizedActionDescription(const QString &name) const
|
||||
|
||||
Returns a localized action description of \a name.
|
||||
|
||||
This is what should be presented to the user. The actionNames should always
|
||||
be untranslated to make them consistent for screen readers.
|
||||
|
||||
\sa actionNames(), localizedActionName()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QAccessibleActionInterface::doAction(const QString &actionName) const
|
||||
|
||||
Invokes the action specified by \a actionName
|
||||
|
||||
\sa actionNames()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QStringList QAccessibleActionInterface::keyBindingsForAction(const QString &actionName) const
|
||||
|
||||
Returns a list of the keyboard shortcuts available for invoking the action named \a actionName
|
||||
|
||||
\sa actionNames()
|
||||
*/
|
||||
|
||||
const QString QAccessibleActionInterface::PressAction = QStringLiteral("Press");
|
||||
const QString QAccessibleActionInterface::IncreaseAction = QStringLiteral("Increase");
|
||||
const QString QAccessibleActionInterface::DecreaseAction = QStringLiteral("Decrease");
|
||||
const QString QAccessibleActionInterface::ShowMenuAction = QStringLiteral("ShowMenu");
|
||||
const QString QAccessibleActionInterface::SetFocusAction = QStringLiteral("SetFocus");
|
||||
const QString QAccessibleActionInterface::CheckAction = QStringLiteral("Check");
|
||||
const QString QAccessibleActionInterface::UncheckAction = QStringLiteral("Uncheck");
|
||||
|
||||
QString QAccessibleActionInterface::localizedActionName(const QString &actionName) const
|
||||
{
|
||||
if (actionName == PressAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Press");
|
||||
else if (actionName == IncreaseAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Increase");
|
||||
else if (actionName == DecreaseAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Decrease");
|
||||
else if (actionName == ShowMenuAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "ShowMenu");
|
||||
else if (actionName == SetFocusAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "SetFocus");
|
||||
else if (actionName == CheckAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Check");
|
||||
else if (actionName == UncheckAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Uncheck");
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QAccessibleActionInterface::localizedActionDescription(const QString &actionName) const
|
||||
{
|
||||
if (actionName == PressAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Triggers the action");
|
||||
else if (actionName == IncreaseAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Increase the value");
|
||||
else if (actionName == DecreaseAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Decrease the value");
|
||||
else if (actionName == ShowMenuAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Shows the menu");
|
||||
else if (actionName == SetFocusAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Sets the focus");
|
||||
else if (actionName == CheckAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Checks the checkbox");
|
||||
else if (actionName == UncheckAction)
|
||||
return QCoreApplication::translate("QAccessibleActionInterface", "Unchecks the checkbox");
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
@ -326,17 +326,24 @@ friend class QAbstractItemView;
|
||||
friend class QAbstractItemViewPrivate;
|
||||
};
|
||||
|
||||
class Q_GUI_EXPORT QAccessibleActionInterface : public QAccessible2Interface
|
||||
class Q_GUI_EXPORT QAccessibleActionInterface: public QAccessible2Interface
|
||||
{
|
||||
public:
|
||||
inline QAccessible2Interface *qAccessibleActionCastHelper() { return this; }
|
||||
|
||||
virtual int actionCount() = 0;
|
||||
virtual void doAction(int actionIndex) = 0;
|
||||
virtual QString localizedDescription(int actionIndex) = 0;
|
||||
virtual QString name(int actionIndex) = 0;
|
||||
virtual QString localizedName(int actionIndex) = 0;
|
||||
virtual QStringList keyBindings(int actionIndex) = 0;
|
||||
virtual QStringList actionNames() const = 0;
|
||||
virtual QString localizedActionName(const QString &name) const;
|
||||
virtual QString localizedActionDescription(const QString &name) const;
|
||||
virtual void doAction(const QString &actionName) = 0;
|
||||
virtual QStringList keyBindingsForAction(const QString &actionName) const = 0;
|
||||
|
||||
static const QString PressAction;
|
||||
static const QString IncreaseAction;
|
||||
static const QString DecreaseAction;
|
||||
static const QString ShowMenuAction;
|
||||
static const QString SetFocusAction;
|
||||
static const QString CheckAction;
|
||||
static const QString UncheckAction;
|
||||
};
|
||||
|
||||
class Q_GUI_EXPORT QAccessibleImageInterface : public QAccessible2Interface
|
||||
|
@ -154,44 +154,6 @@ void QAccessibleObject::setText(Text, int, const QString &)
|
||||
{
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
int QAccessibleObject::userActionCount(int) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
bool QAccessibleObject::doAction(int, int, const QVariantList &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char * const action_text[][5] =
|
||||
{
|
||||
// Name, Description, Value, Help, Accelerator
|
||||
{ "Press", "", "", "", "Space" },
|
||||
{ "SetFocus", "Passes focus to this widget", "", "", "" },
|
||||
{ "Increase", "", "", "", "" },
|
||||
{ "Decrease", "", "", "", "" },
|
||||
{ "Accept", "", "", "", "" },
|
||||
{ "Cancel", "", "", "", "" },
|
||||
{ "Select", "", "", "", "" },
|
||||
{ "ClearSelection", "", "", "", "" },
|
||||
{ "RemoveSelection", "", "", "", "" },
|
||||
{ "ExtendSelection", "", "", "", "" },
|
||||
{ "AddToSelection", "", "", "", "" }
|
||||
};
|
||||
|
||||
/*! \reimp */
|
||||
QString QAccessibleObject::actionText(int action, Text t, int child) const
|
||||
{
|
||||
if (child || action > FirstStandardAction || action < LastStandardAction || t > Accelerator)
|
||||
return QString();
|
||||
|
||||
return QString::fromLatin1(action_text[-(action - FirstStandardAction)][t]);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\class QAccessibleApplication
|
||||
\brief The QAccessibleApplication class implements the QAccessibleInterface for QApplication.
|
||||
@ -353,45 +315,6 @@ QAccessible::State QAccessibleApplication::state(int) const
|
||||
return QGuiApplication::activeWindow() ? Focused : Normal;
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
int QAccessibleApplication::userActionCount(int) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
bool QAccessibleApplication::doAction(int action, int child, const QVariantList ¶m)
|
||||
{
|
||||
//###Move to IA2 action interface at some point to get rid of the ambiguity.
|
||||
/* //### what is action == 0 and action == 1 ?????
|
||||
if (action == 0 || action == 1) {
|
||||
QWindow *w = 0;
|
||||
w = QGuiApplication::activeWindow();
|
||||
if (!w)
|
||||
w = topLevelWindows().at(0);
|
||||
if (!w)
|
||||
return false;
|
||||
w->requestActivateWindow();
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
return QAccessibleObject::doAction(action, child, param);
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
QString QAccessibleApplication::actionText(int action, Text text, int child) const
|
||||
{
|
||||
QString str;
|
||||
if ((action == 0 || action == 1) && !child) switch (text) {
|
||||
case Name:
|
||||
return QGuiApplication::tr("Activate");
|
||||
case Description:
|
||||
return QGuiApplication::tr("Activates the program's main window");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return QAccessibleObject::actionText(action, text, child);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#define QACCESSIBLEOBJECT_H
|
||||
|
||||
#include "qaccessible.h"
|
||||
#include "qaccessible2.h"
|
||||
|
||||
QT_BEGIN_HEADER
|
||||
|
||||
@ -67,11 +68,6 @@ public:
|
||||
QRect rect(int child = 0) const;
|
||||
void setText(Text t, int child, const QString &text);
|
||||
|
||||
// actions
|
||||
int userActionCount(int child = 0) const;
|
||||
bool doAction(int action, int child = 0, const QVariantList ¶ms = QVariantList());
|
||||
QString actionText(int action, Text t, int child = 0) const;
|
||||
|
||||
protected:
|
||||
virtual ~QAccessibleObject();
|
||||
|
||||
@ -82,6 +78,7 @@ private:
|
||||
|
||||
class Q_GUI_EXPORT QAccessibleApplication : public QAccessibleObject
|
||||
{
|
||||
Q_ACCESSIBLE_OBJECT
|
||||
public:
|
||||
QAccessibleApplication();
|
||||
|
||||
@ -101,11 +98,6 @@ public:
|
||||
QString text(Text t, int child = 0) const;
|
||||
Role role(int child = 0) const;
|
||||
State state(int child = 0) const;
|
||||
|
||||
// actions
|
||||
int userActionCount(int child = 0) const;
|
||||
bool doAction(int action, int child = 0, const QVariantList ¶ms = QVariantList());
|
||||
QString actionText(int action, Text t, int child = 0) const;
|
||||
};
|
||||
|
||||
#endif // QT_NO_ACCESSIBILITY
|
||||
|
@ -486,7 +486,7 @@ QAccessibleInterface *QAccessibleItemRow::parent() const
|
||||
return new QAccessibleItemView(view->viewport());
|
||||
}
|
||||
|
||||
QAccessibleInterface *QAccessibleItemRow::child(int index) const
|
||||
QAccessibleInterface *QAccessibleItemRow::child(int) const
|
||||
{
|
||||
// FIXME? port to IA2 table2.
|
||||
return 0;
|
||||
@ -1500,47 +1500,25 @@ public:
|
||||
return QAccessible::Unrelated;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_ACTION
|
||||
int userActionCount(int) const { return 0; }
|
||||
QString actionText(int, Text, int) const { return QString(); }
|
||||
bool doAction(int actionIndex, int, const QVariantList &) {
|
||||
doAction(actionIndex);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// action interface
|
||||
int actionCount() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void doAction(int actionIndex)
|
||||
|
||||
QStringList actionNames() const
|
||||
{
|
||||
if (actionIndex == Press || actionIndex == DefaultAction)
|
||||
return QStringList() << PressAction;
|
||||
}
|
||||
|
||||
void doAction(const QString &actionName)
|
||||
{
|
||||
if (actionName == PressAction)
|
||||
m_parent->setCurrentIndex(m_index);
|
||||
}
|
||||
|
||||
QString localizedDescription(int actionIndex)
|
||||
QStringList keyBindingsForAction(const QString &) const
|
||||
{
|
||||
if (actionIndex == 0)
|
||||
return QTabWidget::tr("Select this tab");
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString name(int actionIndex)
|
||||
{
|
||||
if (actionIndex == 0)
|
||||
return QStringLiteral("Select tab");
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString localizedName(int actionIndex)
|
||||
{
|
||||
if (actionIndex == 0)
|
||||
return QTabWidget::tr("Select tab");
|
||||
return QString();
|
||||
}
|
||||
QStringList keyBindings(int actionIndex) {
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
@ -1684,7 +1662,6 @@ QComboBox *QAccessibleComboBox::comboBox() const
|
||||
|
||||
QAccessibleInterface* QAccessibleComboBox::child(int index) const
|
||||
{
|
||||
QAccessibleInterface* target = 0;
|
||||
if (index == 0) {
|
||||
QAbstractItemView *view = comboBox()->view();
|
||||
//QWidget *parent = view ? view->parentWidget() : 0;
|
||||
@ -1717,7 +1694,8 @@ int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString QAccessibleComboBox::text(Text t, int child) const
|
||||
/*! \reimp */
|
||||
QString QAccessibleComboBox::text(Text t, int) const
|
||||
{
|
||||
QString str;
|
||||
|
||||
@ -1746,54 +1724,30 @@ QString QAccessibleComboBox::text(Text t, int child) const
|
||||
return str;
|
||||
}
|
||||
|
||||
bool QAccessibleComboBox::doAction(int action, int, const QVariantList &)
|
||||
QStringList QAccessibleComboBox::actionNames() const
|
||||
{
|
||||
if (action == DefaultAction || action == Press) {
|
||||
return QStringList() << ShowMenuAction;
|
||||
}
|
||||
|
||||
QString QAccessibleComboBox::localizedActionDescription(const QString &actionName) const
|
||||
{
|
||||
if (actionName == ShowMenuAction)
|
||||
return QComboBox::tr("Open the combo box selection popup");
|
||||
return QString();
|
||||
}
|
||||
|
||||
void QAccessibleComboBox::doAction(const QString &actionName)
|
||||
{
|
||||
if (actionName == ShowMenuAction) {
|
||||
if (comboBox()->view()->isVisible()) {
|
||||
comboBox()->hidePopup();
|
||||
} else {
|
||||
comboBox()->showPopup();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString QAccessibleComboBox::actionText(int action, Text t, int child) const
|
||||
{
|
||||
QString text;
|
||||
if (t == Name && (action == DefaultAction || action == Press))
|
||||
text = comboBox()->view()->isVisible() ? QComboBox::tr("Close") : QComboBox::tr("Open");
|
||||
return text;
|
||||
}
|
||||
|
||||
int QAccessibleComboBox::actionCount()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void QAccessibleComboBox::doAction(int actionIndex)
|
||||
{
|
||||
doAction(0, 0, QVariantList());
|
||||
}
|
||||
|
||||
QString QAccessibleComboBox::localizedDescription
|
||||
(int actionIndex)
|
||||
{
|
||||
return QComboBox::tr("Opens the selection list of this combo box.");
|
||||
}
|
||||
|
||||
QString QAccessibleComboBox::name(int actionIndex)
|
||||
{
|
||||
return QStringLiteral("Popup Combobox Menu");
|
||||
}
|
||||
|
||||
QString QAccessibleComboBox::localizedName(int actionIndex)
|
||||
{
|
||||
return QComboBox::tr("Popup Combobox Menu");
|
||||
}
|
||||
|
||||
QStringList QAccessibleComboBox::keyBindings(int)
|
||||
QStringList QAccessibleComboBox::keyBindingsForAction(const QString &/*actionName*/) const
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
@ -263,16 +263,11 @@ public:
|
||||
|
||||
QString text(Text t, int child) const;
|
||||
|
||||
bool doAction(int action, int child, const QVariantList ¶ms);
|
||||
QString actionText(int action, Text t, int child) const;
|
||||
|
||||
// QAccessibleActionInterface
|
||||
int actionCount();
|
||||
void doAction(int actionIndex);
|
||||
QString localizedDescription(int actionIndex);
|
||||
QString name(int actionIndex);
|
||||
QString localizedName(int actionIndex);
|
||||
QStringList keyBindings(int actionIndex);
|
||||
QStringList actionNames() const;
|
||||
QString localizedActionDescription(const QString &actionName) const;
|
||||
void doAction(const QString &actionName);
|
||||
QStringList keyBindingsForAction(const QString &actionName) const;
|
||||
|
||||
protected:
|
||||
QComboBox *comboBox() const;
|
||||
|
@ -110,29 +110,6 @@ QAccessible::State QAccessibleMenu::state(int child) const
|
||||
return s;
|
||||
}
|
||||
|
||||
QString QAccessibleMenu::actionText(int action, QAccessible::Text text, int child) const
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
return QAccessibleWidget::actionText(action, text, child);
|
||||
}
|
||||
|
||||
bool QAccessibleMenu::doAction(int act, int child, const QVariantList &)
|
||||
{
|
||||
// Q_ASSERT(child == 0);
|
||||
if (!child || act != QAccessible::DefaultAction)
|
||||
return false;
|
||||
|
||||
QAction *action = menu()->actions().value(child-1, 0);
|
||||
if (!action || !action->isEnabled())
|
||||
return false;
|
||||
|
||||
if (action->menu() && action->menu()->isVisible())
|
||||
action->menu()->hide();
|
||||
else
|
||||
menu()->setActiveAction(action);
|
||||
return true;
|
||||
}
|
||||
|
||||
QAccessibleInterface *QAccessibleMenu::child(int index) const
|
||||
{
|
||||
if (index < childCount())
|
||||
@ -246,35 +223,12 @@ QAccessible::State QAccessibleMenuBar::state(int child) const
|
||||
return s;
|
||||
}
|
||||
|
||||
QString QAccessibleMenuBar::actionText(int action, QAccessible::Text text, int child) const
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
return QAccessibleWidget::actionText(action, text, child);
|
||||
}
|
||||
|
||||
bool QAccessibleMenuBar::doAction(int, int child, const QVariantList &)
|
||||
{
|
||||
// Q_ASSERT(child == 0);
|
||||
QAction *action = menuBar()->actions().value(child-1, 0);
|
||||
if (!action || !action->isEnabled())
|
||||
return false;
|
||||
if (action->menu() && action->menu()->isVisible())
|
||||
action->menu()->hide();
|
||||
else {
|
||||
menuBar()->setActiveAction(action);
|
||||
}
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // QT_NO_MENUBAR
|
||||
|
||||
QAccessibleMenuItem::QAccessibleMenuItem(QWidget *owner, QAction *action) : m_action(action), m_owner(owner)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QAccessibleMenuItem::~QAccessibleMenuItem()
|
||||
{}
|
||||
|
||||
@ -292,66 +246,6 @@ int QAccessibleMenuItem::childCount() const
|
||||
return m_action->menu() ? 1 : 0;
|
||||
}
|
||||
|
||||
QString QAccessibleMenuItem::actionText(int action, Text text, int child) const
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
if (!m_action || m_action->isSeparator())
|
||||
return QString();
|
||||
|
||||
if (text == Name && ((action == Press) || (action == DefaultAction))) {
|
||||
if (m_action->menu()) {
|
||||
return QMenu::tr("Open");
|
||||
}
|
||||
return QMenu::tr("Execute");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
//QAction *action = menuBar()->actions().value(child-1, 0);
|
||||
//if (!action || !action->isEnabled())
|
||||
// return false;
|
||||
//if (action->menu() && action->menu()->isVisible())
|
||||
// action->menu()->hide();
|
||||
//else
|
||||
// menuBar()->setActiveAction(action);
|
||||
//return true;
|
||||
|
||||
|
||||
|
||||
bool QAccessibleMenuItem::doAction(int action, int child, const QVariantList & /*params = QVariantList()*/ )
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
if ((action != Press) && (action != DefaultAction))
|
||||
return false;
|
||||
if (!m_action->isEnabled())
|
||||
return false;
|
||||
|
||||
if (QMenuBar *bar = qobject_cast<QMenuBar*>(owner())) {
|
||||
if (m_action->menu() && m_action->menu()->isVisible()) {
|
||||
m_action->menu()->hide();
|
||||
return true;
|
||||
} else {
|
||||
bar->setActiveAction(m_action);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if (QMenu *menu = qobject_cast<QMenu*>(owner())){
|
||||
if (m_action->menu() && m_action->menu()->isVisible()) {
|
||||
m_action->menu()->hide();
|
||||
return true;
|
||||
} else {
|
||||
menu->setActiveAction(m_action);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// no menu
|
||||
m_action->trigger();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int QAccessibleMenuItem::indexOfChild(const QAccessibleInterface * child) const
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
@ -462,11 +356,8 @@ QAccessible::Relation QAccessibleMenuItem::relationTo ( int child, const QAccess
|
||||
return Unrelated;
|
||||
}
|
||||
|
||||
QAccessible::Role QAccessibleMenuItem::role(int child) const
|
||||
QAccessible::Role QAccessibleMenuItem::role(int) const
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
// if (m_action->menu())
|
||||
// return PopupMenu;
|
||||
return m_action->isSeparator() ? Separator : MenuItem;
|
||||
}
|
||||
|
||||
@ -530,11 +421,66 @@ QString QAccessibleMenuItem::text ( Text t, int child ) const
|
||||
return str;
|
||||
}
|
||||
|
||||
int QAccessibleMenuItem::userActionCount ( int /*child*/ ) const
|
||||
|
||||
QString QAccessibleMenuItem::actionText(int action, Text text, int child) const
|
||||
{
|
||||
return 0;
|
||||
Q_ASSERT(child == 0);
|
||||
if (!m_action || m_action->isSeparator())
|
||||
return QString();
|
||||
|
||||
if (text == Name && ((action == Press) || (action == DefaultAction))) {
|
||||
if (m_action->menu()) {
|
||||
return QMenu::tr("Open");
|
||||
}
|
||||
return QMenu::tr("Execute");
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QStringList QAccessibleMenuItem::actionNames() const
|
||||
{
|
||||
QStringList actions;
|
||||
if (!m_action || m_action->isSeparator())
|
||||
return actions;
|
||||
|
||||
if (m_action->menu()) {
|
||||
actions << ShowMenuAction;
|
||||
} else {
|
||||
actions << PressAction;
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
|
||||
void QAccessibleMenuItem::doAction(const QString &actionName)
|
||||
{
|
||||
if (!m_action->isEnabled())
|
||||
return;
|
||||
|
||||
if (actionName == PressAction) {
|
||||
m_action->trigger();
|
||||
} else if (actionName == ShowMenuAction) {
|
||||
if (QMenuBar *bar = qobject_cast<QMenuBar*>(owner())) {
|
||||
if (m_action->menu() && m_action->menu()->isVisible()) {
|
||||
m_action->menu()->hide();
|
||||
} else {
|
||||
bar->setActiveAction(m_action);
|
||||
}
|
||||
} else if (QMenu *menu = qobject_cast<QMenu*>(owner())){
|
||||
if (m_action->menu() && m_action->menu()->isVisible()) {
|
||||
m_action->menu()->hide();
|
||||
} else {
|
||||
menu->setActiveAction(m_action);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QStringList QAccessibleMenuItem::keyBindingsForAction(const QString &) const
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
|
||||
QAction *QAccessibleMenuItem::action() const
|
||||
{
|
||||
return m_action;
|
||||
|
@ -70,9 +70,6 @@ public:
|
||||
int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
|
||||
int indexOfChild( const QAccessibleInterface *child ) const;
|
||||
|
||||
QString actionText(int action, QAccessible::Text text, int child) const;
|
||||
bool doAction(int action, int child, const QVariantList ¶ms);
|
||||
|
||||
protected:
|
||||
QMenu *menu() const;
|
||||
};
|
||||
@ -93,18 +90,15 @@ public:
|
||||
int navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const;
|
||||
int indexOfChild( const QAccessibleInterface *child ) const;
|
||||
|
||||
QString actionText(int action, QAccessible::Text text, int child) const;
|
||||
bool doAction(int action, int child, const QVariantList ¶ms);
|
||||
|
||||
protected:
|
||||
QMenuBar *menuBar() const;
|
||||
};
|
||||
#endif // QT_NO_MENUBAR
|
||||
|
||||
|
||||
|
||||
class QAccessibleMenuItem : public QAccessibleInterface
|
||||
class QAccessibleMenuItem : public QAccessibleInterface, public QAccessibleActionInterface
|
||||
{
|
||||
Q_ACCESSIBLE_OBJECT
|
||||
public:
|
||||
explicit QAccessibleMenuItem(QWidget *owner, QAction *w);
|
||||
|
||||
@ -112,7 +106,6 @@ public:
|
||||
virtual QString actionText ( int action, Text t, int child ) const;
|
||||
virtual int childAt ( int x, int y ) const;
|
||||
virtual int childCount () const;
|
||||
virtual bool doAction ( int action, int child, const QVariantList & params = QVariantList() );
|
||||
virtual int indexOfChild ( const QAccessibleInterface * child ) const;
|
||||
virtual bool isValid () const;
|
||||
|
||||
@ -126,11 +119,13 @@ public:
|
||||
virtual void setText ( Text t, int child, const QString & text );
|
||||
virtual State state ( int child ) const;
|
||||
virtual QString text ( Text t, int child ) const;
|
||||
virtual int userActionCount ( int child ) const;
|
||||
|
||||
// QAccessibleActionInterface
|
||||
QStringList actionNames() const;
|
||||
void doAction(const QString &actionName);
|
||||
QStringList keyBindingsForAction(const QString &actionName) const;
|
||||
|
||||
QWidget *owner() const;
|
||||
|
||||
|
||||
protected:
|
||||
QAction *action() const;
|
||||
private:
|
||||
|
@ -88,14 +88,6 @@ QString QAccessibleAbstractSpinBox::text(Text t, int child) const
|
||||
return QAccessibleWidget::text(t, 0);
|
||||
}
|
||||
|
||||
bool QAccessibleAbstractSpinBox::doAction(int action, int child, const QVariantList ¶ms)
|
||||
{
|
||||
Q_UNUSED(child)
|
||||
if (!widget()->isEnabled())
|
||||
return false;
|
||||
return QAccessibleWidget::doAction(action, 0, params);
|
||||
}
|
||||
|
||||
QVariant QAccessibleAbstractSpinBox::currentValue()
|
||||
{
|
||||
QVariant result = abstractSpinBox()->property("value");
|
||||
@ -166,14 +158,6 @@ QSpinBox *QAccessibleSpinBox::spinBox() const
|
||||
return qobject_cast<QSpinBox*>(object());
|
||||
}
|
||||
|
||||
bool QAccessibleSpinBox::doAction(int action, int child, const QVariantList ¶ms)
|
||||
{
|
||||
Q_UNUSED(child)
|
||||
if (!widget()->isEnabled())
|
||||
return false;
|
||||
|
||||
return QAccessibleAbstractSpinBox::doAction(action, 0, params);
|
||||
}
|
||||
|
||||
// ================================== QAccessibleDoubleSpinBox ==================================
|
||||
QAccessibleDoubleSpinBox::QAccessibleDoubleSpinBox(QWidget *widget)
|
||||
@ -276,23 +260,6 @@ QString QAccessibleSlider::text(Text t, int child) const
|
||||
return QAccessibleAbstractSlider::text(t, child);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn int QAccessibleSlider::defaultAction(int child) const
|
||||
|
||||
Returns the default action for the given \a child. The base class
|
||||
implementation returns 0.
|
||||
*/
|
||||
int QAccessibleSlider::defaultAction(int /*child*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
QString QAccessibleSlider::actionText(int /*action*/, Text /*t*/, int /*child*/) const
|
||||
{
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
QAccessibleAbstractSlider::QAccessibleAbstractSlider(QWidget *w, Role r)
|
||||
: QAccessibleWidget(w, r)
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ class QDoubleSpinBox;
|
||||
class QDial;
|
||||
|
||||
#ifndef QT_NO_SPINBOX
|
||||
class QAccessibleAbstractSpinBox: public QAccessibleWidget, public QAccessibleValueInterface
|
||||
class QAccessibleAbstractSpinBox: public QAccessibleWidget, public QAccessibleValueInterface // TODO, public QAccessibleActionInterface
|
||||
{
|
||||
Q_ACCESSIBLE_OBJECT
|
||||
public:
|
||||
@ -86,7 +86,6 @@ class QAccessibleSpinBox : public QAccessibleAbstractSpinBox
|
||||
{
|
||||
public:
|
||||
explicit QAccessibleSpinBox(QWidget *w);
|
||||
bool doAction(int action, int child, const QVariantList ¶ms);
|
||||
|
||||
protected:
|
||||
QSpinBox *spinBox() const;
|
||||
@ -142,9 +141,6 @@ public:
|
||||
explicit QAccessibleSlider(QWidget *w);
|
||||
QString text(Text t, int child) const;
|
||||
|
||||
int defaultAction(int child) const;
|
||||
QString actionText(int action, Text t, int child) const;
|
||||
|
||||
protected:
|
||||
QSlider *slider() const;
|
||||
};
|
||||
|
@ -104,75 +104,23 @@ QAbstractButton *QAccessibleButton::button() const
|
||||
return qobject_cast<QAbstractButton*>(object());
|
||||
}
|
||||
|
||||
QString QAccessibleButton::actionText(int action, Text text, int child) const
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
|
||||
if (text == Name) switch (action) {
|
||||
case Press:
|
||||
case DefaultAction: // press, checking or open
|
||||
switch (role(0)) {
|
||||
case ButtonMenu:
|
||||
return QPushButton::tr("Open");
|
||||
case CheckBox:
|
||||
{
|
||||
if (state(0) & Checked)
|
||||
return QCheckBox::tr("Uncheck");
|
||||
QCheckBox *cb = qobject_cast<QCheckBox*>(object());
|
||||
if (!cb || !cb->isTristate() || cb->checkState() == Qt::PartiallyChecked)
|
||||
return QCheckBox::tr("Check");
|
||||
return QCheckBox::tr("Toggle");
|
||||
}
|
||||
break;
|
||||
case RadioButton:
|
||||
return QRadioButton::tr("Check");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return QAccessibleWidget::actionText(action, text, child);
|
||||
}
|
||||
|
||||
bool QAccessibleButton::doAction(int action, int child, const QVariantList ¶ms)
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
if (!widget()->isEnabled())
|
||||
return false;
|
||||
|
||||
switch (action) {
|
||||
case DefaultAction:
|
||||
case Press:
|
||||
{
|
||||
#ifndef QT_NO_MENU
|
||||
QPushButton *pb = qobject_cast<QPushButton*>(object());
|
||||
if (pb && pb->menu())
|
||||
pb->showMenu();
|
||||
else
|
||||
#endif
|
||||
button()->animateClick();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return QAccessibleWidget::doAction(action, child, params);
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
QString QAccessibleButton::text(Text t, int child) const
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
QString str;
|
||||
switch (t) {
|
||||
case Accelerator:
|
||||
{
|
||||
{
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
QPushButton *pb = qobject_cast<QPushButton*>(object());
|
||||
if (pb && pb->isDefault())
|
||||
str = (QString)QKeySequence(Qt::Key_Enter);
|
||||
QPushButton *pb = qobject_cast<QPushButton*>(object());
|
||||
if (pb && pb->isDefault())
|
||||
str = (QString)QKeySequence(Qt::Key_Enter);
|
||||
#endif
|
||||
if (str.isEmpty())
|
||||
str = qt_accHotKey(button()->text());
|
||||
}
|
||||
break;
|
||||
if (str.isEmpty())
|
||||
str = qt_accHotKey(button()->text());
|
||||
}
|
||||
break;
|
||||
case Name:
|
||||
str = widget()->accessibleName();
|
||||
if (str.isEmpty())
|
||||
@ -189,7 +137,7 @@ QString QAccessibleButton::text(Text t, int child) const
|
||||
QAccessible::State QAccessibleButton::state(int child) const
|
||||
{
|
||||
Q_ASSERT(child == 0);
|
||||
State state = QAccessibleWidget::state(0);
|
||||
State state = QAccessibleWidget::state();
|
||||
|
||||
QAbstractButton *b = button();
|
||||
QCheckBox *cb = qobject_cast<QCheckBox *>(b);
|
||||
@ -212,79 +160,68 @@ QAccessible::State QAccessibleButton::state(int child) const
|
||||
return state;
|
||||
}
|
||||
|
||||
int QAccessibleButton::actionCount()
|
||||
QStringList QAccessibleButton::actionNames() const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void QAccessibleButton::doAction(int actionIndex)
|
||||
{
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
button()->click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString QAccessibleButton::localizedDescription(int actionIndex)
|
||||
{
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
if (button()->isCheckable()) {
|
||||
return QLatin1String("Toggles the button.");
|
||||
}
|
||||
return QLatin1String("Clicks the button.");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString QAccessibleButton::name(int actionIndex)
|
||||
{
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
if (button()->isCheckable()) {
|
||||
if (button()->isChecked()) {
|
||||
return QLatin1String("Uncheck");
|
||||
QStringList names;
|
||||
if (widget()->isEnabled()) {
|
||||
switch (role()) {
|
||||
case ButtonMenu:
|
||||
names << ShowMenuAction;
|
||||
break;
|
||||
case RadioButton:
|
||||
names << CheckAction;
|
||||
break;
|
||||
default:
|
||||
if (button()->isCheckable()) {
|
||||
if (state() & Checked) {
|
||||
names << UncheckAction;
|
||||
} else {
|
||||
// FIXME
|
||||
// QCheckBox *cb = qobject_cast<QCheckBox*>(object());
|
||||
// if (!cb || !cb->isTristate() || cb->checkState() == Qt::PartiallyChecked)
|
||||
names << CheckAction;
|
||||
}
|
||||
} else {
|
||||
return QLatin1String("Check");
|
||||
names << PressAction;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return QLatin1String("Press");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
QString QAccessibleButton::localizedName(int actionIndex)
|
||||
void QAccessibleButton::doAction(const QString &actionName)
|
||||
{
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
if (button()->isCheckable()) {
|
||||
if (button()->isChecked()) {
|
||||
return tr("Uncheck");
|
||||
} else {
|
||||
return tr("Check");
|
||||
}
|
||||
}
|
||||
return tr("Press");
|
||||
default:
|
||||
return QString();
|
||||
if (!widget()->isEnabled())
|
||||
return;
|
||||
if (actionName == PressAction ||
|
||||
actionName == ShowMenuAction) {
|
||||
#ifndef QT_NO_MENU
|
||||
QPushButton *pb = qobject_cast<QPushButton*>(object());
|
||||
if (pb && pb->menu())
|
||||
pb->showMenu();
|
||||
else
|
||||
#endif
|
||||
button()->animateClick();
|
||||
}
|
||||
|
||||
if (actionName == CheckAction)
|
||||
button()->setChecked(true);
|
||||
if (actionName == UncheckAction)
|
||||
button()->setChecked(false);
|
||||
}
|
||||
|
||||
QStringList QAccessibleButton::keyBindings(int actionIndex)
|
||||
QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) const
|
||||
{
|
||||
switch (actionIndex) {
|
||||
if (actionName == PressAction) {
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
case 0:
|
||||
return QStringList() << button()->shortcut().toString();
|
||||
#endif
|
||||
default:
|
||||
return QStringList();
|
||||
}
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
|
||||
#ifndef QT_NO_TOOLBUTTON
|
||||
/*!
|
||||
\class QAccessibleToolButton
|
||||
@ -383,120 +320,44 @@ int QAccessibleToolButton::actionCount(int) const
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
|
||||
If \a text is \c Name, then depending on the \a child or the \a
|
||||
action, an action text is returned. This is a translated string
|
||||
which in English is one of "Press", "Open", or "Set Focus". If \a
|
||||
text is not \c Name, an empty string is returned.
|
||||
/*
|
||||
The three different tool button types can have the following actions:
|
||||
| DelayedPopup | ShowMenuAction + (PressedAction || CheckedAction) |
|
||||
| MenuButtonPopup | ShowMenuAction + (PressedAction || CheckedAction) |
|
||||
| InstantPopup | ShowMenuAction |
|
||||
*/
|
||||
QString QAccessibleToolButton::actionText(int action, Text text, int) const
|
||||
QStringList QAccessibleToolButton::actionNames() const
|
||||
{
|
||||
return QString();
|
||||
QStringList names;
|
||||
if (widget()->isEnabled()) {
|
||||
if (toolButton()->menu())
|
||||
names << ShowMenuAction;
|
||||
if (toolButton()->popupMode() != QToolButton::InstantPopup)
|
||||
names << QAccessibleButton::actionNames();
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
bool QAccessibleToolButton::doAction(int, int, const QVariantList &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int QAccessibleToolButton::actionCount()
|
||||
{
|
||||
return isSplitButton() ? 2 : 1;
|
||||
}
|
||||
|
||||
void QAccessibleToolButton::doAction(int actionIndex)
|
||||
void QAccessibleToolButton::doAction(const QString &actionName)
|
||||
{
|
||||
if (!widget()->isEnabled())
|
||||
return;
|
||||
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
if (actionName == PressAction) {
|
||||
button()->click();
|
||||
break;
|
||||
case 1:
|
||||
if (isSplitButton()) {
|
||||
} else if (actionName == ShowMenuAction) {
|
||||
if (toolButton()->popupMode() != QToolButton::InstantPopup) {
|
||||
toolButton()->setDown(true);
|
||||
#ifndef QT_NO_MENU
|
||||
toolButton()->showMenu();
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
QAccessibleButton::doAction(actionName);
|
||||
}
|
||||
}
|
||||
|
||||
QString QAccessibleToolButton::name(int actionIndex)
|
||||
{
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
if (button()->isCheckable()) {
|
||||
if (button()->isChecked()) {
|
||||
return QLatin1String("Uncheck");
|
||||
} else {
|
||||
return QLatin1String("Check");
|
||||
}
|
||||
}
|
||||
return QLatin1String("Press");
|
||||
case 1:
|
||||
if (isSplitButton())
|
||||
return QLatin1String("Show popup menu");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString QAccessibleToolButton::localizedName(int actionIndex)
|
||||
{
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
if (button()->isCheckable()) {
|
||||
if (button()->isChecked()) {
|
||||
return tr("Uncheck");
|
||||
} else {
|
||||
return tr("Check");
|
||||
}
|
||||
}
|
||||
return tr("Press");
|
||||
case 1:
|
||||
return tr("Show popup menu");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString QAccessibleToolButton::localizedDescription(int actionIndex)
|
||||
{
|
||||
switch (actionIndex) {
|
||||
case 0:
|
||||
if (button()->isCheckable()) {
|
||||
return tr("Toggles the button.");
|
||||
}
|
||||
return tr("Clicks the button.");
|
||||
case 1:
|
||||
return tr("Shows the menu.");
|
||||
default:
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QStringList QAccessibleToolButton::keyBindings(int actionIndex)
|
||||
{
|
||||
switch (actionIndex) {
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
case 0:
|
||||
return QStringList() << button()->shortcut().toString();
|
||||
#endif
|
||||
default:
|
||||
return QStringList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // QT_NO_TOOLBUTTON
|
||||
|
||||
/*!
|
||||
|
@ -65,16 +65,9 @@ public:
|
||||
QString text(Text t, int child = 0) const;
|
||||
State state(int child = 0) const;
|
||||
|
||||
QString actionText(int action, Text text, int child) const;
|
||||
bool doAction(int action, int child, const QVariantList ¶ms);
|
||||
|
||||
// QAccessibleActionInterface
|
||||
int actionCount();
|
||||
void doAction(int actionIndex);
|
||||
QString localizedDescription(int actionIndex);
|
||||
QString name(int actionIndex);
|
||||
QString localizedName(int actionIndex);
|
||||
QStringList keyBindings(int actionIndex);
|
||||
QStringList actionNames() const;
|
||||
void doAction(const QString &actionName);
|
||||
QStringList keyBindingsForAction(const QString &actionName) const;
|
||||
|
||||
protected:
|
||||
QAbstractButton *button() const;
|
||||
@ -98,12 +91,8 @@ public:
|
||||
bool doAction(int action, int child, const QVariantList ¶ms);
|
||||
|
||||
// QAccessibleActionInterface
|
||||
int actionCount();
|
||||
void doAction(int actionIndex);
|
||||
QString localizedDescription(int actionIndex);
|
||||
QString name(int actionIndex);
|
||||
QString localizedName(int actionIndex);
|
||||
QStringList keyBindings(int actionIndex);
|
||||
QStringList actionNames() const;
|
||||
void doAction(const QString &actionName);
|
||||
|
||||
protected:
|
||||
QToolButton *toolButton() const;
|
||||
|
@ -58,7 +58,7 @@
|
||||
#include <QtGui/qaccessible.h>
|
||||
#include <QtGui/qplatformnativeinterface_qpa.h>
|
||||
#include <QtGui/qwindow.h>
|
||||
|
||||
#include <QtGui/qaccessible2.h>
|
||||
#include <OleAcc.h>
|
||||
|
||||
//#include <uiautomationcoreapi.h>
|
||||
@ -949,27 +949,35 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accParent(IDispatch** ppdispPa
|
||||
*/
|
||||
HRESULT STDMETHODCALLTYPE QWindowsAccessible::accDoDefaultAction(VARIANT varID)
|
||||
{
|
||||
Q_UNUSED(varID);
|
||||
showDebug(__FUNCTION__, accessible);
|
||||
if (!accessible->isValid())
|
||||
return E_FAIL;
|
||||
|
||||
return accessible->doAction(DefaultAction, varID.lVal, QVariantList()) ? S_OK : S_FALSE;
|
||||
if (QAccessibleActionInterface *actionIface = accessible->actionInterface()) {
|
||||
const QString def = actionIface->actionNames().value(0);
|
||||
if (!def.isEmpty()) {
|
||||
actionIface->doAction(def);
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accDefaultAction(VARIANT varID, BSTR* pszDefaultAction)
|
||||
{
|
||||
Q_UNUSED(varID);
|
||||
showDebug(__FUNCTION__, accessible);
|
||||
if (!accessible->isValid())
|
||||
return E_FAIL;
|
||||
|
||||
QString def = accessible->actionText(DefaultAction, Name, varID.lVal);
|
||||
if (def.isEmpty()) {
|
||||
*pszDefaultAction = 0;
|
||||
return S_FALSE;
|
||||
*pszDefaultAction = 0;
|
||||
if (QAccessibleActionInterface *actionIface = accessible->actionInterface()) {
|
||||
const QString def = actionIface->actionNames().value(0);
|
||||
if (!def.isEmpty())
|
||||
*pszDefaultAction = QStringToBSTR(def);
|
||||
}
|
||||
|
||||
*pszDefaultAction = QStringToBSTR(def);
|
||||
return S_OK;
|
||||
return *pszDefaultAction ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accDescription(VARIANT varID, BSTR* pszDescription)
|
||||
@ -1011,18 +1019,21 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accHelpTopic(BSTR *, VARIANT,
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accKeyboardShortcut(VARIANT varID, BSTR *pszKeyboardShortcut)
|
||||
{
|
||||
Q_UNUSED(varID);
|
||||
showDebug(__FUNCTION__, accessible);
|
||||
if (!accessible->isValid())
|
||||
return E_FAIL;
|
||||
|
||||
QString sc = accessible->text(Accelerator, varID.lVal);
|
||||
if (sc.size()) {
|
||||
*pszKeyboardShortcut = QStringToBSTR(sc);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*pszKeyboardShortcut = 0;
|
||||
return S_FALSE;
|
||||
if (QAccessibleActionInterface *actionIface = accessible->actionInterface()) {
|
||||
const QString def = actionIface->actionNames().value(0);
|
||||
if (!def.isEmpty()) {
|
||||
const QString keyBoardShortCut = actionIface->keyBindingsForAction(def).value(0);
|
||||
if (!keyBoardShortCut.isEmpty())
|
||||
*pszKeyboardShortcut = QStringToBSTR(keyBoardShortCut);
|
||||
}
|
||||
}
|
||||
return *pszKeyboardShortcut ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accName(VARIANT varID, BSTR* pszName)
|
||||
@ -1106,6 +1117,10 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::accSelect(long flagsSelect, VARIAN
|
||||
|
||||
bool res = false;
|
||||
|
||||
/*
|
||||
### Check for accessibleTableInterface() or accessibleTextInterface()
|
||||
|
||||
### and if there are no ia2 interfaces we should do nothing??
|
||||
if (flagsSelect & SELFLAG_TAKEFOCUS)
|
||||
res = accessible->doAction(SetFocus, varID.lVal, QVariantList());
|
||||
if (flagsSelect & SELFLAG_TAKESELECTION) {
|
||||
@ -1118,7 +1133,7 @@ HRESULT STDMETHODCALLTYPE QWindowsAccessible::accSelect(long flagsSelect, VARIAN
|
||||
res = accessible->doAction(AddToSelection, varID.lVal, QVariantList());
|
||||
if (flagsSelect & SELFLAG_REMOVESELECTION)
|
||||
res = accessible->doAction(RemoveSelection, varID.lVal, QVariantList());
|
||||
|
||||
*/
|
||||
return res ? S_OK : S_FALSE;
|
||||
}
|
||||
|
||||
|
@ -819,67 +819,6 @@ QString QAccessibleWidget::text(Text t, int child) const
|
||||
return str;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_ACTION
|
||||
|
||||
/*! \reimp */
|
||||
int QAccessibleWidget::userActionCount(int child) const
|
||||
{
|
||||
if (child)
|
||||
return 0;
|
||||
return widget()->actions().count();
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
QString QAccessibleWidget::actionText(int action, Text t, int child) const
|
||||
{
|
||||
if (action == DefaultAction)
|
||||
action = SetFocus;
|
||||
|
||||
if (action > 0 && !child) {
|
||||
QAction *act = widget()->actions().value(action - 1);
|
||||
if (act) {
|
||||
switch (t) {
|
||||
case Name:
|
||||
return act->text();
|
||||
case Description:
|
||||
return act->toolTip();
|
||||
#ifndef QT_NO_SHORTCUT
|
||||
case Accelerator:
|
||||
return act->shortcut().toString();
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QAccessibleObject::actionText(action, t, child);
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
bool QAccessibleWidget::doAction(int action, int child, const QVariantList ¶ms)
|
||||
{
|
||||
if (action == SetFocus || action == DefaultAction) {
|
||||
if (child || !widget()->isEnabled())
|
||||
return false;
|
||||
if (widget()->focusPolicy() != Qt::NoFocus)
|
||||
widget()->setFocus();
|
||||
else if (widget()->isWindow())
|
||||
widget()->activateWindow();
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
} else if (action > 0) {
|
||||
if (QAction *act = widget()->actions().value(action - 1)) {
|
||||
act->trigger();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return QAccessibleObject::doAction(action, child, params);
|
||||
}
|
||||
|
||||
#endif // QT_NO_ACTION
|
||||
|
||||
/*! \reimp */
|
||||
QAccessible::Role QAccessibleWidget::role(int child) const
|
||||
{
|
||||
|
@ -75,12 +75,6 @@ public:
|
||||
Role role(int child = 0) const;
|
||||
State state(int child = 0) const;
|
||||
|
||||
#ifndef QT_NO_ACTION
|
||||
int userActionCount(int child = 0) const;
|
||||
QString actionText(int action, Text t, int child = 0) const;
|
||||
bool doAction(int action, int child = 0, const QVariantList ¶ms = QVariantList());
|
||||
#endif
|
||||
|
||||
QVariant invokeMethod(Method method, int child, const QVariantList ¶ms);
|
||||
|
||||
protected:
|
||||
|
@ -224,8 +224,7 @@ private slots:
|
||||
void textAttributes();
|
||||
void hideShowTest();
|
||||
|
||||
void userActionCount();
|
||||
void actionText();
|
||||
void actionTest();
|
||||
|
||||
void applicationTest();
|
||||
void mainWindowTest();
|
||||
@ -933,41 +932,11 @@ void tst_QAccessibility::hideShowTest()
|
||||
QTestAccessibility::clearEvents();
|
||||
}
|
||||
|
||||
void tst_QAccessibility::userActionCount()
|
||||
|
||||
void tst_QAccessibility::actionTest()
|
||||
{
|
||||
QWidget widget;
|
||||
QCOMPARE(QAccessibleActionInterface::PressAction, QString("Press"));
|
||||
|
||||
QAccessibleInterface *test = QAccessible::queryAccessibleInterface(&widget);
|
||||
QVERIFY(test);
|
||||
QVERIFY(test->isValid());
|
||||
QCOMPARE(test->userActionCount(0), 0);
|
||||
QCOMPARE(test->userActionCount(1), 0);
|
||||
QCOMPARE(test->userActionCount(-1), 0);
|
||||
delete test; test = 0;
|
||||
|
||||
QFrame frame;
|
||||
|
||||
test = QAccessible::queryAccessibleInterface(&frame);
|
||||
QVERIFY(test);
|
||||
QVERIFY(test->isValid());
|
||||
QCOMPARE(test->userActionCount(0), 0);
|
||||
QCOMPARE(test->userActionCount(1), 0);
|
||||
QCOMPARE(test->userActionCount(-1), 0);
|
||||
delete test; test = 0;
|
||||
|
||||
QLineEdit lineEdit;
|
||||
|
||||
test = QAccessible::queryAccessibleInterface(&lineEdit);
|
||||
QVERIFY(test);
|
||||
QVERIFY(test->isValid());
|
||||
QCOMPARE(test->userActionCount(0), 0);
|
||||
QCOMPARE(test->userActionCount(1), 0);
|
||||
QCOMPARE(test->userActionCount(-1), 0);
|
||||
delete test; test = 0;
|
||||
}
|
||||
|
||||
void tst_QAccessibility::actionText()
|
||||
{
|
||||
QWidget *widget = new QWidget;
|
||||
widget->show();
|
||||
|
||||
@ -975,13 +944,13 @@ void tst_QAccessibility::actionText()
|
||||
QVERIFY(test);
|
||||
QVERIFY(test->isValid());
|
||||
|
||||
QCOMPARE(test->actionText(1, QAccessible::Name, 0), QString());
|
||||
QCOMPARE(test->actionText(0, QAccessible::Name, 1), QString());
|
||||
QCOMPARE(test->actionText(1, QAccessible::Name, 1), QString());
|
||||
QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, -1), QString());
|
||||
// QCOMPARE(test->actionText(1, QAccessible::Name, 0), QString());
|
||||
// QCOMPARE(test->actionText(0, QAccessible::Name, 1), QString());
|
||||
// QCOMPARE(test->actionText(1, QAccessible::Name, 1), QString());
|
||||
// QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, -1), QString());
|
||||
|
||||
QCOMPARE(test->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString("SetFocus"));
|
||||
QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, 0), QString("SetFocus"));
|
||||
// QCOMPARE(test->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString("SetFocus"));
|
||||
// QCOMPARE(test->actionText(QAccessible::SetFocus, QAccessible::Name, 0), QString("SetFocus"));
|
||||
|
||||
delete test;
|
||||
delete widget;
|
||||
@ -1070,14 +1039,13 @@ void tst_QAccessibility::buttonTest()
|
||||
QAccessibleInterface* interface = QAccessible::queryAccessibleInterface(&pushButton);
|
||||
QAccessibleActionInterface* actionInterface = interface->actionInterface();
|
||||
QVERIFY(actionInterface != 0);
|
||||
|
||||
QCOMPARE(interface->role(), QAccessible::PushButton);
|
||||
|
||||
// currently our buttons only have click as action, press and release are missing
|
||||
QCOMPARE(actionInterface->actionCount(), 1);
|
||||
QCOMPARE(actionInterface->name(0), QString("Press"));
|
||||
QCOMPARE(actionInterface->actionNames().size(), 1);
|
||||
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
|
||||
QCOMPARE(pushButton.clickCount, 0);
|
||||
actionInterface->doAction(0);
|
||||
actionInterface->doAction(QAccessibleActionInterface::PressAction);
|
||||
QTest::qWait(500);
|
||||
QCOMPARE(pushButton.clickCount, 1);
|
||||
delete interface;
|
||||
@ -1086,63 +1054,59 @@ void tst_QAccessibility::buttonTest()
|
||||
interface = QAccessible::queryAccessibleInterface(&toggleButton);
|
||||
actionInterface = interface->actionInterface();
|
||||
QCOMPARE(interface->role(), QAccessible::CheckBox);
|
||||
QCOMPARE(actionInterface->localizedDescription(0), QString("Toggles the button."));
|
||||
QCOMPARE(actionInterface->name(0), QString("Check"));
|
||||
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::CheckAction);
|
||||
QCOMPARE(actionInterface->localizedActionDescription(QAccessibleActionInterface::CheckAction), QString("Checks the checkbox"));
|
||||
QVERIFY(!toggleButton.isChecked());
|
||||
QVERIFY((interface->state() & QAccessible::Checked) == 0);
|
||||
actionInterface->doAction(0);
|
||||
actionInterface->doAction(QAccessibleActionInterface::CheckAction);
|
||||
QTest::qWait(500);
|
||||
QCOMPARE(actionInterface->name(0), QString("Uncheck"));
|
||||
QVERIFY(toggleButton.isChecked());
|
||||
QVERIFY((interface->state() & QAccessible::Checked));
|
||||
QCOMPARE(actionInterface->actionNames().at(0), QAccessibleActionInterface::UncheckAction);
|
||||
QVERIFY(interface->state() & QAccessible::Checked);
|
||||
delete interface;
|
||||
|
||||
// // test menu push button
|
||||
// QVERIFY(QAccessible::queryAccessibleInterface(&menuButton, &test));
|
||||
// QCOMPARE(test->role(), QAccessible::ButtonMenu);
|
||||
// QCOMPARE(test->defaultAction(0), QAccessible::Press);
|
||||
// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Open"));
|
||||
// QCOMPARE(test->state(), (int)QAccessible::HasPopup);
|
||||
// test->release();
|
||||
{
|
||||
// test menu push button
|
||||
QAction *foo = new QAction("Foo", 0);
|
||||
foo->setShortcut(QKeySequence("Ctrl+F"));
|
||||
QMenu *menu = new QMenu();
|
||||
menu->addAction(foo);
|
||||
QPushButton menuButton;
|
||||
menuButton.setMenu(menu);
|
||||
menuButton.show();
|
||||
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&menuButton);
|
||||
QCOMPARE(interface->role(), QAccessible::ButtonMenu);
|
||||
QVERIFY(interface->state() & QAccessible::HasPopup);
|
||||
QCOMPARE(interface->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction);
|
||||
// showing the menu enters a new event loop...
|
||||
// interface->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
|
||||
// QTest::qWait(500);
|
||||
delete interface;
|
||||
delete menu;
|
||||
}
|
||||
|
||||
// test check box
|
||||
interface = QAccessible::queryAccessibleInterface(&checkBox);
|
||||
actionInterface = interface->actionInterface();
|
||||
QCOMPARE(interface->role(), QAccessible::CheckBox);
|
||||
QCOMPARE(actionInterface->name(0), QString("Check"));
|
||||
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::CheckAction);
|
||||
QVERIFY((interface->state() & QAccessible::Checked) == 0);
|
||||
actionInterface->doAction(0);
|
||||
actionInterface->doAction(QAccessibleActionInterface::CheckAction);
|
||||
QTest::qWait(500);
|
||||
QCOMPARE(actionInterface->name(0), QString("Uncheck"));
|
||||
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::UncheckAction);
|
||||
QVERIFY(interface->state() & QAccessible::Checked);
|
||||
QVERIFY(checkBox.isChecked());
|
||||
delete interface;
|
||||
|
||||
// // test tristate check box
|
||||
// QVERIFY(QAccessible::queryAccessibleInterface(&tristate, &test));
|
||||
// QCOMPARE(test->role(), QAccessible::CheckBox);
|
||||
// QCOMPARE(test->defaultAction(0), QAccessible::Press);
|
||||
// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Toggle"));
|
||||
// QCOMPARE(test->state(), (int)QAccessible::Normal);
|
||||
// QVERIFY(test->doAction(QAccessible::Press, 0));
|
||||
// QTest::qWait(500);
|
||||
// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Check"));
|
||||
// QCOMPARE(test->state(), (int)QAccessible::Mixed);
|
||||
// QVERIFY(test->doAction(QAccessible::Press, 0));
|
||||
// QTest::qWait(500);
|
||||
// QCOMPARE(test->actionText(test->defaultAction(0), QAccessible::Name, 0), QString("Uncheck"));
|
||||
// QCOMPARE(test->state(), (int)QAccessible::Checked);
|
||||
// test->release();
|
||||
|
||||
// test radiobutton
|
||||
interface = QAccessible::queryAccessibleInterface(&radio);
|
||||
actionInterface = interface->actionInterface();
|
||||
QCOMPARE(interface->role(), QAccessible::RadioButton);
|
||||
QCOMPARE(actionInterface->name(0), QString("Check"));
|
||||
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::CheckAction);
|
||||
QVERIFY((interface->state() & QAccessible::Checked) == 0);
|
||||
actionInterface->doAction(0);
|
||||
actionInterface->doAction(QAccessibleActionInterface::CheckAction);
|
||||
QTest::qWait(500);
|
||||
QCOMPARE(actionInterface->name(0), QString("Uncheck"));
|
||||
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::CheckAction);
|
||||
QVERIFY(interface->state() & QAccessible::Checked);
|
||||
QVERIFY(checkBox.isChecked());
|
||||
delete interface;
|
||||
@ -1237,8 +1201,6 @@ void tst_QAccessibility::scrollBarTest()
|
||||
const QRect scrollBarRect = scrollBarInterface->rect();
|
||||
QVERIFY(scrollBarRect.isValid());
|
||||
|
||||
qDebug() << scrollBarRect;
|
||||
|
||||
delete scrollBarInterface;
|
||||
delete scrollBar;
|
||||
|
||||
@ -1253,8 +1215,6 @@ void tst_QAccessibility::tabTest()
|
||||
QAccessibleInterface * const interface = QAccessible::queryAccessibleInterface(tabBar);
|
||||
QVERIFY(interface);
|
||||
QCOMPARE(interface->childCount(), 2);
|
||||
interface->doAction(QAccessible::Press, 1);
|
||||
interface->doAction(QAccessible::Press, 2);
|
||||
|
||||
// Test that the Invisible bit for the navigation buttons gets set
|
||||
// and cleared correctly.
|
||||
@ -1286,11 +1246,14 @@ void tst_QAccessibility::tabTest()
|
||||
tabBar->setCurrentIndex(0);
|
||||
|
||||
// Test that sending a focus action to a tab does not select it.
|
||||
child2->doAction(QAccessible::Focus, 2, QVariantList());
|
||||
// child2->doAction(QAccessible::Focus, 2, QVariantList());
|
||||
QCOMPARE(tabBar->currentIndex(), 0);
|
||||
|
||||
// Test that sending a press action to a tab selects it.
|
||||
child2->doAction(QAccessible::Press, 2, QVariantList());
|
||||
QVERIFY(child2->actionInterface());
|
||||
QCOMPARE(child2->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
|
||||
QCOMPARE(tabBar->currentIndex(), 0);
|
||||
child2->actionInterface()->doAction(QAccessibleActionInterface::PressAction);
|
||||
QCOMPARE(tabBar->currentIndex(), 1);
|
||||
|
||||
delete tabBar;
|
||||
@ -1483,36 +1446,33 @@ void tst_QAccessibility::menuTest()
|
||||
QCOMPARE(iAction->text(QAccessible::Accelerator, 0), QString());
|
||||
#endif
|
||||
|
||||
QCOMPARE(iFile->actionText(QAccessible::DefaultAction, QAccessible::Name), QString("Open"));
|
||||
QCOMPARE(iEdit->actionText(QAccessible::DefaultAction, QAccessible::Name), QString("Open"));
|
||||
QCOMPARE(iSeparator->actionText(QAccessible::DefaultAction, QAccessible::Name), QString());
|
||||
QCOMPARE(iHelp->actionText(QAccessible::DefaultAction, QAccessible::Name), QString("Open"));
|
||||
QCOMPARE(iAction->actionText(QAccessible::DefaultAction, QAccessible::Name), QString("Execute"));
|
||||
QVERIFY(iFile->actionInterface());
|
||||
|
||||
QCOMPARE(iFile->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction);
|
||||
QCOMPARE(iSeparator->actionInterface()->actionNames(), QStringList());
|
||||
QCOMPARE(iHelp->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction);
|
||||
QCOMPARE(iAction->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
|
||||
|
||||
bool menuFade = qApp->isEffectEnabled(Qt::UI_FadeMenu);
|
||||
int menuFadeDelay = 300;
|
||||
iFile->doAction(QAccessible::DefaultAction);
|
||||
iFile->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
|
||||
if(menuFade)
|
||||
QTest::qWait(menuFadeDelay);
|
||||
QVERIFY(file->isVisible() && !edit->isVisible() && !help->isVisible());
|
||||
iEdit->doAction(QAccessible::DefaultAction);
|
||||
iEdit->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
|
||||
if(menuFade)
|
||||
QTest::qWait(menuFadeDelay);
|
||||
QVERIFY(!file->isVisible() && edit->isVisible() && !help->isVisible());
|
||||
iSeparator->doAction(QAccessible::DefaultAction);
|
||||
if(menuFade)
|
||||
QTest::qWait(menuFadeDelay);
|
||||
QVERIFY(!file->isVisible() && !edit->isVisible() && !help->isVisible());
|
||||
iHelp->doAction(QAccessible::DefaultAction);
|
||||
iHelp->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
|
||||
if(menuFade)
|
||||
QTest::qWait(menuFadeDelay);
|
||||
QVERIFY(!file->isVisible() && !edit->isVisible() && help->isVisible());
|
||||
iAction->doAction(QAccessible::DefaultAction);
|
||||
iAction->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
|
||||
if(menuFade)
|
||||
QTest::qWait(menuFadeDelay);
|
||||
QVERIFY(!file->isVisible() && !edit->isVisible() && !help->isVisible());
|
||||
|
||||
interface->doAction(QAccessible::DefaultAction);
|
||||
QVERIFY(!interface->actionInterface());
|
||||
delete interface;
|
||||
interface = QAccessible::queryAccessibleInterface(file);
|
||||
QCOMPARE(interface->childCount(), 5);
|
||||
@ -1529,11 +1489,11 @@ void tst_QAccessibility::menuTest()
|
||||
QCOMPARE(iFileSave->role(), QAccessible::MenuItem);
|
||||
QCOMPARE(iFileSeparator->role(), QAccessible::Separator);
|
||||
QCOMPARE(iFileExit->role(), QAccessible::MenuItem);
|
||||
QCOMPARE(iFileNew->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString("Open"));
|
||||
QCOMPARE(iFileOpen->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString("Execute"));
|
||||
QCOMPARE(iFileSave->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString("Execute"));
|
||||
QCOMPARE(iFileSeparator->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString());
|
||||
QCOMPARE(iFileExit->actionText(QAccessible::DefaultAction, QAccessible::Name, 0), QString("Execute"));
|
||||
QCOMPARE(iFileNew->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction);
|
||||
QCOMPARE(iFileOpen->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
|
||||
QCOMPARE(iFileSave->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
|
||||
QCOMPARE(iFileSeparator->actionInterface()->actionNames(), QStringList());
|
||||
QCOMPARE(iFileExit->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
|
||||
|
||||
QAccessibleInterface *iface = 0;
|
||||
QAccessibleInterface *iface2 = 0;
|
||||
@ -1623,8 +1583,8 @@ void tst_QAccessibility::menuTest()
|
||||
if (menuFade)
|
||||
QTest::qWait(menuFadeDelay);
|
||||
|
||||
iFile->doAction(QAccessible::DefaultAction);
|
||||
iFileNew->doAction(QAccessible::DefaultAction);
|
||||
iFile->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
|
||||
iFileNew->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
|
||||
|
||||
QVERIFY(file->isVisible());
|
||||
QVERIFY(fileNew->isVisible());
|
||||
@ -3294,8 +3254,8 @@ void tst_QAccessibility::comboBoxTest()
|
||||
|
||||
QVERIFY(!combo.view()->isVisible());
|
||||
QVERIFY(iface->actionInterface());
|
||||
QCOMPARE(iface->actionInterface()->actionCount(), 1);
|
||||
iface->actionInterface()->doAction(0);
|
||||
QCOMPARE(iface->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction);
|
||||
iface->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
|
||||
QVERIFY(combo.view()->isVisible());
|
||||
|
||||
delete iface;
|
||||
|
Loading…
Reference in New Issue
Block a user