diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-10-13 16:11:46 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2023-11-15 12:06:23 +0100 |
commit | d2bf45c6ed3264babc12061e635ab620a1322d2f (patch) | |
tree | e931f20a11fce0bd1e8e386efb707123e164fde9 | |
parent | 360152bdcd0e4045b558e2bf598eabbf8a16abe8 (diff) |
a11y: Report strikethrough via text attribute
Let `QAccessibleTextWidget::attributes`
report whether strikeout is applied to text
via the "text-line-through-type" IAccessible2 text
attribute [1].
Use a value of "single" when strikeout is applied,
and "none" otherwise.
A previous change already implemented bridging that to
the corresponding AT-SPI "strikethrough" attribute.
Update the existing test tst_QAccessibility::textAttributes_data
to take into account that this attribute is reported
as well now.
[1] https://wiki.linuxfoundation.org/accessibility/iaccessible2/textattributes
Fixes: QTBUG-118106
Change-Id: I0416f00b1c11709d9cd0ca0ee38cc6df6caa6dcf
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
-rw-r--r-- | src/widgets/accessible/qaccessiblewidgets.cpp | 2 | ||||
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 249165736e..1c29de8caf 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -839,6 +839,8 @@ QString QAccessibleTextWidget::attributes(int offset, int *startOffset, int *end QFont::Style style = charFormatFont.style(); attrs["font-style"] = QString::fromLatin1((style == QFont::StyleItalic) ? "italic" : ((style == QFont::StyleOblique) ? "oblique": "normal")); + attrs["text-line-through-type"] = charFormatFont.strikeOut() ? "single"_L1 : "none"_L1; + QTextCharFormat::UnderlineStyle underlineStyle = charFormat.underlineStyle(); if (underlineStyle == QTextCharFormat::NoUnderline && charFormatFont.underline()) // underline could still be set in the default font underlineStyle = QTextCharFormat::SingleUnderline; diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 7c78c9ab95..99136979d6 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -665,7 +665,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;font-size:13pt").split(';'); + static QStringList defaults = QString("font-style:normal;font-weight:normal;text-align:left;text-position:baseline;font-size:13pt;text-line-through-type:none").split(';'); static QStringList bold = defaults; bold[1] = QString::fromLatin1("font-weight:bold"); @@ -701,7 +701,7 @@ void tst_QAccessibility::textAttributes_data() defaultFontDifferentBoldItalic[1] = QString::fromLatin1("font-weight:bold"); static QStringList defaultFontDifferentMonospace = defaultFontDifferent; - defaultFontDifferentMonospace[7] = (QLatin1String("font-family:\"monospace\"")); + defaultFontDifferentMonospace[8] = (QLatin1String("font-family:\"monospace\"")); static QStringList defaultFontDifferentFont8pt = defaultFontDifferent; defaultFontDifferentFont8pt[4] = (QLatin1String("font-size:8pt")); |