diff options
author | Daniel Engelke <daniel.engelke@basyskom.com> | 2018-11-28 18:02:43 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2018-12-10 19:40:25 +0000 |
commit | c352ca4a3dc2e6e3a4c039589849cf502911ba95 (patch) | |
tree | 1c346fc6dc6b238cb91593dc7ced5f2e9160d400 /src/quick/util | |
parent | 0b586e5b504f66c5ba2b690eda1c89e3e5dfdca3 (diff) |
Fix missing strike out
Added <s></s> and <del></del> tag aka strike out to QQuickStyledText.
QQuickStyledText covers the essential text decorations, apart from
strike out. In order to use it, one had to switch to RichText,
which comes with its own overhead and limitations.
<s> for no longer accurate or no longer relevant content
<del> for removed content
Fixes: QTBUG-72376
Change-Id: I3c191d91d57afcc48090facc49d643f8ad708fb4
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/util')
-rw-r--r-- | src/quick/util/qquickstyledtext.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/quick/util/qquickstyledtext.cpp b/src/quick/util/qquickstyledtext.cpp index 762d49f2d2..5e1aaf121e 100644 --- a/src/quick/util/qquickstyledtext.cpp +++ b/src/quick/util/qquickstyledtext.cpp @@ -50,6 +50,8 @@ QQuickStyledText supports few tags: <b></b> - bold + <del></del> - strike out (removed content) + <s></s> - strike out (no longer accurate or no longer relevant content) <strong></strong> - bold <i></i> - italic <br> - new line @@ -379,8 +381,16 @@ bool QQuickStyledTextPrivate::parseTag(const QChar *&ch, const QString &textIn, format.setFontWeight(QFont::Bold); return true; } - } else if (tag == QLatin1String("strong")) { - format.setFontWeight(QFont::Bold); + } else if (char0 == QLatin1Char('s')) { + if (tagLength == 1) { + format.setFontStrikeOut(true); + return true; + } else if (tag == QLatin1String("strong")) { + format.setFontWeight(QFont::Bold); + return true; + } + } else if (tag == QLatin1String("del")) { + format.setFontStrikeOut(true); return true; } else if (tag == QLatin1String("ol")) { List listItem; @@ -511,7 +521,13 @@ bool QQuickStyledTextPrivate::parseCloseTag(const QChar *&ch, const QString &tex return true; } else if (tag == QLatin1String("font")) { return true; - } else if (tag == QLatin1String("strong")) { + } else if (char0 == QLatin1Char('s')) { + if (tagLength == 1) { + return true; + } else if (tag == QLatin1String("strong")) { + return true; + } + } else if (tag == QLatin1String("del")) { return true; } else if (tag == QLatin1String("ol")) { if (!listStack.isEmpty()) { |