diff options
author | Harald Fernengel <harald.fernengel@nokia.com> | 2009-10-20 15:45:48 (GMT) |
---|---|---|
committer | Harald Fernengel <harald.fernengel@nokia.com> | 2009-10-20 15:48:26 (GMT) |
commit | 339b5b04a98ad3a5569180b0a1a000e82e985867 (patch) | |
tree | 824182963f5d27486726a6d2b8f47f7cd6ddaf45 /src/plugins/accessible | |
parent | 77f2319ab80be40268da689d5bc4726257ddd7ab (diff) | |
download | Qt-339b5b04a98ad3a5569180b0a1a000e82e985867.zip Qt-339b5b04a98ad3a5569180b0a1a000e82e985867.tar.gz Qt-339b5b04a98ad3a5569180b0a1a000e82e985867.tar.bz2 |
Introduce the QAccessibleActionInterface
with a sample implementation for QAccessibleButton. Not implemented
for all widgets yet (API is preliminary).
Patch has been in the accessibility-fixes branch of qt-maemo for quite
a while now without complains, thus no reviewer.
Diffstat (limited to 'src/plugins/accessible')
-rw-r--r-- | src/plugins/accessible/widgets/simplewidgets.cpp | 56 | ||||
-rw-r--r-- | src/plugins/accessible/widgets/simplewidgets.h | 14 |
2 files changed, 69 insertions, 1 deletions
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); |