X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fuisupport%2Fqssparser.cpp;h=8e917b7b34c10e8c76712b8bc862ca90be9d4479;hb=c639f2b13b485c0d158ee3857742eaf4d1fa4760;hp=f46147b34af186190b54957df44a6c43b557cd63;hpb=5e4dd1ccc3277d871153ac3155b1d1443920f9b8;p=quassel.git diff --git a/src/uisupport/qssparser.cpp b/src/uisupport/qssparser.cpp index f46147b3..8e917b7b 100644 --- a/src/uisupport/qssparser.cpp +++ b/src/uisupport/qssparser.cpp @@ -199,7 +199,7 @@ quint64 QssParser::parseFormatType(const QString &decl) { } // Next up: conditional (formats, labels, nickhash) - QRegExp condRx("\\s*(\\w+)\\s*=\\s*\"(\\w+)\"\\s*"); + QRegExp condRx("\\s*([\\w\\-]+)\\s*=\\s*\"(\\w+)\"\\s*"); if(!conditions.isEmpty()) { foreach(const QString &cond, conditions.split(',', QString::SkipEmptyParts)) { if(!condRx.exactMatch(cond)) { @@ -236,19 +236,31 @@ quint64 QssParser::parseFormatType(const QString &decl) { } else if(condName == "format") { if(condValue == "bold") fmtType |= UiStyle::Bold; - if(condValue == "italic") + else if(condValue == "italic") fmtType |= UiStyle::Italic; - if(condValue == "underline") + else if(condValue == "underline") fmtType |= UiStyle::Underline; - if(condValue == "reverse") + else if(condValue == "reverse") fmtType |= UiStyle::Reverse; else { qWarning() << Q_FUNC_INFO << tr("Invalid format name: %1").arg(condValue); return UiStyle::Invalid; } - + } else if(condName == "fg-color" || condName == "bg-color") { + bool ok; + quint8 col = condValue.toUInt(&ok, 16); + if(!ok || col > 0x0f) { + qWarning() << Q_FUNC_INFO << tr("Illegal IRC color specification (must be between 00 and 0f): %1").arg(condValue); + return UiStyle::Invalid; + } + if(condName == "fg-color") + fmtType |= 0x00400000 | (col << 24); + else + fmtType |= 0x00800000 | (col << 28); + } else { + qWarning() << Q_FUNC_INFO << tr("Unhandled condition: %1").arg(condName); + return UiStyle::Invalid; } - // TODO: colors } } @@ -474,7 +486,7 @@ QGradientStops QssParser::parseGradientStops(const QString &str_) { /******** Font Properties ********/ void QssParser::parseFont(const QString& value, QTextCharFormat* format) { - QRegExp rx("((?:(?:normal|italic|oblique|bold|100|200|300|400|500|600|700|800|900) ){0,2}) ?(\\d+)(pt|px)? \"(.*)\""); + QRegExp rx("((?:(?:normal|italic|oblique|underline|bold|100|200|300|400|500|600|700|800|900) ){0,2}) ?(\\d+)(pt|px)? \"(.*)\""); if(!rx.exactMatch(value)) { qWarning() << Q_FUNC_INFO << tr("Invalid font specification: %1").arg(value); return; @@ -485,6 +497,8 @@ void QssParser::parseFont(const QString& value, QTextCharFormat* format) { foreach(QString prop, proplist) { if(prop == "italic") format->setFontItalic(true); + else if(prop == "underline") + format->setFontUnderline(true); //else if(prop == "oblique") // format->setStyle(QFont::StyleOblique); else if(prop == "bold") @@ -508,6 +522,8 @@ void QssParser::parseFontStyle(const QString& value, QTextCharFormat* format) { format->setFontItalic(false); else if(value == "italic") format->setFontItalic(true); + else if(value == "underline") + format->setFontUnderline(true); //else if(value == "oblique") // format->setStyle(QFont::StyleOblique); else {