add text color & text size

This commit is contained in:
王劲鹏 2021-03-16 16:01:38 +08:00 committed by osborn
parent ca1129d31e
commit c51b99a351
2 changed files with 10 additions and 2 deletions

View File

@ -23,10 +23,10 @@ Rectangle {
this.childrenRectWidth = childrenRect.width
this.childrenRectHeight = childrenRect.height
if (this.width === 0) {
if (this.width < this.childrenRectWidth) {
this.width = this.childrenRectWidth
}
if (this.height === 0) {
if (this.height < this.childrenRectHeight) {
this.height = this.childrenRectHeight
}
}

View File

@ -1,4 +1,5 @@
#include "DoricTextNode.h"
#include "../utils/DoricUtils.h"
QQuickItem *DoricTextNode::build() {
QQmlComponent component(getContext()->getQmlEngine());
@ -17,6 +18,13 @@ QQuickItem *DoricTextNode::build() {
void DoricTextNode::blend(QQuickItem *view, QString name, QJSValue prop) {
if (name == "text") {
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 {
DoricViewNode::blend(view, name, prop);
}