client: Highest sender prefix mode, migrate, fix
[quassel.git] / src / qtui / qtuistyle.cpp
index a81f929..f8e56aa 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2016 by the Quassel Project                        *
+ *   Copyright (C) 2005-2018 by the Quassel Project                        *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -22,6 +22,7 @@
 #include "qtuistyle.h"
 
 #include <QFile>
+#include <QFileInfo>
 #include <QTextStream>
 
 QtUiStyle::QtUiStyle(QObject *parent) : UiStyle(parent)
@@ -31,6 +32,8 @@ QtUiStyle::QtUiStyle(QObject *parent) : UiStyle(parent)
     updateUseCustomTimestampFormat();
     s.notify("TimestampFormat", this, SLOT(updateTimestampFormatString()));
     updateTimestampFormatString();
+    s.notify("SenderPrefixMode", this, SLOT(updateSenderPrefixDisplay()));
+    updateSenderPrefixDisplay();
     s.notify("ShowSenderBrackets", this, SLOT(updateShowSenderBrackets()));
     updateShowSenderBrackets();
 
@@ -53,6 +56,12 @@ void QtUiStyle::updateTimestampFormatString()
     setTimestampFormatString(s.timestampFormatString());
 }
 
+void QtUiStyle::updateSenderPrefixDisplay()
+{
+    ChatViewSettings s;
+    setSenderPrefixDisplay(s.SenderPrefixDisplay());
+}
+
 void QtUiStyle::updateShowSenderBrackets()
 {
     ChatViewSettings s;
@@ -153,6 +162,17 @@ void QtUiStyle::generateSettingsQss() const
                 out << senderQss(i, "action", true);
         }
 
+        // Only color the nicks in CTCP ACTIONs if sender colors are enabled
+        if (s.value("UseNickGeneralColors", true).toBool()) {
+            // For action messages, color the 'sender' column -and- the nick itself
+            out << "\n// Nickname colors for all messages\n"
+                << "ChatLine::nick[sender=\"self\"] { foreground: palette(sender-color-self); }\n\n";
+
+            // Matches qssparser.cpp for any style of message (UiStyle::...)
+            for (int i = 0; i < defaultSenderColors.count(); i++)
+                out << nickQss(i);
+        }
+
     }
 
     // ItemViews
@@ -251,6 +271,16 @@ QString QtUiStyle::senderQss(int i, const QString &messageType, bool includeNick
 }
 
 
+QString QtUiStyle::nickQss(int i) const
+{
+    QString dez = QString::number(i);
+    if (dez.length() == 1) dez.prepend('0');
+
+    return QString("ChatLine::nick[sender=\"0%1\"]   { foreground: palette(sender-color-0%1); }\n")
+            .arg(QString::number(i, 16));
+}
+
+
 QString QtUiStyle::chatListItemQss(const QString &state, const QString &key, UiSettings &settings) const
 {
     return QString("ChatListItem[state=\"%1\"] { foreground: %2; }\n").arg(state, color(key, settings));