+ // If no style sheet exists, generate it on first run.
+ initializeSettingsQss();
+}
+
+void QtUiStyle::updateUseCustomTimestampFormat()
+{
+ ChatViewSettings s;
+ setUseCustomTimestampFormat(s.useCustomTimestampFormat());
+}
+
+void QtUiStyle::updateTimestampFormatString()
+{
+ ChatViewSettings s;
+ setTimestampFormatString(s.timestampFormatString());
+}
+
+void QtUiStyle::updateSenderPrefixDisplay()
+{
+ ChatViewSettings s;
+ setSenderPrefixDisplay(s.senderPrefixDisplay());
+}
+
+void QtUiStyle::updateShowSenderBrackets()
+{
+ ChatViewSettings s;
+ enableSenderBrackets(s.showSenderBrackets());
+}
+
+void QtUiStyle::initializeSettingsQss()
+{
+ QFileInfo settingsQss(Quassel::configDirPath() + "settings.qss");
+ // Only initialize if it doesn't already exist
+ if (settingsQss.exists())
+ return;
+
+ // Generate and load the new stylesheet
+ generateSettingsQss();
+ reload();
+}
+
+void QtUiStyle::generateSettingsQss() const
+{
+ QFile settingsQss(Quassel::configDirPath() + "settings.qss");
+
+ if (!settingsQss.open(QFile::WriteOnly | QFile::Truncate)) {
+ qWarning() << "Could not open" << settingsQss.fileName() << "for writing!";
+ return;
+ }
+ QTextStream out(&settingsQss);
+
+ out << "// Style settings made in Quassel's configuration dialog\n"
+ << "// This file is automatically generated, do not edit\n";
+
+ // ChatView
+ ///////////
+ QtUiStyleSettings fs("Fonts");
+ if (fs.value("UseCustomChatViewFont").toBool())
+ out << "\n// ChatView Font\n"
+ << "ChatLine { " << fontDescription(fs.value("ChatView").value<QFont>()) << "; }\n";