diff options
-rw-r--r-- | src/gui/widgets/qtabbar.cpp | 2 | ||||
-rw-r--r-- | src/plugins/accessible/widgets/complexwidgets.cpp | 65 | ||||
-rw-r--r-- | src/plugins/accessible/widgets/complexwidgets.h | 4 |
3 files changed, 70 insertions, 1 deletions
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index b294965..41cd131 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1221,6 +1221,8 @@ void QTabBar::setCurrentIndex(int index) d->layoutTab(index); #ifndef QT_NO_ACCESSIBILITY if (QAccessible::isActive()) { + QAccessible::updateAccessibility(this, oldIndex + 1, QAccessible::Selection); + QAccessible::updateAccessibility(this, index + 1, QAccessible::Focus); QAccessible::updateAccessibility(this, index + 1, QAccessible::Selection); } diff --git a/src/plugins/accessible/widgets/complexwidgets.cpp b/src/plugins/accessible/widgets/complexwidgets.cpp index 193a625..dae4e9c 100644 --- a/src/plugins/accessible/widgets/complexwidgets.cpp +++ b/src/plugins/accessible/widgets/complexwidgets.cpp @@ -1545,6 +1545,28 @@ QAccessible::Role QAccessibleTabBar::role(int child) const } /*! \reimp */ +int QAccessibleTabBar::navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const +{ + //QAccessibleWidgetEx::navigate might think that this is not a complex widget + //if close buttons are enabled, so this functions handles those cases in which + //the value to return is different if it's a complex widget and if it's not. + if (!target) + return -1; + + *target = 0; + + switch (relation) { + case Child: + if ((entry >= 0) && (entry <= childCount())) + return entry; + return -1; + default: + return QAccessibleWidgetEx::navigate(relation, entry, target); + } +} + + +/*! \reimp */ QAccessible::State QAccessibleTabBar::state(int child) const { State st = QAccessibleWidgetEx::state(0); @@ -1574,18 +1596,59 @@ QAccessible::State QAccessibleTabBar::state(int child) const else st |= Selectable; - if (!tb->currentIndex() == child - 1) + if (tb->currentIndex() == child - 1) st |= Selected; return st; } /*! \reimp */ +QString QAccessibleTabBar::actionText(int action, Text t, int child) const +{ + if (!child) + return QString(); + + switch (t) { + case QAccessible::Name: + if ((action == 1) && (child <= tabBar()->count())) { + return tabBar()->tabsClosable() ? QTabBar::tr("Close") : QString(); + } else if (action == 0) { + if (child <= tabBar()->count()) + return QTabBar::tr("Activate"); + else //it's an scroll button + return QTabBar::tr("Press"); + } + break; + case QAccessible::Description: + if ((action == 1) && (child <= tabBar()->count())) { + return tabBar()->tabsClosable() ? QTabBar::tr("Close the tab") : QString(); + } else if (action == 0) { + if (child <= tabBar()->count()) + return QTabBar::tr("Activate the tab"); + } + break; + } + return QString(); +} + +/*! \reimp */ +int QAccessibleTabBar::userActionCount(int child) const +{ + if (!child || (child > tabBar()->count())) + return 0; + return tabBar()->tabsClosable() ? 1 : 0; +} + +/*! \reimp */ bool QAccessibleTabBar::doAction(int action, int child, const QVariantList &) { if (!child) return false; + if ((action == 1) && (child <= tabBar()->count()) && tabBar()->tabsClosable()) { + emit tabBar()->tabCloseRequested(child - 1); + } + if (action != QAccessible::DefaultAction && action != QAccessible::Press) return false; diff --git a/src/plugins/accessible/widgets/complexwidgets.h b/src/plugins/accessible/widgets/complexwidgets.h index 88aded5..14ad622 100644 --- a/src/plugins/accessible/widgets/complexwidgets.h +++ b/src/plugins/accessible/widgets/complexwidgets.h @@ -241,8 +241,12 @@ public: QString text(Text t, int child) const; Role role(int child) const; State state(int child) const; + int navigate(RelationFlag relation, int entry, + QAccessibleInterface **target) const; bool doAction(int action, int child, const QVariantList ¶ms); + QString actionText(int action, Text t, int child) const; + int userActionCount(int child) const; bool setSelected(int child, bool on, bool extend); QVector<int> selection() const; |