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) {
}
}
-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);
}
bool parsePalette(QPalette &, const QString &qss);
// Parse basic data types
- QBrush parseBrushValue(const QString &str);
+ QBrush parseBrushValue(const QString &str, bool *ok = 0);
QColor parseColorValue(const QString &str);
QFont parseFontValue(const QString &str);