void TextOverlay::setProperties(const QScriptValue& properties) { Overlay2D::setProperties(properties); _qmlElement->setX(_bounds.left()); _qmlElement->setY(_bounds.top()); _qmlElement->setWidth(_bounds.width()); _qmlElement->setHeight(_bounds.height()); _qmlElement->settextColor(toQmlColor(vec4(toGlm(_color), _alpha))); QScriptValue font = properties.property("font"); if (font.isObject()) { if (font.property("size").isValid()) { setFontSize(font.property("size").toInt32()); } QFont font(_qmlElement->fontFamily()); font.setPixelSize(_qmlElement->fontSize()); QFontMetrics fm(font); _qmlElement->setlineHeight(fm.lineSpacing() * 1.2); } QScriptValue text = properties.property("text"); if (text.isValid()) { setText(text.toVariant().toString()); } QScriptValue backgroundColor = properties.property("backgroundColor"); if (backgroundColor.isValid()) { QScriptValue red = backgroundColor.property("red"); QScriptValue green = backgroundColor.property("green"); QScriptValue blue = backgroundColor.property("blue"); if (red.isValid() && green.isValid() && blue.isValid()) { _backgroundColor.red = red.toVariant().toInt(); _backgroundColor.green = green.toVariant().toInt(); _backgroundColor.blue = blue.toVariant().toInt(); } } if (properties.property("backgroundAlpha").isValid()) { _backgroundAlpha = properties.property("backgroundAlpha").toVariant().toFloat(); } _qmlElement->setbackgroundColor(toQmlColor(vec4(toGlm(_backgroundColor), _backgroundAlpha))); if (properties.property("leftMargin").isValid()) { setLeftMargin(properties.property("leftMargin").toVariant().toInt()); } if (properties.property("topMargin").isValid()) { setTopMargin(properties.property("topMargin").toVariant().toInt()); } }