add x & y & spacing; render try catch; remove rectangle layer in qml

This commit is contained in:
王劲鹏 2021-02-24 15:47:57 +08:00 committed by osborn
parent 850d6321a0
commit d35c8d2118
7 changed files with 25 additions and 25 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.14.0, 2021-02-24T10:31:57. -->
<!-- Written by QtCreator 4.14.0, 2021-02-24T14:48:39. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

View File

@ -6,18 +6,22 @@
void DoricShaderPlugin::render(QJSValue jsValue, QString callbackId) {
getContext()->getDriver()->asyncCall(
[this, jsValue] {
QString viewId = jsValue.property("id").toString();
DoricRootNode *rootNode = getContext()->getRootNode();
try {
QString viewId = jsValue.property("id").toString();
DoricRootNode *rootNode = getContext()->getRootNode();
if (rootNode->getId().isEmpty() &&
jsValue.property("type").toString() == "Root") {
rootNode->setId(viewId);
rootNode->blend(jsValue.property("props"));
} else {
DoricViewNode *viewNode = getContext()->targetViewNode(viewId);
if (viewNode != nullptr) {
viewNode->blend(jsValue.property("props"));
if (rootNode->getId().isEmpty() &&
jsValue.property("type").toString() == "Root") {
rootNode->setId(viewId);
rootNode->blend(jsValue.property("props"));
} else {
DoricViewNode *viewNode = getContext()->targetViewNode(viewId);
if (viewNode != nullptr) {
viewNode->blend(jsValue.property("props"));
}
}
} catch (...) {
qCritical() << "render exception";
}
},
DoricThreadMode::UI);

View File

@ -1,9 +1,6 @@
import QtQuick 2.12
import QtQuick.Controls 2.5
Rectangle {
Row {
}
Row {
}

View File

@ -2,7 +2,4 @@ import QtQuick 2.12
import QtQuick.Controls 2.5
Rectangle {
StackView {
}
}

View File

@ -2,7 +2,4 @@ import QtQuick 2.12
import QtQuick.Controls 2.5
Rectangle {
StackView {
}
}

View File

@ -1,9 +1,6 @@
import QtQuick 2.12
import QtQuick.Controls 2.5
Rectangle {
Column {
}
Column {
}

View File

@ -47,5 +47,13 @@ void DoricViewNode::blend(QQuickItem *view, QString name, QJSValue prop) {
} else if (name == "backgroundColor") {
QString color = DoricUtils::doricColor(prop.toNumber()).name();
view->setProperty("color", color);
} else if (name == "x") {
view->setProperty("x", prop.toInt());
} else if (name == "y") {
view->setProperty("y", prop.toInt());
} else if (name == "space") {
view->setProperty("spacing", prop.toInt());
} else {
qCritical() << name << ": " << prop.toString();
}
}