From: Manuel Nickschas Date: Wed, 7 Mar 2018 23:47:39 +0000 (+0100) Subject: uistyle: Support rendering of strikethrough'd text X-Git-Tag: travis-deploy-test~164 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=f56f4515fa722a9e20bca9457ff876e1a0a5f38c;ds=sidebyside uistyle: Support rendering of strikethrough'd text As defined in [1], format code 0x1e indicates text that is struck through. Add support for rendering this accordingly. Extend the stylesheet parser so the format can be defined, and add to the default stylesheet. [1] https://modern.ircdocs.horse/formatting.html#strikethrough --- diff --git a/data/stylesheets/default.qss b/data/stylesheets/default.qss index 506dda97..6027980a 100644 --- a/data/stylesheets/default.qss +++ b/data/stylesheets/default.qss @@ -77,9 +77,10 @@ ChatLine[fg-color="0f"] { foreground: #c0c0c0; } ChatLine[bg-color="0f"] { background: #c0c0c0; } // mIRC formats -ChatLine[format="bold"] { font-weight: bold; } -ChatLine[format="italic"] { font-style: italic; } -ChatLine[format="underline"] { font-style: underline; } +ChatLine[format="bold"] { font-weight: bold; } +ChatLine[format="italic"] { font-style: italic; } +ChatLine[format="underline"] { font-style: underline; } +ChatLine[format="strikethrough"] { font-style: strikethrough; } // ChatView message colors ChatLine#notice { foreground: #916409; } diff --git a/src/uisupport/qssparser.cpp b/src/uisupport/qssparser.cpp index 07dab3a8..3e5cd8ed 100644 --- a/src/uisupport/qssparser.cpp +++ b/src/uisupport/qssparser.cpp @@ -322,6 +322,8 @@ std::pair QssParser::parseFormatType fmtType |= FormatType::Italic; else if (condValue == "underline") fmtType |= FormatType::Underline; + else if (condValue == "strikethrough") + fmtType |= FormatType::Strikethrough; else { qWarning() << Q_FUNC_INFO << tr("Invalid format name: %1").arg(condValue); return invalid; @@ -713,7 +715,7 @@ QGradientStops QssParser::parseGradientStops(const QString &str_) void QssParser::parseFont(const QString &value, QTextCharFormat *format) { - static const QRegExp rx("((?:(?:normal|italic|oblique|underline|bold|100|200|300|400|500|600|700|800|900) ){0,2}) ?(\\d+)(pt|px)? \"(.*)\""); + static const QRegExp rx("((?:(?:normal|italic|oblique|underline|strikethrough|bold|100|200|300|400|500|600|700|800|900) ){0,2}) ?(\\d+)(pt|px)? \"(.*)\""); if (!rx.exactMatch(value)) { qWarning() << Q_FUNC_INFO << tr("Invalid font specification: %1").arg(value); return; @@ -726,6 +728,7 @@ void QssParser::parseFont(const QString &value, QTextCharFormat *format) format->setFontItalic(true); else if (prop == "underline") format->setFontUnderline(true); + // Oblique is not a property supported by QTextCharFormat //else if(prop == "oblique") // format->setStyle(QFont::StyleOblique); else if (prop == "bold") @@ -753,6 +756,9 @@ void QssParser::parseFontStyle(const QString &value, QTextCharFormat *format) format->setFontItalic(true); else if (value == "underline") format->setFontUnderline(true); + else if (value == "strikethrough") + format->setFontStrikeOut(true); + // Oblique is not a property supported by QTextCharFormat //else if(value == "oblique") // format->setStyle(QFont::StyleOblique); else { diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index bd9b013c..831c76eb 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -85,8 +85,9 @@ UiStyle::UiStyle(QObject *parent) // Now initialize the mapping between FormatCodes and FormatTypes... _formatCodes["%O"] = FormatType::Base; _formatCodes["%B"] = FormatType::Bold; - _formatCodes["%S"] = FormatType::Italic; + _formatCodes["%I"] = FormatType::Italic; _formatCodes["%U"] = FormatType::Underline; + _formatCodes["%S"] = FormatType::Strikethrough; _formatCodes["%DN"] = FormatType::Nick; _formatCodes["%DH"] = FormatType::Hostmask; @@ -761,6 +762,9 @@ QString UiStyle::mircToInternal(const QString &mirc_) mirc += "%R"; break; case '\x1d': + mirc += "%I"; + break; + case '\x1e': mirc += "%S"; break; case '\x1f': diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index 35d9eeeb..023808e7 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -81,6 +81,7 @@ public: Bold = 0x00000100, Italic = 0x00000200, Underline = 0x00000400, + Strikethrough = 0x00000800, // Individual parts of a message Timestamp = 0x00001000,