diff options
-rw-r--r-- | src/gui/accessible/qaccessible.h | 7 | ||||
-rw-r--r-- | src/gui/accessible/qaccessible2.cpp | 12 | ||||
-rw-r--r-- | src/gui/accessible/qaccessible2.h | 16 | ||||
-rw-r--r-- | src/plugins/accessible/widgets/simplewidgets.cpp | 56 | ||||
-rw-r--r-- | src/plugins/accessible/widgets/simplewidgets.h | 14 |
5 files changed, 103 insertions, 2 deletions
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index 96fe91c..8f6d9d9 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -310,7 +310,8 @@ namespace QAccessible2 TextInterface, EditableTextInterface, ValueInterface, - TableInterface + TableInterface, + ActionInterface }; } @@ -319,6 +320,7 @@ class QAccessibleTextInterface; class QAccessibleEditableTextInterface; class QAccessibleValueInterface; class QAccessibleTableInterface; +class QAccessibleActionInterface; class Q_GUI_EXPORT QAccessibleInterface : public QAccessible { @@ -376,6 +378,9 @@ public: inline QAccessibleTableInterface *tableInterface() { return reinterpret_cast<QAccessibleTableInterface *>(cast_helper(QAccessible2::TableInterface)); } + inline QAccessibleActionInterface *actionInterface() + { return reinterpret_cast<QAccessibleActionInterface *>(cast_helper(QAccessible2::ActionInterface)); } + private: QAccessible2Interface *cast_helper(QAccessible2::InterfaceType); }; diff --git a/src/gui/accessible/qaccessible2.cpp b/src/gui/accessible/qaccessible2.cpp index f731962..0867368 100644 --- a/src/gui/accessible/qaccessible2.cpp +++ b/src/gui/accessible/qaccessible2.cpp @@ -108,6 +108,18 @@ 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 +*/ + QAccessibleSimpleEditableTextInterface::QAccessibleSimpleEditableTextInterface( QAccessibleInterface *accessibleInterface) : iface(accessibleInterface) diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h index 3281509..435c640 100644 --- a/src/gui/accessible/qaccessible2.h +++ b/src/gui/accessible/qaccessible2.h @@ -81,6 +81,7 @@ inline QAccessible2Interface *qAccessibleValueCastHelper() { return 0; } inline QAccessible2Interface *qAccessibleTextCastHelper() { return 0; } inline QAccessible2Interface *qAccessibleEditableTextCastHelper() { return 0; } inline QAccessible2Interface *qAccessibleTableCastHelper() { return 0; } +inline QAccessible2Interface *qAccessibleActionCastHelper() { return 0; } #define Q_ACCESSIBLE_OBJECT \ public: \ @@ -95,6 +96,8 @@ inline QAccessible2Interface *qAccessibleTableCastHelper() { return 0; } return qAccessibleValueCastHelper(); \ case QAccessible2::TableInterface: \ return qAccessibleTableCastHelper(); \ + case QAccessible2::ActionInterface: \ + return qAccessibleActionCastHelper(); \ } \ return 0; \ } \ @@ -208,6 +211,19 @@ public: int *columnSpan, bool *isSelected) = 0; }; +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 description(int actionIndex) = 0; + virtual QString name(int actionIndex) = 0; + virtual QString localizedName(int actionIndex) = 0; + virtual QStringList keyBindings(int actionIndex) = 0; +}; + #endif // QT_NO_ACCESSIBILITY QT_END_NAMESPACE diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 89482bb..aa51759 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -209,6 +209,62 @@ QAccessible::State QAccessibleButton::state(int child) const return state; } +int QAccessibleButton::actionCount() +{ + return 1; +} + +void QAccessibleButton::doAction(int actionIndex) +{ + switch (actionIndex) { + case 0: + button()->click(); + break; + } +} + +QString QAccessibleButton::description(int actionIndex) +{ + switch (actionIndex) { + case 0: + return QLatin1String("Clicks the button."); + default: + return QString(); + } +} + +QString QAccessibleButton::name(int actionIndex) +{ + switch (actionIndex) { + case 0: + return QLatin1String("Press"); + default: + return QString(); + } +} + +QString QAccessibleButton::localizedName(int actionIndex) +{ + switch (actionIndex) { + case 0: + return tr("Press"); + default: + return QString(); + } +} + +QStringList QAccessibleButton::keyBindings(int actionIndex) +{ + switch (actionIndex) { +#ifdef QT_NO_SHORTCUT + case 0: + return button()->shortcut().toString(); +#endif + default: + return QStringList(); + } +} + #ifndef QT_NO_TOOLBUTTON /*! \class QAccessibleToolButton diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h index 8de35ef..0c1cf5e 100644 --- a/src/plugins/accessible/widgets/simplewidgets.h +++ b/src/plugins/accessible/widgets/simplewidgets.h @@ -42,6 +42,7 @@ #ifndef SIMPLEWIDGETS_H #define SIMPLEWIDGETS_H +#include <QtCore/qcoreapplication.h> #include <QtGui/qaccessible2.h> #include <QtGui/qaccessiblewidget.h> @@ -54,8 +55,10 @@ class QLineEdit; class QToolButton; class QProgressBar; -class QAccessibleButton : public QAccessibleWidgetEx +class QAccessibleButton : public QAccessibleWidgetEx, public QAccessibleActionInterface { + Q_ACCESSIBLE_OBJECT + Q_DECLARE_TR_FUNCTIONS(QAccessibleButton) public: QAccessibleButton(QWidget *w, Role r); @@ -65,6 +68,14 @@ public: 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 description(int actionIndex); + QString name(int actionIndex); + QString localizedName(int actionIndex); + QStringList keyBindings(int actionIndex); + protected: QAbstractButton *button() const; }; @@ -102,6 +113,7 @@ protected: class QAccessibleDisplay : public QAccessibleWidgetEx { + Q_ACCESSIBLE_OBJECT public: explicit QAccessibleDisplay(QWidget *w, Role role = StaticText); |