Add --qss parameter to load a custom stylesheet
[quassel.git] / src / uisupport / qssparser.cpp
index d7a788e..91ecac5 100644 (file)
@@ -51,20 +51,7 @@ QssParser::QssParser()
   _paletteColorRoles["window-text"] = QPalette::WindowText;
 }
 
-void QssParser::loadStyleSheet(const QString &styleSheet) {
-  QString ss = styleSheet;
-  ss = "file:////home/sputnick/devel/quassel/test.qss"; // FIXME
-  if(ss.startsWith("file:///")) {
-    ss.remove(0, 8);
-    QFile file(ss);
-    if(file.open(QFile::ReadOnly)) {
-      QTextStream stream(&file);
-      ss = stream.readAll();
-    } else {
-      qWarning() << tr("Could not read stylesheet \"%1\"!").arg(file.fileName());
-      return;
-    }
-  }
+void QssParser::processStyleSheet(QString &ss) {
   if(ss.isEmpty())
     return;
 
@@ -237,12 +224,26 @@ quint64 QssParser::parseFormatType(const QString &decl) {
               qWarning() << Q_FUNC_INFO << tr("Invalid senderhash specification: %1").arg(condValue);
               return UiStyle::Invalid;
             }
-            if(val >= 255) {
-              qWarning() << Q_FUNC_INFO << tr("Senderhash can be at most \"fe\"!");
+            if(val >= 16) {
+              qWarning() << Q_FUNC_INFO << tr("Senderhash can be at most \"0x0f\"!");
               return UiStyle::Invalid;
             }
             fmtType |= val << 48;
           }
+      } else if(condName == "format") {
+        if(condValue == "bold")
+          fmtType |= UiStyle::Bold;
+        if(condValue == "italic")
+          fmtType |= UiStyle::Italic;
+        if(condValue == "underline")
+          fmtType |= UiStyle::Underline;
+        if(condValue == "reverse")
+          fmtType |= UiStyle::Reverse;
+        else {
+          qWarning() << Q_FUNC_INFO << tr("Invalid format name: %1").arg(condValue);
+          return UiStyle::Invalid;
+        }
+
       }
       // TODO: colors
     }