summaryrefslogtreecommitdiffstats
path: root/src/widgets/accessible/qaccessiblewidgets.cpp
diff options
context:
space:
mode:
authorBoris Dušek <me@dusek.me>2015-02-15 22:50:15 +0100
committerJan Arve Sæther <jan-arve.saether@theqtcompany.com>2015-02-25 08:56:21 +0000
commit62cd369594dc39e06e8c7ec2c761cfedf5d9c9ba (patch)
tree9ecbef016df5e6af3e9a77bbfc3864655cfafeaf /src/widgets/accessible/qaccessiblewidgets.cpp
parent989cd600bc9ca5eb4a73b7bd4da6fed47304dfff (diff)
Support all underline types in accessibility
Change-Id: I74684167eef13d407e94d3b9668077fe61553672 Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'src/widgets/accessible/qaccessiblewidgets.cpp')
-rw-r--r--src/widgets/accessible/qaccessiblewidgets.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp
index 3f12ae6f0d..1f48561af5 100644
--- a/src/widgets/accessible/qaccessiblewidgets.cpp
+++ b/src/widgets/accessible/qaccessiblewidgets.cpp
@@ -764,7 +764,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" ));