From ec9dfe9e58893d3d53f61cb36f1be767f6eb069d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Tue, 25 May 2021 12:42:14 +0800 Subject: [PATCH] handle rich text --- doric-Qt/example/doric/resources/text.qml | 2 ++ .../example/doric/shader/DoricTextNode.cpp | 26 +++++++++++++++++++ doric-Qt/example/doric/shader/DoricTextNode.h | 2 ++ 3 files changed, 30 insertions(+) diff --git a/doric-Qt/example/doric/resources/text.qml b/doric-Qt/example/doric/resources/text.qml index 6006b1ac..8aaa4410 100644 --- a/doric-Qt/example/doric/resources/text.qml +++ b/doric-Qt/example/doric/resources/text.qml @@ -123,4 +123,6 @@ TextArea { color: shadowColor transparentBorder: true } + + textFormat: TextEdit.AutoText } diff --git a/doric-Qt/example/doric/shader/DoricTextNode.cpp b/doric-Qt/example/doric/shader/DoricTextNode.cpp index 6bd6e1a0..7caec8ba 100644 --- a/doric-Qt/example/doric/shader/DoricTextNode.cpp +++ b/doric-Qt/example/doric/shader/DoricTextNode.cpp @@ -18,6 +18,22 @@ QQuickItem *DoricTextNode::build() { return item; } +void DoricTextNode::blendLayoutConfig(QJsonValue jsObject) { + DoricViewNode::blendLayoutConfig(jsObject); + + DoricLayouts *layout = + (DoricLayouts *)(mView->property("doricLayout").toULongLong()); + + QJsonValue maxWidth = jsObject["maxWidth"]; + if (maxWidth.isDouble()) { + layout->setMaxWidth(maxWidth.toDouble()); + } + QJsonValue maxHeight = jsObject["maxHeight"]; + if (maxHeight.isDouble()) { + layout->setMaxHeight(maxHeight.toDouble()); + } +} + void DoricTextNode::blend(QQuickItem *view, QString name, QJsonValue prop) { if (name == "text") { view->setProperty("text", prop.toString()); @@ -39,6 +55,16 @@ void DoricTextNode::blend(QQuickItem *view, QString name, QJsonValue prop) { view->setProperty("shadowOffsetX", prop["offsetX"].toDouble()); view->setProperty("shadowOffsetY", prop["offsetY"].toDouble()); view->setProperty("shadowOpacity", prop["opacity"].toDouble()); + } else if (name == "htmlText") { + view->setProperty("text", prop.toString()); + } else if (name == "maxWidth") { + DoricLayouts *layout = + (DoricLayouts *)(mView->property("doricLayout").toULongLong()); + layout->setMaxWidth(prop.toDouble()); + } else if (name == "maxHeight") { + DoricLayouts *layout = + (DoricLayouts *)(mView->property("doricLayout").toULongLong()); + layout->setMaxHeight(prop.toDouble()); } else { DoricViewNode::blend(view, name, prop); } diff --git a/doric-Qt/example/doric/shader/DoricTextNode.h b/doric-Qt/example/doric/shader/DoricTextNode.h index 68bfdb1a..d3cabe33 100644 --- a/doric-Qt/example/doric/shader/DoricTextNode.h +++ b/doric-Qt/example/doric/shader/DoricTextNode.h @@ -11,6 +11,8 @@ public: QQuickItem *build() override; + virtual void blendLayoutConfig(QJsonValue jsObject) override; + virtual void blend(QQuickItem *view, QString name, QJsonValue prop) override; };