summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorDongmei Wang <dongmei.wang@theqtcompany.com>2016-01-22 20:19:28 -0800
committerDongmei Wang <dongmei.wang@theqtcompany.com>2016-04-24 01:32:23 +0000
commit18291af42caf18165f99dd0300738576b96379a6 (patch)
treedade97f9818ab92e865ac27026c2f1e141b2b892 /src/widgets/widgets
parent2ddad99979f19ad731b29fd4de6ff7c673068440 (diff)
QTabBar: Add setAccessibleTabName() and accessibleTabName()
Currently, a tab's text is used as its accessibleName. When a tab's text is empty, there is no API to set the tab's accessibleName. The two APIs are added to set and return the accessibleName property of a tab. Task-number: QTBUG-46530 Change-Id: Idf88b5f905fe66c6365ea0eeb650e74211db90e1 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qtabbar.cpp28
-rw-r--r--src/widgets/widgets/qtabbar.h5
-rw-r--r--src/widgets/widgets/qtabbar_p.h3
3 files changed, 36 insertions, 0 deletions
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 6c748c09bb..9cc44007bd 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -2522,6 +2522,34 @@ QWidget *QTabBar::tabButton(int index, ButtonPosition position) const
return d->tabList.at(index).rightWidget;
}
+#ifndef QT_NO_ACCESSIBILITY
+/*!
+ Sets the accessibleName of the tab at position \a index to \a name.
+*/
+void QTabBar::setAccessibleTabName(int index, const QString &name)
+{
+ Q_D(QTabBar);
+ if (QTabBarPrivate::Tab *tab = d->at(index)) {
+ tab->accessibleName = name;
+ QAccessibleEvent event(this, QAccessible::NameChanged);
+ event.setChild(index);
+ QAccessible::updateAccessibility(&event);
+ }
+}
+
+/*!
+ Returns the accessibleName of the tab at position \a index, or an empty
+ string if \a index is out of range.
+*/
+QString QTabBar::accessibleTabName(int index) const
+{
+ Q_D(const QTabBar);
+ if (const QTabBarPrivate::Tab *tab = d->at(index))
+ return tab->accessibleName;
+ return QString();
+}
+#endif // QT_NO_ACCESSIBILITY
+
CloseButton::CloseButton(QWidget *parent)
: QAbstractButton(parent)
{
diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h
index 138c5470c6..84b2d40aea 100644
--- a/src/widgets/widgets/qtabbar.h
+++ b/src/widgets/widgets/qtabbar.h
@@ -172,6 +172,11 @@ public:
bool changeCurrentOnDrag() const;
void setChangeCurrentOnDrag(bool change);
+#ifndef QT_NO_ACCESSIBILITY
+ QString accessibleTabName(int index) const;
+ void setAccessibleTabName(int index, const QString &name);
+#endif
+
public Q_SLOTS:
void setCurrentIndex(int index);
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index 48f235f050..7c50ebd235 100644
--- a/src/widgets/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
@@ -131,6 +131,9 @@ public:
QWidget *rightWidget;
int lastTab;
int dragOffset;
+#ifndef QT_NO_ACCESSIBILITY
+ QString accessibleName;
+#endif
#ifndef QT_NO_ANIMATION
~Tab() { delete animation; }