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: I169d5eff527a0aef810af11d7712a362148974a5
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
José Millán Soto 2012-09-23 11:46:21 +02:00 committed by The Qt Project
parent f6bd02317d
commit c39b6e3188

View File

@ -55,6 +55,7 @@
#include <qlineedit.h>
#include <qstyle.h>
#include <qstyleoption.h>
#include <qtextdocument.h>
#include <QtCore/qvarlengtharray.h>
#ifdef Q_OS_MAC
@ -392,7 +393,14 @@ QString QAccessibleDisplay::text(QAccessible::Text t) 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());