qss: Introduce new message label "hovered"
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 24 Jul 2018 21:19:27 +0000 (23:19 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Tue, 28 Aug 2018 19:47:05 +0000 (21:47 +0200)
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
src/uisupport/qssparser.cpp
src/uisupport/uistyle.cpp
src/uisupport/uistyle.h

index 61ccd4c..e372d24 100644 (file)
@@ -25,6 +25,10 @@ ChatLine[label="selected"] {
   allow-background-override: false;
 }
 
+ChatLine[label="hovered"] {
+  font-style: underline;
+}
+
 // ChatLine::sender[sender="self"] {
 //   font-style: italic;
 // }
index ff47c05..031933a 100644 (file)
@@ -293,6 +293,8 @@ std::pair<UiStyle::FormatType, UiStyle::MessageLabel> 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;
index 879fc35..cbae7e6 100644 (file)
@@ -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<quint32>(MessageLabel::Selected); mask <<= 1) {
+    for (quint32 mask = 0x00000001; mask <= static_cast<quint32>(MessageLabel::Last); mask <<= 1) {
         if (static_cast<quint32>(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<quint32>(MessageLabel::Selected); mask <<= 1) {
+        for (quint32 mask = 0x00000001; mask <= static_cast<quint32>(MessageLabel::Last); mask <<= 1) {
             if (static_cast<quint32>(label) & mask) {
                 mergeColors(charFormat, format, label & mask);
             }
index b87e221..6ea9fa8 100644 (file)
@@ -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 {