X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fqtuistyle.cpp;h=efca13a50685986b9c79f6c0b2e94107533c172e;hb=a0e333e994dce2d949a84930293382020e724596;hp=a81f929517c65cc9826ae3a6d168b943590dd3f5;hpb=12d401fe2949ca2c823ea38181361650eaaeae66;p=quassel.git diff --git a/src/qtui/qtuistyle.cpp b/src/qtui/qtuistyle.cpp index a81f9295..efca13a5 100644 --- a/src/qtui/qtuistyle.cpp +++ b/src/qtui/qtuistyle.cpp @@ -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 +#include #include 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(); @@ -39,8 +42,6 @@ QtUiStyle::QtUiStyle(QObject *parent) : UiStyle(parent) } -QtUiStyle::~QtUiStyle() {} - void QtUiStyle::updateUseCustomTimestampFormat() { ChatViewSettings s; @@ -53,6 +54,12 @@ void QtUiStyle::updateTimestampFormatString() setTimestampFormatString(s.timestampFormatString()); } +void QtUiStyle::updateSenderPrefixDisplay() +{ + ChatViewSettings s; + setSenderPrefixDisplay(s.SenderPrefixDisplay()); +} + void QtUiStyle::updateShowSenderBrackets() { ChatViewSettings s; @@ -153,6 +160,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 @@ -180,7 +198,7 @@ void QtUiStyle::generateSettingsQss() const out << "\n// NickView Colors\n" << "NickListItem[type=\"category\"] { foreground: " << color("DefaultBuffer", uiColors) << "; }\n" << "NickListItem[type=\"user\"] { foreground: " << color("OnlineNick", uiColors) << "; }\n" - << "NickListItem[type=\"user\", state=\"away\"] { foreground: " << color("AwayNick", uiColors) << "; }\n"; + << R"(NickListItem[type="user", state="away"] { foreground: )" << color("AwayNick", uiColors) << "; }\n"; } settingsQss.close(); @@ -195,15 +213,16 @@ QString QtUiStyle::color(const QString &key, UiSettings &settings, const QColor QString QtUiStyle::fontDescription(const QFont &font) const { - QString desc = "font: "; - if (font.italic()) - desc += "italic "; - if (font.bold()) - desc += "bold "; - if (!font.italic() && !font.bold()) - desc += "normal "; - desc += QString("%1pt \"%2\"").arg(font.pointSize()).arg(font.family()); - return desc; + QFont::Style style = font.style(); + int weight = font.weight(); + + return QString("font: %1 %2 %3pt \"%4\"") + .arg(style == QFont::StyleItalic ? "italic" : + style == QFont::StyleOblique ? "oblique" : + "normal") + .arg(100 * qBound(1, (weight * 8 + 50) / 100, 9)) + .arg(font.pointSize()) + .arg(font.family()); } @@ -251,6 +270,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));