if(ss.isEmpty())
return;
- // Now we have the stylesheet itself in ss, start parsing
+ // Remove C-style comments /* */ or //
+ QRegExp commentRx("(//.*(\\n|$)|/\\*.*\\*/)");
+ commentRx.setMinimal(true);
+ ss.remove(commentRx);
+
// Palette definitions first, so we can apply roles later on
QRegExp paletterx("(Palette[^{]*)\\{([^}]+)\\}");
int pos = 0;
while((pos = paletterx.indexIn(ss, pos)) >= 0) {
parsePaletteData(paletterx.cap(1).trimmed(), paletterx.cap(2).trimmed());
- pos += paletterx.matchedLength();
+ ss.remove(pos, paletterx.matchedLength());
}
// Now we can parse the rest of our custom blocks
//else
// TODO: add moar here
- pos += blockrx.matchedLength();
+ ss.remove(pos, blockrx.matchedLength());
}
-
}
void QssParser::parseChatLineData(const QString &decl, const QString &contents) {
}
}
- _formats[fmtType] = format;
+ _formats[fmtType].merge(format);
}
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)) {
quint64 labeltype = 0;
if(condValue == "highlight")
labeltype = UiStyle::Highlight;
+ else if(condValue == "selected")
+ labeltype = UiStyle::Selected;
else {
qWarning() << Q_FUNC_INFO << tr("Invalid message label: %1").arg(condValue);
return UiStyle::Invalid;
} 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
}
}
}
QString rolestr = line.left(idx).trimmed();
QString brushstr = line.mid(idx + 1).trimmed();
+
+ // We treat the marker line color as a palette role even though it isn't -> special casing
+ if(rolestr == "marker-line") {
+ _markerLineBrush = parseBrush(brushstr);
+ continue;
+ }
+
if(!_paletteColorRoles.contains(rolestr)) {
qWarning() << Q_FUNC_INFO << tr("Unknown palette role name: %1").arg(rolestr);
continue;
/******** 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;
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")
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 {