]> git.sesse.net Git - mlt/blobdiff - src/modules/qimage/kdenlivetitle_wrapper.cpp
Add support for Qt 5, drop support for Qt 3 and KDE 3.
[mlt] / src / modules / qimage / kdenlivetitle_wrapper.cpp
index d52b35ebe9681316782ac1c27737926a71c1b880..2d5bc4d6bf0df243cebfbc52348a552213771f4a 100755 (executable)
 
 #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
 {
@@ -197,8 +198,10 @@ void loadFromXml( mlt_producer producer, QGraphicsScene *scene, const char *temp
                                }
                                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(
@@ -257,7 +260,7 @@ void loadFromXml( mlt_producer producer, QGraphicsScene *scene, const char *temp
                                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 );
@@ -272,7 +275,7 @@ void loadFromXml( mlt_producer producer, QGraphicsScene *scene, const char *temp
                                        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){
@@ -401,6 +404,7 @@ void drawKdenliveTitle( producer_ktitle self, mlt_frame frame, int width, int he
                                        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 );
@@ -442,7 +446,6 @@ void drawKdenliveTitle( producer_ktitle self, mlt_frame frame, int width, int he
                                    // 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();
                                    cursor.movePosition(QTextCursor::EndOfBlock);
                                    // get the font format
@@ -457,7 +460,7 @@ void drawKdenliveTitle( producer_ktitle self, mlt_frame frame, int width, int he
                                            empty.append( "\n " );
                                    cursor.insertText( txt.isEmpty() ? empty : txt, format );
                                    if ( !titem->data( 1 ).isNull() )
-                                         titem->setTextWidth( titem->data( 1 ).toInt() );
+                                         titem->setTextWidth( titem->data( 1 ).toDouble() );
                            }
                    }
                }