#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){
- 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){
{
mlt_log_panic( MLT_PRODUCER_SERVICE( producer ), "Error, cannot render titles without an X11 environment.\nPlease either run melt from an X session or use a fake X server like xvfb:\nxvfb-run -a melt (...)\n" );
pthread_mutex_unlock( &self->mutex );
- exit(1);
return;
}
#endif
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 );
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() );
}
}
}
scene->render( &p1, source, end, Qt::IgnoreAspectRatio );
}
else {
- double percentage = position / anim_out;
+ double percentage = 0;
+ if ( position && anim_out )
+ percentage = position / anim_out;
QPointF topleft = start.topLeft() + ( end.topLeft() - start.topLeft() ) * percentage;
QPointF bottomRight = start.bottomRight() + ( end.bottomRight() - start.bottomRight() ) * percentage;
const QRectF r1( topleft, bottomRight );