]> git.sesse.net Git - mlt/commitdiff
Merge branch 'jbm-kdenlivetitle' into kdenlivetitle
authorMarco Gittler <g.marco@freenet.de>
Fri, 24 Jul 2009 09:39:03 +0000 (11:39 +0200)
committerMarco Gittler <g.marco@freenet.de>
Fri, 24 Jul 2009 09:39:03 +0000 (11:39 +0200)
Conflicts:
src/modules/qimage/factory.c
src/modules/qimage/kdenlivetitle_wrapper.cpp
src/modules/qimage/kdenlivetitle_wrapper.h
src/modules/qimage/producer_kdenlivetitle.c

src/modules/qimage/kdenlivetitle_wrapper.cpp
src/modules/qimage/kdenlivetitle_wrapper.h
src/modules/qimage/producer_kdenlivetitle.c
src/modules/qimage/qimage_wrapper.cpp

index 3c9f5a808b2b21124e569a63f0fdbf1acb04115c..dfc27397ea123b2931e3f5f006b1752c55796359 100644 (file)
@@ -40,9 +40,9 @@ extern "C"
        {
                titleclass=new Title( QString( c ) );
        }
-       void refresh_kdenlivetitle( uint8_t* buffer, int width, int height , double position )
+       void refresh_kdenlivetitle( uint8_t* buffer, int width, int height , double position, char *templatexml, char *templatetext )
        {
-               titleclass->drawKdenliveTitle( buffer,width,height,position );
+               titleclass->drawKdenliveTitle( buffer, width, height, position, templatexml, templatetext );
        }
 }
 Title::Title( const QString& filename ):m_filename( filename ),m_scene( NULL )
@@ -53,7 +53,7 @@ Title::Title( const QString& filename ):m_filename( filename ),m_scene( NULL )
        end=new QGraphicsPolygonItem( QPolygonF( QRectF( 0, 0, 300, 300 ) ) );
        ;
 }
-void Title::drawKdenliveTitle( uint8_t * buffer ,int width,int height,double position )
+void Title::drawKdenliveTitle( uint8_t * buffer, int width, int height, double position, char *templatexml, char *templatetext )
 {
        if ( !m_scene )
        {
@@ -64,7 +64,7 @@ void Title::drawKdenliveTitle( uint8_t * buffer ,int width,int height,double pos
                        //if (!app)
                        app=new QApplication( argc,argv );
                m_scene=new QGraphicsScene;
-               loadDocument( m_filename,start,end );
+               loadDocument( m_filename, start, end, QString( templatexml ), QString( templatetext ) );
        }
        //must be extracted from kdenlive title
 
@@ -91,21 +91,28 @@ void Title::drawKdenliveTitle( uint8_t * buffer ,int width,int height,double pos
        }
        delete img;
 }
-int Title::loadDocument( const QString& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv )
+int Title::loadDocument( const QString& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv, const QString templateXml, const QString templateText )
 {
        QDomDocument doc;
        if ( !m_scene )
                return -1;
-
-       QFile file( url );
-       if ( file.open( QIODevice::ReadOnly ) )
+       if ( !templateXml.isEmpty() )
+       {
+               doc.setContent( templateXml );
+       }
+       else
        {
-               doc.setContent( &file, false );
-               file.close();
+               QFile file( url );
+               if ( file.open( QIODevice::ReadOnly ) )
+               {
+                       doc.setContent( &file, false );
+                       file.close();
+               }
        }
-       return loadFromXml( doc, startv, endv );
+       return loadFromXml( doc, startv, endv, templateText );
 }
-int Title::loadFromXml( QDomDocument doc, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv )
+
+int Title::loadFromXml( QDomDocument doc, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv, const QString templateText )
 {
        QDomNodeList titles = doc.elementsByTagName( "kdenlivetitle" );
        int maxZValue = 0;
@@ -136,7 +143,14 @@ int Title::loadFromXml( QDomDocument doc, QGraphicsPolygonItem* startv, QGraphic
                                        else
                                                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 );
+                                       QGraphicsTextItem *txt;
+                                       if ( !templateText.isEmpty() )
+                                       {
+                                               QString text = items.item( i ).namedItem( "content" ).firstChild().nodeValue();
+                                               text = text.replace( "%s", templateText );
+                                               txt = m_scene->addText( text, font );
+                                       }
+                                       else txt = m_scene->addText( items.item( i ).namedItem( "content" ).firstChild().nodeValue(), font );
                                        txt->setDefaultTextColor( col );
                                        txt->setTextInteractionFlags( Qt::NoTextInteraction );
                                        if ( txtProperties.namedItem( "alignment" ).isNull() == false )
index 490047a16e73fa2d4e06de57f608eaa020d40e5a..31943bf2262fa9f352e58118e13b5b1ec6e36e55 100644 (file)
@@ -34,11 +34,11 @@ class Title: public QObject
 
 public:
        Title( const QString & );
-       void drawKdenliveTitle( uint8_t*,int,int,double );
+       void drawKdenliveTitle( uint8_t*, int, int, double, char*, char* );
 private:
        QString m_filename;
-       int  loadFromXml( QDomDocument doc, QGraphicsPolygonItem* /*startv*/, QGraphicsPolygonItem* /*endv*/ );
-       int loadDocument( const QString& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv );
+       int loadDocument( const QString& url, QGraphicsPolygonItem* startv, QGraphicsPolygonItem* endv, const QString templateXml, const QString templateText );
+       int  loadFromXml( QDomDocument doc, QGraphicsPolygonItem* /*startv*/, QGraphicsPolygonItem* /*endv*/, const QString templateText );
        QGraphicsView *view;
        QGraphicsScene *m_scene;
        QGraphicsPolygonItem *start,*end;
index 2b270cf32ac6d241d68398ee94068cbd7a20693f..44821a3b44be61d1b005336af2562e2958e4e600 100644 (file)
@@ -23,7 +23,7 @@
 
 extern void init_qt();
 
-extern void refresh_kdenlivetitle( uint8_t*, int, int, double );
+extern void refresh_kdenlivetitle( uint8_t*, int, int, double, char*, char* );
 
 static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_format *format, int *width, int *height, int writable )
 {
@@ -57,7 +57,7 @@ static int producer_get_image( mlt_frame frame, uint8_t **buffer, mlt_image_form
                mlt_position out = mlt_producer_get_out( producer );
                mlt_position time = mlt_frame_get_position( frame );
                double position = ( double )( time - in ) / ( double )( out - in + 1 );
-               refresh_kdenlivetitle( *buffer, *width, *height, position );
+               refresh_kdenlivetitle( *buffer, *width, *height, position, mlt_properties_get( MLT_PRODUCER_PROPERTIES( producer ), "templatexml" ), mlt_properties_get( MLT_PRODUCER_PROPERTIES( producer ), "templatetext" ) );
                mlt_log_debug( MLT_PRODUCER_SERVICE( producer ), "width:%d height:%d %s\n", *width, *height, mlt_image_format_name( *format ) );
        }
 
index ed52681cc8453ebdcf202f8d680a26c0b47989f7..66ebe425d8b3a5088fc8e2402222f46d1c5589d6 100644 (file)
@@ -73,6 +73,7 @@ void init_qimage()
        if (!instance) {
            instance = new KInstance("qimage_prod");
            KImageIO::registerFormats();
+        //QApplication *app=new QApplication();
        }
 }
 #endif