From 670e7d401aae1196c0a24c59f96d267a8eb9d1bb Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 24 Jul 2018 23:19:27 +0200 Subject: [PATCH] qss: Introduce new message label "hovered" In order to make the appearance of hovered-upon URLs controllable by stylesheet, add support for a new message label "hovered". Extend the default stylesheet to underline hovered-upon URLs. --- data/stylesheets/default.qss | 4 ++++ src/uisupport/qssparser.cpp | 2 ++ src/uisupport/uistyle.cpp | 4 ++-- src/uisupport/uistyle.h | 4 +++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/data/stylesheets/default.qss b/data/stylesheets/default.qss index 61ccd4c1..e372d24f 100644 --- a/data/stylesheets/default.qss +++ b/data/stylesheets/default.qss @@ -25,6 +25,10 @@ ChatLine[label="selected"] { allow-background-override: false; } +ChatLine[label="hovered"] { + font-style: underline; +} + // ChatLine::sender[sender="self"] { // font-style: italic; // } diff --git a/src/uisupport/qssparser.cpp b/src/uisupport/qssparser.cpp index ff47c05f..031933a5 100644 --- a/src/uisupport/qssparser.cpp +++ b/src/uisupport/qssparser.cpp @@ -293,6 +293,8 @@ std::pair QssParser::parseFormatType label |= MessageLabel::Highlight; else if (condValue == "selected") label |= MessageLabel::Selected; + else if (condValue == "hovered") + label |= MessageLabel::Hovered; else { qWarning() << Q_FUNC_INFO << tr("Invalid message label: %1").arg(condValue); return invalid; diff --git a/src/uisupport/uistyle.cpp b/src/uisupport/uistyle.cpp index 879fc350..cbae7e68 100644 --- a/src/uisupport/uistyle.cpp +++ b/src/uisupport/uistyle.cpp @@ -475,7 +475,7 @@ QTextCharFormat UiStyle::format(const Format &format, MessageLabel label) const // Merge all formats except mIRC and extended colors mergeFormat(charFormat, format, label & 0xffff0000); // keep nickhash in label - for (quint32 mask = 0x00000001; mask <= static_cast(MessageLabel::Selected); mask <<= 1) { + for (quint32 mask = 0x00000001; mask <= static_cast(MessageLabel::Last); mask <<= 1) { if (static_cast(label) & mask) { mergeFormat(charFormat, format, label & (mask | 0xffff0000)); } @@ -485,7 +485,7 @@ QTextCharFormat UiStyle::format(const Format &format, MessageLabel label) const // unless the AllowForegroundOverride or AllowBackgroundOverride properties are set (via stylesheet). if (_allowMircColors) { mergeColors(charFormat, format, MessageLabel::None); - for (quint32 mask = 0x00000001; mask <= static_cast(MessageLabel::Selected); mask <<= 1) { + for (quint32 mask = 0x00000001; mask <= static_cast(MessageLabel::Last); mask <<= 1) { if (static_cast(label) & mask) { mergeColors(charFormat, format, label & mask); } diff --git a/src/uisupport/uistyle.h b/src/uisupport/uistyle.h index b87e2211..6ea9fa8c 100644 --- a/src/uisupport/uistyle.h +++ b/src/uisupport/uistyle.h @@ -105,7 +105,9 @@ public: None = 0x00000000, OwnMsg = 0x00000001, Highlight = 0x00000002, - Selected = 0x00000004 // must be last! + Selected = 0x00000004, + Hovered = 0x00000008, + Last = Hovered }; enum class ItemFormatType : quint32 { -- 2.20.1