while((pos = blockrx.indexIn(ss, pos)) >= 0) {
//qDebug() << blockrx.cap(1) << blockrx.cap(2);
- if(blockrx.cap(2) == "ChatLine")
+ if(blockrx.cap(1).startsWith("ChatLine"))
parseChatLineData(blockrx.cap(1).trimmed(), blockrx.cap(2).trimmed());
//else
// TODO: add moar here
if(fmtType == UiStyle::Invalid)
return;
-
+ QTextCharFormat format;
+ foreach(QString line, contents.split(';', QString::SkipEmptyParts)) {
+ int idx = line.indexOf(':');
+ if(idx <= 0) {
+ qWarning() << Q_FUNC_INFO << tr("Invalid property declaration: %1").arg(line.trimmed());
+ continue;
+ }
+ QString property = line.left(idx).trimmed();
+ QString value = line.mid(idx + 1).trimmed();
+
+ if(property == "background" || property == "background-color")
+ format.setBackground(parseBrushValue(value));
+ else if(property == "foreground" || property == "color")
+ format.setForeground(parseBrushValue(value));
+
+ else {
+ qWarning() << Q_FUNC_INFO << tr("Unknown ChatLine property: %1").arg(property);
+ }
+ }
+
+ _formats[fmtType] = format;
}
quint64 QssParser::parseFormatType(const QString &decl) {
// First determine the subelement
if(!subElement.isEmpty()) {
- if(subElement == "Timestamp")
+ if(subElement == "timestamp")
fmtType |= UiStyle::Timestamp;
- else if(subElement == "Sender")
+ else if(subElement == "sender")
fmtType |= UiStyle::Sender;
- else if(subElement == "Nick")
+ else if(subElement == "nick")
fmtType |= UiStyle::Nick;
- else if(subElement == "Hostmask")
+ else if(subElement == "hostmask")
fmtType |= UiStyle::Hostmask;
- else if(subElement == "ModeFlags")
+ else if(subElement == "modeflags")
fmtType |= UiStyle::ModeFlags;
else {
qWarning() << Q_FUNC_INFO << tr("Invalid subelement name in %1").arg(decl);
// Now, figure out the message type
if(!msgType.isEmpty()) {
- if(msgType == "Plain")
+ if(msgType == "plain")
fmtType |= UiStyle::PlainMsg;
- else if(msgType == "Notice")
+ else if(msgType == "notice")
fmtType |= UiStyle::NoticeMsg;
- else if(msgType == "Server")
+ else if(msgType == "server")
fmtType |= UiStyle::ServerMsg;
- else if(msgType == "Error")
+ else if(msgType == "error")
fmtType |= UiStyle::ErrorMsg;
- else if(msgType == "Join")
+ else if(msgType == "join")
fmtType |= UiStyle::JoinMsg;
- else if(msgType == "Part")
+ else if(msgType == "part")
fmtType |= UiStyle::PartMsg;
- else if(msgType == "Quit")
+ else if(msgType == "quit")
fmtType |= UiStyle::QuitMsg;
- else if(msgType == "Kick")
+ else if(msgType == "kick")
fmtType |= UiStyle::KickMsg;
- else if(msgType == "Rename")
+ else if(msgType == "rename")
fmtType |= UiStyle::RenameMsg;
- else if(msgType == "Mode")
+ else if(msgType == "mode")
fmtType |= UiStyle::ModeMsg;
- else if(msgType == "Action")
+ else if(msgType == "action")
fmtType |= UiStyle::ActionMsg;
else {
qWarning() << Q_FUNC_INFO << tr("Invalid message type in %1").arg(decl);
}
}
-QBrush QssParser::parseBrushValue(const QString &str) {
+QBrush QssParser::parseBrushValue(const QString &str, bool *ok) {
+ if(ok)
+ *ok = false;
QColor c = parseColorValue(str);
- if(c.isValid())
+ if(c.isValid()) {
+ if(ok)
+ *ok = true;
return QBrush(c);
+ }
if(str.startsWith("palette")) { // Palette color role
QRegExp rx("palette\\s*\\(\\s*([a-z-]+)\\s*\\)");
}
QLinearGradient gradient(x1, y1, x2, y2);
gradient.setStops(stops);
+ if(ok)
+ *ok = true;
return QBrush(gradient);
} else if(str.startsWith("qconicalgradient")) {
}
QConicalGradient gradient(cx, cy, angle);
gradient.setStops(stops);
+ if(ok)
+ *ok = true;
return QBrush(gradient);
} else if(str.startsWith("qradialgradient")) {
}
QRadialGradient gradient(cx, cy, radius, fx, fy);
gradient.setStops(stops);
+ if(ok)
+ *ok = true;
return QBrush(gradient);
}