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>
This commit is contained in:
Michael Weghorn 2023-10-13 16:11:46 +02:00
parent 360152bdcd
commit d2bf45c6ed
2 changed files with 4 additions and 2 deletions

View File

@ -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;

View File

@ -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"));