From ac371e98f33da6a80acb08da72ebc0720b70385b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mill=C3=A1n=20Soto?= Date: Sun, 23 Sep 2012 12:25:59 +0200 Subject: 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 --- src/plugins/accessible/widgets/simplewidgets.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 #include #include +#include #include #include #include @@ -540,7 +541,14 @@ QString QAccessibleDisplay::text(Text t, int child) const str = widget()->accessibleName(); if (str.isEmpty()) { if (qobject_cast(object())) { - str = qobject_cast(object())->text(); + QLabel *label = qobject_cast(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(object())) { QLCDNumber *l = qobject_cast(object()); -- cgit v0.12