Use new nick for finding hash of Nick messages
authorShane Synan <digitalcircuit36939@gmail.com>
Sat, 3 Dec 2016 00:43:15 +0000 (18:43 -0600)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 12 Apr 2017 20:51:18 +0000 (22:51 +0200)
For nick change messages, use the new nickname for calculating the
sender hash, not the old one.  This more closely matches
expectations.

Works around a limitation in the Quassel theming engine that doesn't
allow different styling for multiple nicks in one message.
Unfortunately, rewriting the necessary parts of the theme engine to
support multiple styles per nick is above my understanding right now.

src/uisupport/uistyle.cpp

index 6c6e999..f35543d 100644 (file)
@@ -961,7 +961,19 @@ quint8 UiStyle::StyledMessage::senderHash() const
     if (_senderHash != 0xff)
         return _senderHash;
 
-    QString nick = nickFromMask(sender()).toLower();
+    QString nick;
+
+    // HACK: Until multiple nicknames with different colors can be solved in the theming engine,
+    // for /nick change notifications, use the color of the new nickname (if possible), not the old
+    // nickname.
+    if (type() == Message::Nick) {
+        // New nickname is given as contents.  Change to that.
+        nick = stripFormatCodes(contents()).toLower();
+    } else {
+        // Just use the sender directly
+        nick = nickFromMask(sender()).toLower();
+    }
+
     if (!nick.isEmpty()) {
         int chopCount = 0;
         while (chopCount < nick.size() && nick.at(nick.count() - 1 - chopCount) == '_')