/***************************************************************************
- * 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 *
#include "qtuistyle.h"
#include <QFile>
+#include <QFileInfo>
#include <QTextStream>
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();
setTimestampFormatString(s.timestampFormatString());
}
+void QtUiStyle::updateSenderPrefixDisplay()
+{
+ ChatViewSettings s;
+ setSenderPrefixDisplay(s.SenderPrefixDisplay());
+}
+
void QtUiStyle::updateShowSenderBrackets()
{
ChatViewSettings s;
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
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());
}
}
+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));