summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/accessible/qaccessiblewidgets.cpp37
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp13
2 files changed, 43 insertions, 7 deletions
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp
index 7080dd6f8d..f283c0ea34 100644
--- a/src/widgets/accessible/qaccessiblewidgets.cpp
+++ b/src/widgets/accessible/qaccessiblewidgets.cpp
@@ -776,7 +776,42 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end
QFont::Style style = charFormat.font().style();
attrs["font-style"] = QString::fromLatin1((style == QFont::StyleItalic) ? "italic" : ((style == QFont::StyleOblique) ? "oblique": "normal"));
- attrs["text-underline-style"] = QString::fromLatin1(charFormat.font().underline() ? "solid" : "none");
+ QTextCharFormat::UnderlineStyle underlineStyle = charFormat.underlineStyle();
+ if (underlineStyle == QTextCharFormat::NoUnderline && charFormat.font().underline()) // underline could still be set in the default font
+ underlineStyle = QTextCharFormat::SingleUnderline;
+ QString underlineStyleValue;
+ switch (underlineStyle) {
+ case QTextCharFormat::NoUnderline:
+ break;
+ case QTextCharFormat::SingleUnderline:
+ underlineStyleValue = QStringLiteral("solid");
+ break;
+ case QTextCharFormat::DashUnderline:
+ underlineStyleValue = QStringLiteral("dash");
+ break;
+ case QTextCharFormat::DotLine:
+ underlineStyleValue = QStringLiteral("dash");
+ break;
+ case QTextCharFormat::DashDotLine:
+ underlineStyleValue = QStringLiteral("dot-dash");
+ break;
+ case QTextCharFormat::DashDotDotLine:
+ underlineStyleValue = QStringLiteral("dot-dot-dash");
+ break;
+ case QTextCharFormat::WaveUnderline:
+ underlineStyleValue = QStringLiteral("wave");
+ break;
+ case QTextCharFormat::SpellCheckUnderline:
+ underlineStyleValue = QStringLiteral("wave"); // this is not correct, but provides good approximation at least
+ break;
+ default:
+ qWarning() << "Unknown QTextCharFormat::​UnderlineStyle value " << underlineStyle << " could not be translated to IAccessible2 value";
+ break;
+ }
+ if (!underlineStyleValue.isNull()) {
+ attrs["text-underline-style"] = underlineStyleValue;
+ attrs["text-underline-type"] = QStringLiteral("single"); // if underlineStyleValue is set, there is an underline, and Qt does not support other than single ones
+ } // else both are "none" which is the default - no need to set them
QTextCharFormat::VerticalAlignment alignment = charFormat.verticalAlignment();
attrs["text-position"] = QString::fromLatin1((alignment == QTextCharFormat::AlignSubScript) ? "sub" : ((alignment == QTextCharFormat::AlignSuperScript) ? "super" : "baseline" ));
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 9937b6f7f8..98cbfa00f3 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -668,7 +668,7 @@ void tst_QAccessibility::textAttributes_data()
defaultComplexFont.setStyle(QFont::StyleItalic);
defaultComplexFont.setUnderline(true);
- static QStringList defaults = QString("font-style:normal;font-weight:normal;text-align:left;text-position:baseline;text-underline-style:none;font-size:13pt").split(';');
+ static QStringList defaults = QString("font-style:normal;font-weight:normal;text-align:left;text-position:baseline;font-size:13pt").split(';');
static QStringList bold = defaults;
bold[1] = QString::fromLatin1("font-weight:bold");
@@ -683,7 +683,7 @@ void tst_QAccessibility::textAttributes_data()
monospace.append(QLatin1String("font-family:\"monospace\""));
static QStringList font8pt = defaults;
- font8pt[5] = (QLatin1String("font-size:8pt"));
+ font8pt[4] = (QLatin1String("font-size:8pt"));
static QStringList color = defaults;
color << QLatin1String("color:rgb(240,241,242)") << QLatin1String("background-color:rgb(20,240,30)");
@@ -694,8 +694,9 @@ void tst_QAccessibility::textAttributes_data()
static QStringList defaultFontDifferent = defaults;
defaultFontDifferent[0] = QString::fromLatin1("font-style:italic");
defaultFontDifferent[1] = QString::fromLatin1("font-weight:bold");
- defaultFontDifferent[4] = QString::fromLatin1("text-underline-style:solid");
- defaultFontDifferent[5] = QString::fromLatin1("font-size:20pt");
+ defaultFontDifferent[4] = QString::fromLatin1("font-size:20pt");
+ defaultFontDifferent.append("text-underline-style:solid");
+ defaultFontDifferent.append("text-underline-type:single");
defaultFontDifferent.append("font-family:\"Arial\"");
static QStringList defaultFontDifferentBoldItalic = defaultFontDifferent;
@@ -703,10 +704,10 @@ void tst_QAccessibility::textAttributes_data()
defaultFontDifferentBoldItalic[1] = QString::fromLatin1("font-weight:bold");
static QStringList defaultFontDifferentMonospace = defaultFontDifferent;
- defaultFontDifferentMonospace[6] = (QLatin1String("font-family:\"monospace\""));
+ defaultFontDifferentMonospace[7] = (QLatin1String("font-family:\"monospace\""));
static QStringList defaultFontDifferentFont8pt = defaultFontDifferent;
- defaultFontDifferentFont8pt[5] = (QLatin1String("font-size:8pt"));
+ defaultFontDifferentFont8pt[4] = (QLatin1String("font-size:8pt"));
static QStringList defaultFontDifferentColor = defaultFontDifferent;
defaultFontDifferentColor << QLatin1String("color:rgb(240,241,242)") << QLatin1String("background-color:rgb(20,240,30)");