summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-05-06 21:13:29 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-05-07 17:00:20 +0200
commit688602704d5c5226491b0d0ab7f596f9568966d6 (patch)
tree750f50589fe77ebfe214a7a113c7a6d26011d96a /src/gui/text
parent05f7dd5ead5927ef7b3301380b81d7194d9e0593 (diff)
Support CSS text-decoration-color in underlines, overlines, strikethrough
Also add a feature to the textedit example to set this value. [ChangeLog][QtGui][CSS] The CSS text-decoration-color attribute is now supported in rich text spans with underlines, overlines and strikethrough. Fixes: QTBUG-82114 Task-number: QTBUG-39617 Change-Id: I0065cb5431833da55b0f503ce7ff2b83b74b718a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qcssparser.cpp1
-rw-r--r--src/gui/text/qcssparser_p.h1
-rw-r--r--src/gui/text/qtextdocument.cpp5
-rw-r--r--src/gui/text/qtextformat.cpp9
-rw-r--r--src/gui/text/qtexthtmlparser.cpp1
5 files changed, 13 insertions, 4 deletions
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 46ed67ea7d..4cc310c7e7 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -166,6 +166,7 @@ static const QCssKnownValue properties[NumProperties - 1] = {
{ "subcontrol-position", QtPosition },
{ "text-align", TextAlignment },
{ "text-decoration", TextDecoration },
+ { "text-decoration-color", TextDecorationColor },
{ "text-indent", TextIndent },
{ "text-transform", TextTransform },
{ "text-underline-style", TextUnderlineStyle },
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index 1ccfc45d21..56af5c8bb2 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -201,6 +201,7 @@ enum Property {
QtIcon,
LetterSpacing,
WordSpacing,
+ TextDecorationColor,
NumProperties
};
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 2c0c3582ed..d3bec57bd4 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -2560,6 +2560,11 @@ bool QTextHtmlExporter::emitCharFormatStyle(const QTextCharFormat &format)
if (!atLeastOneDecorationSet)
html += QLatin1String("none");
html += QLatin1Char(';');
+ if (format.hasProperty(QTextFormat::TextUnderlineColor)) {
+ html += QLatin1String(" text-decoration-color:");
+ html += colorValue(format.underlineColor());
+ html += QLatin1Char(';');
+ }
attributesEmitted = true;
} else {
html.chop(decorationTag.size());
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 44986c337c..80c7845410 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -642,7 +642,7 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &stream, QTextFormat &fmt)
\omitvalue FirstFontProperty
\omitvalue LastFontProperty
- \value TextUnderlineColor
+ \value TextUnderlineColor Specifies the color to draw underlines, overlines and strikeouts.
\value TextVerticalAlignment
\value TextOutline
\value TextUnderlineStyle
@@ -1984,8 +1984,8 @@ QStringList QTextCharFormat::anchorNames() const
/*!
\fn void QTextCharFormat::setUnderlineColor(const QColor &color)
- Sets the underline color used for the characters with this format to
- the \a color specified.
+ Sets the color used to draw underlines, overlines and strikeouts on the
+ characters with this format to the \a color specified.
\sa underlineColor()
*/
@@ -1993,7 +1993,8 @@ QStringList QTextCharFormat::anchorNames() const
/*!
\fn QColor QTextCharFormat::underlineColor() const
- Returns the color used to underline the characters with this format.
+ Returns the color used to draw underlines, overlines and strikeouts
+ on the characters with this format.
\sa setUnderlineColor()
*/
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index a242d5e645..3ad0938268 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1346,6 +1346,7 @@ void QTextHtmlParserNode::applyCssDeclarations(const QList<QCss::Declaration> &d
default: break;
}
break;
+ case QCss::TextDecorationColor: charFormat.setUnderlineColor(decl.colorValue()); break;
case QCss::ListStyleType:
case QCss::ListStyle:
setListStyle(decl.d->values);