Don't merge all custom formats with the base format
[quassel.git] / src / uisupport / uistyle.cpp
index d020bb0..75524db 100644 (file)
@@ -102,17 +102,14 @@ void UiStyle::loadStyleSheet() {
     QssParser parser;
     parser.processStyleSheet(styleSheet);
     QApplication::setPalette(parser.palette());
-    _uiStylePalette = parser.uiStylePalette();
 
-    QTextCharFormat baseFmt = parser.formats().value(Base);
-    foreach(quint64 fmtType, parser.formats().keys()) {
-      QTextCharFormat fmt = baseFmt;
-      fmt.merge(parser.formats().value(fmtType));
-      _formats[fmtType] = fmt;
-    }
+    _uiStylePalette = parser.uiStylePalette();
+    _formats = parser.formats();
     _listItemFormats = parser.listItemFormats();
 
-    qApp->setStyleSheet(styleSheet); // pass the remaining sections to the application
+    styleSheet = styleSheet.trimmed();
+    if(!styleSheet.isEmpty())
+      qApp->setStyleSheet(styleSheet); // pass the remaining sections to the application
   }
 
   emit changed();
@@ -352,7 +349,7 @@ void UiStyle::mergeFormat(QTextCharFormat &fmt, quint32 ftype, quint64 label) {
 
   // URL
   if(ftype & Url)
-    mergeSubElementFormat(fmt, ftype & Url, label);
+    mergeSubElementFormat(fmt, ftype & (Url | 0x000000ff), label);
 }
 
 // Merge a subelement format into an existing message format
@@ -455,10 +452,10 @@ UiStyle::StyledString UiStyle::styleString(const QString &s_, quint32 baseFormat
         color &= 0x0f;
         if(s[pos+3] == 'f') {
           curfmt &= 0xf0ffffff;
-          curfmt |= (color << 24) | 0x00400000;
+          curfmt |= (quint32)(color << 24) | 0x00400000;
         } else {
           curfmt &= 0x0fffffff;
-          curfmt |= (color << 28) | 0x00800000;
+          curfmt |= (quint32)(color << 28) | 0x00800000;
         }
         length = 6;
       }
@@ -692,7 +689,7 @@ quint8 UiStyle::StyledMessage::senderHash() const {
   QString nick = nickFromMask(sender()).toLower();
   if(!nick.isEmpty()) {
     int chopCount = 0;
-    while(nick.at(nick.count() - 1 - chopCount) == '_')
+    while(chopCount < nick.size() && nick.at(nick.count() - 1 - chopCount) == '_')
       chopCount++;
     if(chopCount < nick.size())
       nick.chop(chopCount);