+void UiStyle::loadStyleSheet() {
+ qDeleteAll(_metricsCache);
+ _metricsCache.clear();
+ _formatCache.clear();
+
+ UiStyleSettings s;
+
+ QString styleSheet;
+ styleSheet += loadStyleSheet("file:///" + Quassel::findDataFilePath("default.qss"));
+ styleSheet += loadStyleSheet("file:///" + Quassel::configDirPath() + "settings.qss");
+ if(s.value("UseCustomStyleSheet", false).toBool())
+ styleSheet += loadStyleSheet("file:///" + s.value("CustomStyleSheetPath").toString(), true);
+ styleSheet += loadStyleSheet("file:///" + Quassel::optionValue("qss"), true);
+
+ if(styleSheet.isEmpty())
+ return;
+
+ QssParser parser;
+ parser.processStyleSheet(styleSheet);
+ QApplication::setPalette(parser.palette());
+ _formatCache = parser.formats();
+
+ qApp->setStyleSheet(styleSheet); // pass the remaining sections to the application
+
+ emit changed();
+}
+
+QString UiStyle::loadStyleSheet(const QString &styleSheet, bool shouldExist) {
+ QString ss = styleSheet;
+ if(ss.startsWith("file:///")) {
+ ss.remove(0, 8);
+ if(ss.isEmpty())
+ return QString();
+
+ QFile file(ss);
+ if(file.open(QFile::ReadOnly)) {
+ QTextStream stream(&file);
+ ss = stream.readAll();
+ file.close();
+ } else {
+ if(shouldExist)
+ qWarning() << "Could not open stylesheet file:" << file.fileName();
+ return QString();
+ }
+ }
+ return ss;
+}
+
+void UiStyle::setTimestampFormatString(const QString &format) {
+ if(_timestampFormatString != format) {
+ _timestampFormatString = format;
+ // FIXME reload
+ }
+}
+
+/******** Caching *******/
+