snake build on v8 success
This commit is contained in:
parent
7458d0f4c0
commit
7e59150831
@ -13,16 +13,16 @@ void DoricDemoBridge::navigate(QVariant route) {
|
||||
QString name;
|
||||
switch (route.toInt()) {
|
||||
case 0:
|
||||
name = "Counter.es5.js";
|
||||
name = "Counter.js";
|
||||
break;
|
||||
case 1:
|
||||
name = "Gobang.es5.js";
|
||||
name = "Gobang.js";
|
||||
break;
|
||||
case 2:
|
||||
name = "SimpleDemo.es5.js";
|
||||
name = "SimpleDemo.js";
|
||||
break;
|
||||
case 3:
|
||||
name = "Snake.es5.js";
|
||||
name = "Snake.js";
|
||||
break;
|
||||
}
|
||||
QString script = DoricUtils::readAssetFile("/doric/bundles", name);
|
||||
|
@ -21,7 +21,7 @@ void DoricBridgeExtension::callNative(QString contextId, QString module,
|
||||
QObject *plugin = context->obtainPlugin(module);
|
||||
QMetaObject::invokeMethod(plugin, methodName.toUtf8(), Qt::DirectConnection,
|
||||
QGenericReturnArgument(),
|
||||
Q_ARG(QJsonObject, jsValue),
|
||||
Q_ARG(QJsonObject *, &jsValue),
|
||||
Q_ARG(QString, callbackId));
|
||||
}
|
||||
qDebug() << "contextId: " + contextId << "module: " + module
|
||||
|
@ -1,23 +1,24 @@
|
||||
#include <QDebug>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "../shader/DoricRootNode.h"
|
||||
#include "DoricShaderPlugin.h"
|
||||
|
||||
void DoricShaderPlugin::render(QJSValue jsValue, QString callbackId) {
|
||||
void DoricShaderPlugin::render(QJsonObject *jsValue, QString callbackId) {
|
||||
getContext()->getDriver()->asyncCall(
|
||||
[this, jsValue] {
|
||||
try {
|
||||
QString viewId = jsValue.property("id").toString();
|
||||
QString viewId = jsValue->value("id").toString();
|
||||
DoricRootNode *rootNode = getContext()->getRootNode();
|
||||
|
||||
if (rootNode->getId().isEmpty() &&
|
||||
jsValue.property("type").toString() == "Root") {
|
||||
jsValue->value("type").toString() == "Root") {
|
||||
rootNode->setId(viewId);
|
||||
rootNode->blend(jsValue.property("props"));
|
||||
rootNode->blend(jsValue->value("props"));
|
||||
} else {
|
||||
DoricViewNode *viewNode = getContext()->targetViewNode(viewId);
|
||||
if (viewNode != nullptr) {
|
||||
viewNode->blend(jsValue.property("props"));
|
||||
viewNode->blend(jsValue->value("props"));
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
|
@ -11,7 +11,7 @@ class DoricShaderPlugin : public DoricNativePlugin {
|
||||
public:
|
||||
using DoricNativePlugin::DoricNativePlugin;
|
||||
|
||||
Q_INVOKABLE void render(QJSValue jsValue, QString callbackId);
|
||||
Q_INVOKABLE void render(QJsonObject *jsValue, QString callbackId);
|
||||
};
|
||||
|
||||
#endif // SHADERPLUGIN_H
|
||||
|
@ -4,14 +4,14 @@
|
||||
<file alias="qtquickcontrols2.conf">resources/qtquickcontrols2.conf</file>
|
||||
</qresource>
|
||||
<qresource prefix="/doric">
|
||||
<file alias="doric-sandbox.es5.js">../../doric-js/bundle/doric-sandbox.es5.js</file>
|
||||
<file alias="doric-lib.es5.js">../../doric-js/bundle/doric-lib.es5.js</file>
|
||||
<file alias="doric-sandbox.js">../../doric-js/bundle/doric-sandbox.js</file>
|
||||
<file alias="doric-lib.js">../../doric-js/bundle/doric-lib.js</file>
|
||||
</qresource>
|
||||
<qresource prefix="/doric/bundles">
|
||||
<file alias="Counter.es5.js">../../doric-demo/bundle/src/Counter.es5.js</file>
|
||||
<file alias="Gobang.es5.js">../../doric-demo/bundle/src/Gobang.es5.js</file>
|
||||
<file alias="SimpleDemo.es5.js">../../doric-demo/bundle/src/SimpleDemo.es5.js</file>
|
||||
<file alias="Snake.es5.js">../../doric-demo/bundle/src/Snake.es5.js</file>
|
||||
<file alias="Counter.js">../../doric-demo/bundle/src/Counter.js</file>
|
||||
<file alias="Gobang.js">../../doric-demo/bundle/src/Gobang.js</file>
|
||||
<file alias="SimpleDemo.js">../../doric-demo/bundle/src/SimpleDemo.js</file>
|
||||
<file alias="Snake.js">../../doric-demo/bundle/src/Snake.js</file>
|
||||
</qresource>
|
||||
<qresource prefix="/doric/qml">
|
||||
<file alias="Flex.qml">resources/Flex.qml</file>
|
||||
|
@ -20,13 +20,13 @@ ApplicationWindow {
|
||||
text: {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return "Counter.es5.js"
|
||||
return "Counter.js"
|
||||
case 1:
|
||||
return "Gobang.es5.js"
|
||||
return "Gobang.js"
|
||||
case 2:
|
||||
return "SimpleDemo.es5.js"
|
||||
return "SimpleDemo.js"
|
||||
case 3:
|
||||
return "Snake.es5.js"
|
||||
return "Snake.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
#include "DoricGroupNode.h"
|
||||
|
||||
void DoricGroupNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
void DoricGroupNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||
if (name == "children") {
|
||||
mChildViewIds.clear();
|
||||
if (prop.isArray()) {
|
||||
const int length = prop.property("length").toInt();
|
||||
QJsonArray array = prop.toArray();
|
||||
const int length = array.size();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
QJSValue value = prop.property(i);
|
||||
QJsonValue value = array.at(i);
|
||||
if (value.isString()) {
|
||||
mChildViewIds.append(value.toString());
|
||||
}
|
||||
@ -17,7 +18,7 @@ void DoricGroupNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
}
|
||||
}
|
||||
|
||||
void DoricGroupNode::blend(QJSValue jsValue) {
|
||||
void DoricGroupNode::blend(QJsonValue jsValue) {
|
||||
DoricViewNode::blend(jsValue);
|
||||
configChildNode();
|
||||
}
|
||||
@ -31,13 +32,13 @@ void DoricGroupNode::configChildNode() {
|
||||
}
|
||||
for (int idx = 0; idx < mChildViewIds.size(); idx++) {
|
||||
QString id = mChildViewIds.at(idx);
|
||||
QJSValue model = getSubModel(id);
|
||||
QJsonValue model = getSubModel(id);
|
||||
if (model.isUndefined()) {
|
||||
DoricRegistry *registry = getContext()->getDriver()->getRegistry();
|
||||
qCritical() << "model.isUndefined()";
|
||||
continue;
|
||||
}
|
||||
QString type = model.property("type").toString();
|
||||
QString type = model["type"].toString();
|
||||
if (idx < mChildNodes.size()) {
|
||||
DoricViewNode *oldNode = mChildNodes.at(idx);
|
||||
if (id == oldNode->getId()) {
|
||||
@ -47,7 +48,7 @@ void DoricGroupNode::configChildNode() {
|
||||
if (oldNode->getType() == type) {
|
||||
// Same type,can be reused
|
||||
oldNode->setId(id);
|
||||
oldNode->blend(model.property("props"));
|
||||
oldNode->blend(model["props"]);
|
||||
} else {
|
||||
// Replace this view
|
||||
mChildNodes.remove(idx);
|
||||
@ -70,7 +71,7 @@ void DoricGroupNode::configChildNode() {
|
||||
parent->childItems().at(idx));
|
||||
}
|
||||
|
||||
newNode->blend(model.property("props"));
|
||||
newNode->blend(model["props"]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -105,7 +106,7 @@ void DoricGroupNode::configChildNode() {
|
||||
parent->childItems().at(idx));
|
||||
}
|
||||
|
||||
newNode->blend(model.property("props"));
|
||||
newNode->blend(model["props"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,7 +127,7 @@ void DoricGroupNode::configChildNode() {
|
||||
newNode->getNodeView()->stackBefore(parent->childItems().at(idx));
|
||||
}
|
||||
|
||||
newNode->blend(model.property("props"));
|
||||
newNode->blend(model["props"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -141,11 +142,11 @@ void DoricGroupNode::configChildNode() {
|
||||
}
|
||||
}
|
||||
|
||||
void DoricGroupNode::blendSubNode(QJSValue subProperties) {
|
||||
QString subNodeId = subProperties.property("id").toString();
|
||||
void DoricGroupNode::blendSubNode(QJsonValue subProperties) {
|
||||
QString subNodeId = subProperties["id"].toString();
|
||||
for (DoricViewNode *node : mChildNodes) {
|
||||
if (subNodeId == node->getId()) {
|
||||
node->blend(subProperties.property("props"));
|
||||
node->blend(subProperties["props"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ class DoricGroupNode : public DoricSuperNode {
|
||||
public:
|
||||
using DoricSuperNode::DoricSuperNode;
|
||||
|
||||
virtual void blend(QQuickItem *view, QString name, QJSValue prop) override;
|
||||
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
|
||||
|
||||
virtual void blend(QJSValue jsValue) override;
|
||||
virtual void blend(QJsonValue jsValue) override;
|
||||
|
||||
protected:
|
||||
QList<DoricViewNode *> mChildNodes;
|
||||
@ -18,7 +18,7 @@ protected:
|
||||
|
||||
void configChildNode();
|
||||
|
||||
virtual void blendSubNode(QJSValue subProperties) override;
|
||||
virtual void blendSubNode(QJsonValue subProperties) override;
|
||||
};
|
||||
|
||||
#endif // DORICGROUPNODE_H
|
||||
|
@ -15,7 +15,7 @@ QQuickItem *DoricHLayoutNode::build() {
|
||||
return item;
|
||||
}
|
||||
|
||||
void DoricHLayoutNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
void DoricHLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||
if (name == "space") {
|
||||
view->childItems().at(1)->setProperty("spacing", prop.toInt());
|
||||
} else if (name == "gravity") {
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
|
||||
QQuickItem *build() override;
|
||||
|
||||
virtual void blend(QQuickItem *view, QString name, QJSValue prop) override;
|
||||
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
|
||||
};
|
||||
|
||||
#endif // DORICHLAYOUTNODE_H
|
||||
|
@ -15,12 +15,12 @@ QQuickItem *DoricStackNode::build() {
|
||||
return item;
|
||||
}
|
||||
|
||||
void DoricStackNode::blendLayoutConfig(QJSValue jsValue) {
|
||||
void DoricStackNode::blendLayoutConfig(QJsonValue jsValue) {
|
||||
DoricViewNode::blendLayoutConfig(jsValue);
|
||||
QJSValue maxWidth = jsValue.property("maxWidth");
|
||||
if (maxWidth.isNumber()) {
|
||||
QJsonValue maxWidth = jsValue["maxWidth"];
|
||||
if (maxWidth.isDouble()) {
|
||||
}
|
||||
QJSValue maxHeight = jsValue.property("maxHeight");
|
||||
if (maxHeight.isNumber()) {
|
||||
QJsonValue maxHeight = jsValue["maxHeight"];
|
||||
if (maxHeight.isDouble()) {
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
|
||||
QQuickItem *build() override;
|
||||
|
||||
void blendLayoutConfig(QJSValue jsValue) override;
|
||||
void blendLayoutConfig(QJsonValue jsValue) override;
|
||||
};
|
||||
|
||||
#endif // DORICSTACKNODE_H
|
||||
|
@ -2,12 +2,13 @@
|
||||
|
||||
#include "DoricSuperNode.h"
|
||||
|
||||
void DoricSuperNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
void DoricSuperNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||
if (name == "subviews") {
|
||||
if (prop.isArray()) {
|
||||
const int length = prop.property("length").toInt();
|
||||
QJsonArray array = prop.toArray();
|
||||
const int length = array.size();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
QJSValue subNode = prop.property(i);
|
||||
QJsonValue subNode = array.at(i);
|
||||
mixinSubNode(subNode);
|
||||
blendSubNode(subNode);
|
||||
}
|
||||
@ -17,8 +18,8 @@ void DoricSuperNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
}
|
||||
}
|
||||
|
||||
void DoricSuperNode::mixinSubNode(QJSValue subNode) {
|
||||
QString id = subNode.property("id").toString();
|
||||
void DoricSuperNode::mixinSubNode(QJsonValue subNode) {
|
||||
QString id = subNode["id"].toString();
|
||||
QList<QString> keys = subNodes.keys();
|
||||
if (!keys.contains(id)) {
|
||||
subNodes.insert(id, subNode);
|
||||
@ -27,30 +28,36 @@ void DoricSuperNode::mixinSubNode(QJSValue subNode) {
|
||||
}
|
||||
}
|
||||
|
||||
void DoricSuperNode::mixin(QJSValue src, QJSValue target) {
|
||||
QJSValue srcProps = src.property("props");
|
||||
QJSValue targetProps = target.property("props");
|
||||
QJSValueIterator it(srcProps);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
void DoricSuperNode::mixin(QJsonValue src, QJsonValue target) {
|
||||
QJsonValue srcProps = src["props"];
|
||||
QJsonValue targetProps = target["props"];
|
||||
|
||||
if (it.name() == "subviews" && it.value().isArray()) {
|
||||
foreach (const QString &key, srcProps.toObject().keys()) {
|
||||
QJsonValue value = srcProps[key];
|
||||
if (key == "subviews" && value.isArray()) {
|
||||
|
||||
} else {
|
||||
targetProps.setProperty(it.name(), it.value());
|
||||
targetProps.toObject().insert(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QJSValue DoricSuperNode::getSubModel(QString id) {
|
||||
QJsonValue DoricSuperNode::getSubModel(QString id) {
|
||||
if (subNodes.keys().contains(id)) {
|
||||
return subNodes.value(id);
|
||||
} else {
|
||||
return QJSValue::UndefinedValue;
|
||||
return QJsonValue::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
void DoricSuperNode::blendSubLayoutConfig(DoricViewNode *viewNode,
|
||||
QJSValue jsValue) {
|
||||
QJsonValue jsValue) {
|
||||
viewNode->blendLayoutConfig(jsValue);
|
||||
}
|
||||
|
||||
QJsonValue DoricSuperNode::generateDefaultLayoutConfig() {
|
||||
QJsonObject layoutConfig;
|
||||
layoutConfig.insert("widthSpec", 0);
|
||||
layoutConfig.insert("heightSpec", 0);
|
||||
return layoutConfig;
|
||||
}
|
||||
|
@ -1,30 +1,34 @@
|
||||
#ifndef DORICSUPERNODE_H
|
||||
#define DORICSUPERNODE_H
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "DoricViewNode.h"
|
||||
|
||||
class DoricSuperNode : public DoricViewNode {
|
||||
private:
|
||||
QMap<QString, QJSValue> subNodes;
|
||||
QMap<QString, QJsonValue> subNodes;
|
||||
|
||||
protected:
|
||||
virtual void blend(QQuickItem *view, QString name, QJSValue prop) override;
|
||||
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
|
||||
|
||||
virtual void blendSubNode(QJSValue subProperties) = 0;
|
||||
virtual void blendSubNode(QJsonValue subProperties) = 0;
|
||||
|
||||
public:
|
||||
using DoricViewNode::DoricViewNode;
|
||||
|
||||
bool mReusable = false;
|
||||
|
||||
QJSValue getSubModel(QString id);
|
||||
QJsonValue getSubModel(QString id);
|
||||
|
||||
void blendSubLayoutConfig(DoricViewNode *viewNode, QJSValue jsValue);
|
||||
void blendSubLayoutConfig(DoricViewNode *viewNode, QJsonValue jsValue);
|
||||
|
||||
QJsonValue generateDefaultLayoutConfig();
|
||||
|
||||
private:
|
||||
void mixinSubNode(QJSValue subNode);
|
||||
void mixinSubNode(QJsonValue subNode);
|
||||
|
||||
void mixin(QJSValue src, QJSValue target);
|
||||
void mixin(QJsonValue src, QJsonValue target);
|
||||
};
|
||||
|
||||
#endif // DORICSUPERNODE_H
|
||||
|
@ -16,15 +16,15 @@ QQuickItem *DoricTextNode::build() {
|
||||
return item;
|
||||
}
|
||||
|
||||
void DoricTextNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
void DoricTextNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||
if (name == "text") {
|
||||
view->childItems().at(0)->setProperty("text", prop.toString());
|
||||
} else if (name == "textColor") {
|
||||
QString color = DoricUtils::doricColor(prop.toNumber()).name();
|
||||
QString color = DoricUtils::doricColor(prop.toInt()).name();
|
||||
view->childItems().at(0)->setProperty("color", color);
|
||||
} else if (name == "textSize") {
|
||||
QFont font = view->childItems().at(0)->property("font").value<QFont>();
|
||||
font.setPixelSize(prop.toNumber());
|
||||
font.setPixelSize(prop.toInt());
|
||||
view->childItems().at(0)->setProperty("font", QVariant(font));
|
||||
} else if (name == "textAlignment") {
|
||||
view->childItems().at(0)->setProperty("textAlignment", prop.toInt());
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
|
||||
QQuickItem *build() override;
|
||||
|
||||
virtual void blend(QQuickItem *view, QString name, QJSValue prop) override;
|
||||
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
|
||||
};
|
||||
|
||||
#endif // DORICTEXTNODE_H
|
||||
|
@ -15,7 +15,7 @@ QQuickItem *DoricVLayoutNode::build() {
|
||||
return item;
|
||||
}
|
||||
|
||||
void DoricVLayoutNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
void DoricVLayoutNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||
if (name == "space") {
|
||||
view->childItems().at(1)->setProperty("spacing", prop.toInt());
|
||||
} else if (name == "gravity") {
|
||||
|
@ -9,7 +9,7 @@ public:
|
||||
|
||||
QQuickItem *build() override;
|
||||
|
||||
virtual void blend(QQuickItem *view, QString name, QJSValue prop) override;
|
||||
virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override;
|
||||
};
|
||||
|
||||
#endif // DORICVLAYOUTNODE_H
|
||||
|
@ -1,18 +1,16 @@
|
||||
#include <QJSValueIterator>
|
||||
|
||||
#include "DoricViewNode.h"
|
||||
#include "../utils/DoricConstant.h"
|
||||
#include "../utils/DoricUtils.h"
|
||||
#include "DoricSuperNode.h"
|
||||
#include "DoricViewNode.h"
|
||||
|
||||
void DoricViewNode::blendLayoutConfig(QJSValue jsObject) {
|
||||
void DoricViewNode::blendLayoutConfig(QJsonValue jsObject) {
|
||||
this->mLayoutConfig = jsObject;
|
||||
|
||||
QJSValue margin = jsObject.property("margin");
|
||||
QJSValue widthSpec = jsObject.property("widthSpec");
|
||||
QJSValue heightSpec = jsObject.property("heightSpec");
|
||||
QJsonValue margin = jsObject["margin"];
|
||||
QJsonValue widthSpec = jsObject["widthSpec"];
|
||||
QJsonValue heightSpec = jsObject["heightSpec"];
|
||||
|
||||
if (widthSpec.isNumber()) {
|
||||
if (widthSpec.isDouble()) {
|
||||
switch (widthSpec.toInt()) {
|
||||
case 0:
|
||||
mView->setProperty("widthSpec", 0);
|
||||
@ -26,7 +24,7 @@ void DoricViewNode::blendLayoutConfig(QJSValue jsObject) {
|
||||
}
|
||||
}
|
||||
|
||||
if (heightSpec.isNumber()) {
|
||||
if (heightSpec.isDouble()) {
|
||||
switch (heightSpec.toInt()) {
|
||||
case 0:
|
||||
mView->setProperty("heightSpec", 0);
|
||||
@ -41,7 +39,7 @@ void DoricViewNode::blendLayoutConfig(QJSValue jsObject) {
|
||||
}
|
||||
}
|
||||
|
||||
void DoricViewNode::setLayoutConfig(QJSValue layoutConfig) {
|
||||
void DoricViewNode::setLayoutConfig(QJsonValue layoutConfig) {
|
||||
if (mSuperNode != nullptr) {
|
||||
mSuperNode->blendSubLayoutConfig(this, layoutConfig);
|
||||
} else {
|
||||
@ -55,6 +53,7 @@ void DoricViewNode::init(DoricSuperNode *superNode) {
|
||||
thiz->mReusable = superNode->mReusable;
|
||||
}
|
||||
this->mSuperNode = superNode;
|
||||
this->mLayoutConfig = superNode->generateDefaultLayoutConfig();
|
||||
this->mView = build();
|
||||
}
|
||||
|
||||
@ -66,49 +65,49 @@ QString DoricViewNode::getType() { return mType; }
|
||||
|
||||
QQuickItem *DoricViewNode::getNodeView() { return mView; }
|
||||
|
||||
void DoricViewNode::blend(QJSValue jsValue) {
|
||||
QJSValue value = jsValue.property("layoutConfig");
|
||||
void DoricViewNode::blend(QJsonValue jsValue) {
|
||||
QJsonValue value = jsValue["layoutConfig"];
|
||||
if (value.isObject()) {
|
||||
setLayoutConfig(value);
|
||||
}
|
||||
QJSValueIterator it(jsValue);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
blend(mView, it.name(), it.value());
|
||||
|
||||
foreach (const QString &key, jsValue.toObject().keys()) {
|
||||
QJsonValue value = jsValue[key];
|
||||
blend(mView, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
void DoricViewNode::blend(QQuickItem *view, QString name, QJSValue prop) {
|
||||
void DoricViewNode::blend(QQuickItem *view, QString name, QJsonValue prop) {
|
||||
if (name == "width") {
|
||||
if (!prop.isNumber()) {
|
||||
if (!prop.isDouble()) {
|
||||
return;
|
||||
}
|
||||
if (this->mLayoutConfig.isUndefined()) {
|
||||
view->setWidth(prop.toInt());
|
||||
} else {
|
||||
QJSValue widthSpec = this->mLayoutConfig.property("widthSpec");
|
||||
if (widthSpec.isNumber()) {
|
||||
QJsonValue widthSpec = this->mLayoutConfig["widthSpec"];
|
||||
if (widthSpec.isDouble()) {
|
||||
if (widthSpec.toInt() == 0) {
|
||||
view->setWidth(prop.toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (name == "height") {
|
||||
if (!prop.isNumber()) {
|
||||
if (!prop.isDouble()) {
|
||||
return;
|
||||
}
|
||||
if (this->mLayoutConfig.isUndefined()) {
|
||||
view->setHeight(prop.toInt());
|
||||
} else {
|
||||
QJSValue heightSpec = this->mLayoutConfig.property("heightSpec");
|
||||
if (heightSpec.isNumber()) {
|
||||
QJsonValue heightSpec = this->mLayoutConfig["heightSpec"];
|
||||
if (heightSpec.isDouble()) {
|
||||
if (heightSpec.toInt() == 0) {
|
||||
view->setHeight(prop.toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (name == "backgroundColor") {
|
||||
QString color = DoricUtils::doricColor(prop.toNumber()).name();
|
||||
QString color = DoricUtils::doricColor(prop.toInt()).name();
|
||||
view->setProperty("color", color);
|
||||
} else if (name == "x") {
|
||||
view->setProperty("x", prop.toInt());
|
||||
|
@ -2,6 +2,8 @@
|
||||
#define DORICVIEWNODE_H
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QJsonValue>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "../utils/DoricContextHolder.h"
|
||||
|
||||
@ -16,12 +18,12 @@ protected:
|
||||
|
||||
virtual QQuickItem *build() = 0;
|
||||
|
||||
void setLayoutConfig(QJSValue layoutConfig);
|
||||
void setLayoutConfig(QJsonValue layoutConfig);
|
||||
|
||||
private:
|
||||
QString mId;
|
||||
|
||||
QJSValue mLayoutConfig;
|
||||
QJsonValue mLayoutConfig;
|
||||
|
||||
QList<QString> getIdList();
|
||||
|
||||
@ -57,11 +59,11 @@ public:
|
||||
|
||||
QQuickItem *getNodeView();
|
||||
|
||||
virtual void blend(QJSValue jsValue);
|
||||
virtual void blend(QJsonValue jsValue);
|
||||
|
||||
virtual void blend(QQuickItem *view, QString name, QJSValue prop);
|
||||
virtual void blend(QQuickItem *view, QString name, QJsonValue prop);
|
||||
|
||||
virtual void blendLayoutConfig(QJSValue jsObject);
|
||||
virtual void blendLayoutConfig(QJsonValue jsObject);
|
||||
|
||||
void onClick();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "DoricConstant.h"
|
||||
|
||||
const QString DoricConstant::DORIC_BUNDLE_SANDBOX = "doric-sandbox.es5.js";
|
||||
const QString DoricConstant::DORIC_BUNDLE_LIB = "doric-lib.es5.js";
|
||||
const QString DoricConstant::DORIC_BUNDLE_SANDBOX = "doric-sandbox.js";
|
||||
const QString DoricConstant::DORIC_BUNDLE_LIB = "doric-lib.js";
|
||||
const QString DoricConstant::DORIC_MODULE_LIB = "doric";
|
||||
|
||||
const QString DoricConstant::INJECT_ENVIRONMENT = "Environment";
|
||||
|
Reference in New Issue
Block a user