+
+QString QtUiStyle::color(const QString &key, UiSettings &settings, const QColor &defaultColor) const
+{
+ return settings.value(key, defaultColor).value<QColor>().name();
+}
+
+
+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;
+}
+
+
+QString QtUiStyle::msgTypeQss(const QString &msgType, const QString &key, UiSettings &settings) const
+{
+ return QString("ChatLine#%1 { foreground: %2; }\n").arg(msgType, color(key, settings));
+}
+
+
+QString QtUiStyle::senderPaletteQss(UiSettings &settings) const
+{
+ QString result;
+ result += "Palette {\n";
+
+ // Generate entries for sender-color-self
+ result += QString(" sender-color-self: %1;\n")
+ .arg(color("SenderSelf", settings, defaultSenderColorSelf));
+
+ // Generate entries for sender-color-HASH
+ for (int i = 0; i < defaultSenderColors.count(); i++) {
+ QString dez = QString::number(i);
+ if (dez.length() == 1) dez.prepend('0');
+ result += QString(" sender-color-0%1: %2;\n")
+ .arg(QString::number(i, 16), color("Sender"+dez, settings, defaultSenderColors[i]));
+ }
+ result += "}\n\n";
+ return result;
+}
+
+
+QString QtUiStyle::senderQss(int i, const QString &messageType, bool includeNick) const
+{
+ QString dez = QString::number(i);
+ if (dez.length() == 1) dez.prepend('0');
+
+ if (includeNick) {
+ // Include the nickname in the color rules
+ return QString("ChatLine::sender#%1[sender=\"0%2\"] { foreground: palette(sender-color-0%2); }\n"
+ "ChatLine::nick#%1[sender=\"0%2\"] { foreground: palette(sender-color-0%2); }\n")
+ .arg(messageType, QString::number(i, 16));
+ } else {
+ return QString("ChatLine::sender#%1[sender=\"0%2\"] { foreground: palette(sender-color-0%2); }\n")
+ .arg(messageType, QString::number(i, 16));
+ }
+}
+
+
+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));
+}