summaryrefslogtreecommitdiffstats
path: root/src/widgets/accessible
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/accessible
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/accessible')
-rw-r--r--src/widgets/accessible/complexwidgets.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp
index 8faa73b68b..463019dbd0 100644
--- a/src/widgets/accessible/complexwidgets.cpp
+++ b/src/widgets/accessible/complexwidgets.cpp
@@ -120,19 +120,26 @@ public:
{
if (!isValid())
return QString();
+ QString str;
switch (t) {
case QAccessible::Name:
- return qt_accStripAmp(m_parent->tabText(m_index));
+ str = m_parent->accessibleTabName(m_index);
+ if (str.isEmpty())
+ str = qt_accStripAmp(m_parent->tabText(m_index));
+ break;
case QAccessible::Accelerator:
- return qt_accHotKey(m_parent->tabText(m_index));
+ str = qt_accHotKey(m_parent->tabText(m_index));
+ break;
case QAccessible::Description:
- return m_parent->tabToolTip(m_index);
+ str = m_parent->tabToolTip(m_index);
+ break;
case QAccessible::Help:
- return m_parent->tabWhatsThis(m_index);
+ str = m_parent->tabWhatsThis(m_index);
+ break;
default:
break;
}
- return QString();
+ return str;
}
void setText(QAccessible::Text, const QString &) Q_DECL_OVERRIDE {}
@@ -237,7 +244,12 @@ int QAccessibleTabBar::childCount() const
QString QAccessibleTabBar::text(QAccessible::Text t) const
{
if (t == QAccessible::Name) {
- return qt_accStripAmp(tabBar()->tabText(tabBar()->currentIndex()));
+ const QTabBar *tBar = tabBar();
+ int idx = tBar->currentIndex();
+ QString str = tBar->accessibleTabName(idx);
+ if (str.isEmpty())
+ str = qt_accStripAmp(tBar->tabText(idx));
+ return str;
} else if (t == QAccessible::Accelerator) {
return qt_accHotKey(tabBar()->tabText(tabBar()->currentIndex()));
}