diff options
author | José Millán Soto <fid@gpul.org> | 2012-09-23 10:25:59 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-16 13:52:22 (GMT) |
commit | ac371e98f33da6a80acb08da72ebc0720b70385b (patch) | |
tree | ec5c9aaff45742169f3a3315d68f7d5971c99062 /src | |
parent | be330d8959dbd1a589a9d46e4ed12b5b16fffbb4 (diff) | |
download | Qt-ac371e98f33da6a80acb08da72ebc0720b70385b.zip Qt-ac371e98f33da6a80acb08da72ebc0720b70385b.tar.gz Qt-ac371e98f33da6a80acb08da72ebc0720b70385b.tar.bz2 |
Return correct accessible name when a label has rich text
When a QLabel was displaying rich text, the raw html was being returned as
accessible name. Now the plain text is returned.
Task-number: QTBUG-27302
Change-Id: I2fc469b4ca8fc3584b849bbe0a94d094d727d04f
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/accessible/widgets/simplewidgets.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index 8747367..37b1b25 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -51,6 +51,7 @@ #include <qlabel.h> #include <qgroupbox.h> #include <qlcdnumber.h> +#include <qtextdocument.h> #include <qlineedit.h> #include <private/qlineedit_p.h> #include <qstyle.h> @@ -540,7 +541,14 @@ QString QAccessibleDisplay::text(Text t, int child) const str = widget()->accessibleName(); if (str.isEmpty()) { if (qobject_cast<QLabel*>(object())) { - str = qobject_cast<QLabel*>(object())->text(); + QLabel *label = qobject_cast<QLabel*>(object()); + str = label->text(); + if (label->textFormat() == Qt::RichText + || (label->textFormat() == Qt::AutoText && Qt::mightBeRichText(str))) { + QTextDocument doc; + doc.setHtml(str); + str = doc.toPlainText(); + } #ifndef QT_NO_LCDNUMBER } else if (qobject_cast<QLCDNumber*>(object())) { QLCDNumber *l = qobject_cast<QLCDNumber*>(object()); |