#include "kdenlivetitle_wrapper.h"
-#include <QtGui/QImage>
-#include <QtGui/QPainter>
-#include <QtCore/QDebug>
-#include <QtGui/QApplication>
-#include <QtCore/QMutex>
-#include <QtGui/QGraphicsScene>
-#include <QtGui/QGraphicsTextItem>
-#include <QtSvg/QGraphicsSvgItem>
-#include <QtSvg/QSvgRenderer>
-#include <QtGui/QTextCursor>
-#include <QtGui/QTextDocument>
-#include <QtGui/QStyleOptionGraphicsItem>
-
-#include <QtCore/QString>
-
-#include <QtXml/QDomElement>
-#include <QtCore/QRectF>
-#include <QtGui/QColor>
-#include <QtGui/QWidget>
+#include <QImage>
+#include <QPainter>
+#include <QDebug>
+#include <QApplication>
+#include <QMutex>
+#include <QGraphicsScene>
+#include <QGraphicsTextItem>
+#include <QGraphicsSvgItem>
+#include <QSvgRenderer>
+#include <QTextCursor>
+#include <QTextDocument>
+#include <QStyleOptionGraphicsItem>
+
+#include <QString>
+
+#include <QDomElement>
+#include <QRectF>
+#include <QColor>
+#include <QWidget>
#include <framework/mlt_log.h>
#if QT_VERSION >= 0x040600
-#include <QtGui/QGraphicsEffect>
-#include <QtGui/QGraphicsBlurEffect>
-#include <QtGui/QGraphicsDropShadowEffect>
+#include <QGraphicsEffect>
+#include <QGraphicsBlurEffect>
+#include <QGraphicsDropShadowEffect>
#endif
static QApplication *app = NULL;
+Q_DECLARE_METATYPE(QTextCursor);
class ImageItem: public QGraphicsItem
{
}
QGraphicsTextItem *txt = scene->addText(text, font);
if (txtProperties.namedItem("font-outline").nodeValue().toDouble()>0.0){
- qRegisterMetaType<QTextCursor>( "QTextCursor" );
- QTextCursor cursor(txt->document());
+ QTextDocument *doc = txt->document();
+ // Make sure some that the text item does not request refresh by itself
+ doc->blockSignals(true);
+ QTextCursor cursor(doc);
cursor.select(QTextCursor::Document);
QTextCharFormat format;
format.setTextOutline(
mlt_properties_set_int( producer_props, "_animated", 1 );
QStringList effetData = QStringList() << "typewriter" << text << txtProperties.namedItem( "typewriter" ).nodeValue();
txt->setData(0, effetData);
+ if ( !txtProperties.namedItem( "textwidth" ).isNull() )
+ txt->setData( 1, txtProperties.namedItem( "textwidth" ).nodeValue() );
}
if ( txtProperties.namedItem( "alignment" ).isNull() == false )
if (base64.isEmpty()){
img.load(url);
}else{
- img.loadFromData(QByteArray::fromBase64(base64.toAscii()));
+ img.loadFromData(QByteArray::fromBase64(base64.toLatin1()));
}
ImageItem *rec = new ImageItem(img);
scene->addItem( rec );
rec = new QGraphicsSvgItem(url);
}else{
rec = new QGraphicsSvgItem();
- QSvgRenderer *renderer= new QSvgRenderer(QByteArray::fromBase64(base64.toAscii()), rec );
+ QSvgRenderer *renderer= new QSvgRenderer(QByteArray::fromBase64(base64.toLatin1()), rec );
rec->setSharedRenderer(renderer);
}
if (rec){
const char *localename = mlt_properties_get_lcnumeric( MLT_SERVICE_PROPERTIES( MLT_PRODUCER_SERVICE( producer ) ) );
QLocale::setDefault( QLocale( localename ) );
}
+ qRegisterMetaType<QTextCursor>( "QTextCursor" );
}
scene = new QGraphicsScene();
scene->setItemIndexMethod( QGraphicsScene::NoIndex );
// the keystroke delay and a start offset, both in frames
QStringList values = params.at( 2 ).split( ";" );
int interval = qMax( 0, ( ( int ) position - values.at( 1 ).toInt()) / values.at( 0 ).toInt() );
- qRegisterMetaType<QTextCursor>( "QTextCursor" );
- QTextCursor cursor = titem->textCursor();
+ QTextCursor cursor = titem->textCursor();
cursor.movePosition(QTextCursor::EndOfBlock);
// get the font format
QTextCharFormat format = cursor.charFormat();
cursor.select(QTextCursor::Document);
QString txt = params.at( 1 ).left( interval );
- // If the string to insert is empty, insert a space so that we don't loose
+ // If the string to insert is empty, insert a space / linebreak so that we don't loose
// formatting infos for the next iterations
- cursor.insertText(txt.isEmpty() ? " " : txt, format);
+ int lines = params.at( 1 ).count( '\n' );
+ QString empty = " ";
+ for (int i = 0; i < lines; i++)
+ empty.append( "\n " );
+ cursor.insertText( txt.isEmpty() ? empty : txt, format );
+ if ( !titem->data( 1 ).isNull() )
+ titem->setTextWidth( titem->data( 1 ).toDouble() );
}
}
}