add text color & text size
This commit is contained in:
		| @@ -23,10 +23,10 @@ Rectangle { | |||||||
|         this.childrenRectWidth = childrenRect.width |         this.childrenRectWidth = childrenRect.width | ||||||
|         this.childrenRectHeight = childrenRect.height |         this.childrenRectHeight = childrenRect.height | ||||||
|  |  | ||||||
|         if (this.width === 0) { |         if (this.width < this.childrenRectWidth) { | ||||||
|             this.width = this.childrenRectWidth |             this.width = this.childrenRectWidth | ||||||
|         } |         } | ||||||
|         if (this.height === 0) { |         if (this.height < this.childrenRectHeight) { | ||||||
|             this.height = this.childrenRectHeight |             this.height = this.childrenRectHeight | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| #include "DoricTextNode.h" | #include "DoricTextNode.h" | ||||||
|  | #include "../utils/DoricUtils.h" | ||||||
|  |  | ||||||
| QQuickItem *DoricTextNode::build() { | QQuickItem *DoricTextNode::build() { | ||||||
|   QQmlComponent component(getContext()->getQmlEngine()); |   QQmlComponent component(getContext()->getQmlEngine()); | ||||||
| @@ -17,6 +18,13 @@ QQuickItem *DoricTextNode::build() { | |||||||
| void DoricTextNode::blend(QQuickItem *view, QString name, QJSValue prop) { | void DoricTextNode::blend(QQuickItem *view, QString name, QJSValue prop) { | ||||||
|   if (name == "text") { |   if (name == "text") { | ||||||
|     view->childItems().at(0)->setProperty("text", prop.toString()); |     view->childItems().at(0)->setProperty("text", prop.toString()); | ||||||
|  |   } else if (name == "textColor") { | ||||||
|  |     QString color = DoricUtils::doricColor(prop.toNumber()).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()); | ||||||
|  |     view->childItems().at(0)->setProperty("font", QVariant(font)); | ||||||
|   } else { |   } else { | ||||||
|     DoricViewNode::blend(view, name, prop); |     DoricViewNode::blend(view, name, prop); | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user