add gradient for stack

This commit is contained in:
王劲鹏
2021-04-30 19:56:05 +08:00
committed by osborn
parent 7dfc7f7929
commit 6143f65f1e
2 changed files with 153 additions and 3 deletions

View File

@@ -105,9 +105,53 @@ void DoricViewNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
} else if (name == "height") {
getLayouts()->setHeight(prop.toDouble());
} else if (name == "backgroundColor") {
view->setProperty(
"backgroundColor",
QVariant::fromValue(DoricUtils::doricColor(prop.toInt())));
if (prop.isDouble()) {
view->setProperty("backgroundColorIsObject", false);
view->setProperty(
"backgroundColor",
QVariant::fromValue(DoricUtils::doricColor(prop.toInt())));
} else if (prop.isObject()) {
QJsonObject dict = prop.toObject();
view->setProperty("backgroundColorIsObject", true);
QJsonValue orientation = prop["orientation"];
if (orientation.isDouble()) {
view->setProperty("orientation", orientation.toInt());
}
if (dict.keys().contains("colors")) {
QVector<int> colors;
QJsonArray colorArray = dict["colors"].toArray();
for (int i = 0; i != colorArray.size(); i++) {
colors.append(colorArray.at(i).toInt());
}
if (dict.keys().contains("locations")) {
QJsonValue locationsValue = dict["locations"];
if (locationsValue.isArray()) {
QVector<double> locations;
QJsonArray locationArray = locationsValue.toArray();
for (int i = 0; i != locationArray.size(); i++) {
locations.append(locationArray.at(i).toDouble());
}
view->setProperty("gradientLocations",
QVariant::fromValue(locations));
}
}
view->setProperty("gradientColors", QVariant::fromValue(colors));
} else {
if (dict.keys().contains("start") && dict.keys().contains("end")) {
int start = dict["start"].toInt();
int end = dict["end"].toInt();
QVector<int> colors;
colors.append(start);
colors.append(end);
view->setProperty("gradientColors", QVariant::fromValue(colors));
}
}
}
} else if (name == "x") {
getLayouts()->setMarginLeft(prop.toDouble());
} else if (name == "y") {