- if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsRectItem") {
- QString rect = items.item(i).namedItem("content").attributes().namedItem("rect").nodeValue();
- QString br_str = items.item(i).namedItem("content").attributes().namedItem("brushcolor").nodeValue();
- QString pen_str = items.item(i).namedItem("content").attributes().namedItem("pencolor").nodeValue();
- double penwidth = items.item(i).namedItem("content").attributes().namedItem("penwidth").nodeValue().toDouble();
- QGraphicsRectItem *rec = scene->addRect(stringToRect(rect), QPen(QBrush(stringToColor(pen_str)), penwidth), QBrush(stringToColor(br_str)));
- gitem = rec;
- } else
- if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsPixmapItem") {
- QString url = items.item(i).namedItem("content").attributes().namedItem("url").nodeValue();
- QPixmap pix(url);
- QGraphicsPixmapItem *rec = scene->addPixmap(pix);
- rec->setData(Qt::UserRole, url);
- gitem = rec;
- } else
- if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsSvgItem") {
- QString url = items.item(i).namedItem("content").attributes().namedItem("url").nodeValue();
- QGraphicsSvgItem *rec = new QGraphicsSvgItem(url);
- scene->addItem(rec);
- rec->setData(Qt::UserRole, url);
- gitem = rec;
- }
- //pos and transform
- if (gitem) {
- QPointF p(items.item(i).namedItem("position").attributes().namedItem("x").nodeValue().toDouble(),
- items.item(i).namedItem("position").attributes().namedItem("y").nodeValue().toDouble());
- gitem->setPos(p);
- gitem->setTransform(stringToTransform(items.item(i).namedItem("position").firstChild().firstChild().nodeValue()));
- int zValue = items.item(i).attributes().namedItem("z-index").nodeValue().toInt();
- if (zValue > maxZValue) maxZValue = zValue;
- gitem->setZValue(zValue);
- gitem->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
- }
- if (items.item(i).nodeName() == "background") {
- kDebug() << items.item(i).attributes().namedItem("color").nodeValue();
- QColor color = QColor(stringToColor(items.item(i).attributes().namedItem("color").nodeValue()));
- //color.setAlpha(items.item(i).attributes().namedItem("alpha").nodeValue().toInt());
- QList<QGraphicsItem *> items = scene->items();
- for (int i = 0; i < items.size(); i++) {
- if (items.at(i)->zValue() == -1100) {
- ((QGraphicsRectItem *)items.at(i))->setBrush(QBrush(color));
- break;
+ font.setPixelSize(txtProperties.namedItem("font-pixel-size").nodeValue().toInt());
+ QColor col(stringToColor(txtProperties.namedItem("font-color").nodeValue()));
+ QGraphicsTextItem *txt = m_scene->addText(items.item(i).namedItem("content").firstChild().nodeValue(), font);
+ QTextCursor cursor(txt->document());
+ cursor.select(QTextCursor::Document);
+ QTextCharFormat format;
+ if (txtProperties.namedItem("font-outline").nodeValue().toDouble() > 0.0) {
+ txt->setData(101, txtProperties.namedItem("font-outline").nodeValue().toDouble());
+ txt->setData(102, stringToColor(txtProperties.namedItem("font-outline-color").nodeValue()));
+ format.setTextOutline(
+ QPen(QColor(stringToColor(txtProperties.namedItem("font-outline-color").nodeValue())),
+ txtProperties.namedItem("font-outline").nodeValue().toDouble(),
+ Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)
+ );
+
+ }
+ format.setForeground(QBrush(col));
+ cursor.mergeCharFormat(format);
+ txt->setTextInteractionFlags(Qt::NoTextInteraction);
+ if (txtProperties.namedItem("alignment").isNull() == false) {
+ txt->setTextWidth(txt->boundingRect().width());
+ QTextCursor cur = txt->textCursor();
+ QTextBlockFormat format = cur.blockFormat();
+ format.setAlignment((Qt::Alignment) txtProperties.namedItem("alignment").nodeValue().toInt());
+ cur.select(QTextCursor::Document);
+ cur.setBlockFormat(format);
+ txt->setTextCursor(cur);
+ cur.clearSelection();
+ txt->setTextCursor(cur);
+ }
+
+ if (!txtProperties.namedItem("kdenlive-axis-x-inverted").isNull()) {
+ txt->setData(OriginXLeft, txtProperties.namedItem("kdenlive-axis-x-inverted").nodeValue().toInt());
+ }
+ if (!txtProperties.namedItem("kdenlive-axis-y-inverted").isNull()) {
+ txt->setData(OriginYTop, txtProperties.namedItem("kdenlive-axis-y-inverted").nodeValue().toInt());
+ }
+
+ // Effects
+ if (!txtProperties.namedItem("typewriter").isNull()) {
+ QStringList effData = QStringList() << "typewriter" << txtProperties.namedItem("typewriter").nodeValue();
+ txt->setData(100, effData);
+ }
+
+ gitem = txt;
+ } else if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsRectItem") {
+ QString rect = items.item(i).namedItem("content").attributes().namedItem("rect").nodeValue();
+ QString br_str = items.item(i).namedItem("content").attributes().namedItem("brushcolor").nodeValue();
+ QString pen_str = items.item(i).namedItem("content").attributes().namedItem("pencolor").nodeValue();
+ double penwidth = items.item(i).namedItem("content").attributes().namedItem("penwidth").nodeValue().toDouble();
+ QGraphicsRectItem *rec = m_scene->addRect(stringToRect(rect), QPen(QBrush(stringToColor(pen_str)), penwidth, Qt::SolidLine, Qt::SquareCap, Qt::RoundJoin), QBrush(stringToColor(br_str)));
+ gitem = rec;
+ } else if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsPixmapItem") {
+ QString url = items.item(i).namedItem("content").attributes().namedItem("url").nodeValue();
+ QString base64 = items.item(i).namedItem("content").attributes().namedItem("base64").nodeValue();
+ QPixmap pix;
+ if (base64.isEmpty()) {
+ pix.load(url);
+ } else {
+ pix.loadFromData(QByteArray::fromBase64(base64.toAscii()));
+ }
+ QGraphicsPixmapItem *rec = m_scene->addPixmap(pix);
+ rec->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
+ rec->setData(Qt::UserRole, url);
+ if (!base64.isEmpty()) {
+ rec->setData(Qt::UserRole + 1, base64);
+ }
+ gitem = rec;
+ } else if (items.item(i).attributes().namedItem("type").nodeValue() == "QGraphicsSvgItem") {
+ QString url = items.item(i).namedItem("content").attributes().namedItem("url").nodeValue();
+ QString base64 = items.item(i).namedItem("content").attributes().namedItem("base64").nodeValue();
+ QGraphicsSvgItem *rec = NULL;
+ if (base64.isEmpty()) {
+ rec = new QGraphicsSvgItem(url);
+ } else {
+ rec = new QGraphicsSvgItem();
+ QSvgRenderer *renderer = new QSvgRenderer(QByteArray::fromBase64(base64.toAscii()), rec);
+ rec->setSharedRenderer(renderer);
+ //QString elem=rec->elementId();
+ //QRectF bounds = renderer->boundsOnElement(elem);
+ }
+ if (rec) {
+ m_scene->addItem(rec);
+ rec->setData(Qt::UserRole, url);
+ if (!base64.isEmpty()) {
+ rec->setData(Qt::UserRole + 1, base64);