forked from qt-creator/qt-creator
QmlDesigner: Extend SVG paste color parsing
Extend the SVG paste color parsing to support the following values rgb(255,255,255) and rgba(255,255,255,1.0). Task-number: QDS-13508 Change-Id: Id7750617b45a94b1541f5a40f31d610de56dbaee Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
4e913b3d37
commit
fd4214205e
@@ -814,8 +814,29 @@ QVariant convertValue(const QByteArray &key, const QString &value)
|
||||
return value.toInt();
|
||||
} else if (key == "opacity") {
|
||||
return value.toFloat();
|
||||
} else if ((key == "fillColor" || key == "strokeColor") && value == "none") {
|
||||
return "transparent";
|
||||
} else if ((key == "fillColor" || key == "strokeColor")) {
|
||||
if (value == "none")
|
||||
return QColor(0, 0, 0, 0);
|
||||
|
||||
static const QRegularExpression reRGB(
|
||||
R"(^rgb\((?<red>\d{1,3}),\s*(?<green>\d{1,3}),\s*(?<blue>\d{1,3})\)$)");
|
||||
QRegularExpressionMatch match = reRGB.match(value);
|
||||
if (match.hasMatch()) {
|
||||
return QColor(match.captured("red").toInt(),
|
||||
match.captured("green").toInt(),
|
||||
match.captured("blue").toInt());
|
||||
}
|
||||
|
||||
static const QRegularExpression reRGBA(
|
||||
R"(^rgba\((?<red>\d{1,3}),\s*(?<green>\d{1,3}),\s*(?<blue>\d{1,3}),\s*(?<alpha>\d*(?:\.\d+))\)$)");
|
||||
match = reRGBA.match(value);
|
||||
if (match.hasMatch()) {
|
||||
QColor color(match.captured("red").toInt(),
|
||||
match.captured("green").toInt(),
|
||||
match.captured("blue").toInt());
|
||||
color.setAlphaF(match.captured("alpha").toFloat());
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
|
Reference in New Issue
Block a user