[vlmc-devel] commit: EffectsEngine: Respecting plugin path reference. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Tue Aug 24 21:33:08 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Tue Aug 24 20:53:18 2010 +0200| [8937d07fdd67f5dfe1bd5b98115697ff4bd608f4] | committer: Hugo Beauzée-Luyssen 

EffectsEngine: Respecting plugin path reference.

Won't work for windows right now.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=8937d07fdd67f5dfe1bd5b98115697ff4bd608f4
---

 src/EffectsEngine/EffectsEngine.cpp |   35 +++++++++++++++++++++++++++++++----
 src/EffectsEngine/EffectsEngine.h   |    4 +++-
 src/Gui/MainWindow.cpp              |   12 ++++++------
 3 files changed, 40 insertions(+), 11 deletions(-)

diff --git a/src/EffectsEngine/EffectsEngine.cpp b/src/EffectsEngine/EffectsEngine.cpp
index 68bdff1..11a0e4f 100644
--- a/src/EffectsEngine/EffectsEngine.cpp
+++ b/src/EffectsEngine/EffectsEngine.cpp
@@ -71,12 +71,17 @@ EffectsEngine::loadEffect( const QString &fileName )
         else
         {
             type = static_cast<Effect::Type>( typeInt );
+            if ( m_effects.contains( name ) == true )
+            {
+                delete e;
+                return false;
+            }
             m_effects[name] = e;
             emit effectAdded( e, name, type );
             return true;
         }
     }
-    if ( e->load() == false )
+    if ( e->load() == false || m_effects.contains( e->name() ) == true )
     {
         delete e;
         return false;
@@ -94,11 +99,14 @@ void
 EffectsEngine::browseDirectory( const QString &path )
 {
     QDir    dir( path );
-    const QStringList& files = dir.entryList( QDir::Files | QDir::NoDotAndDotDot |
+    const QFileInfoList& files = dir.entryInfoList( QDir::Files | QDir::NoDotAndDotDot |
                                               QDir::Readable | QDir::Executable );
-    foreach ( const QString& file, files )
+    foreach ( const QFileInfo& file, files )
     {
-        loadEffect( path + '/' + file );
+        if ( file.isDir() )
+            browseDirectory( file.absoluteFilePath() );
+        else
+            loadEffect( file.absoluteFilePath() );
     }
 }
 
@@ -213,3 +221,22 @@ EffectsEngine::initMixers( const MixerList &mixers, quint32 width, quint32 heigh
         ++it;
     }
 }
+
+void
+EffectsEngine::loadEffects()
+{
+    //FIXME: What should we do for windows ?!
+    //Refer to http://www.piksel.org/frei0r/1.2/spec/group__pluglocations.html
+    const   QString paths[3] = {
+        QString( QDir::homePath() + "/.frei0r-1/lib/" ),
+        QString("/usr/local/lib/frei0r-1/"),
+        QString("/usr/lib/frei0r-1/" )
+    };
+    for ( quint32 i = 0; i < 3; ++i )
+    {
+        if ( QFile::exists( paths[i] ) == true )
+        {
+            browseDirectory( paths[i] );
+        }
+    }
+}
diff --git a/src/EffectsEngine/EffectsEngine.h b/src/EffectsEngine/EffectsEngine.h
index fb78098..923e8e5 100644
--- a/src/EffectsEngine/EffectsEngine.h
+++ b/src/EffectsEngine/EffectsEngine.h
@@ -77,7 +77,7 @@ class   EffectsEngine : public QObject, public Singleton<EffectsEngine>
 
         Effect*     effect( const QString& name );
         bool        loadEffect( const QString& fileName );
-        void        browseDirectory( const QString& path );
+        void        loadEffects();
 
         //Filters methods:
         static void applyFilters( const FilterList &effects,
@@ -93,7 +93,9 @@ class   EffectsEngine : public QObject, public Singleton<EffectsEngine>
     private:
         EffectsEngine();
         ~EffectsEngine();
+        void        browseDirectory( const QString& path );
 
+    private:
         QHash<QString, Effect*> m_effects;
         QSettings               *m_cache;
         QTime                   *m_time;
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 492fb26..73165ed 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -446,7 +446,7 @@ MainWindow::initializeDockWidgets( void )
                                   QT_TRANSLATE_NOOP( "DockWidgetManager", "Effects List" ),
                                   Qt::AllDockWidgetAreas, QDockWidget::AllDockWidgetFeatures,
                                   Qt::LeftDockWidgetArea );
-    EffectsEngine::getInstance()->browseDirectory( "/usr/lib/frei0r-1" );
+    EffectsEngine::getInstance()->loadEffects();
 
     m_renderer = new WorkflowRenderer();
     m_renderer->initializeRenderer();
@@ -638,7 +638,7 @@ MainWindow::renderVideoSettings( bool exportType )
 
     if ( exportType )
         outputFileName = VLMC_GET_STRING( "general/TempFolderLocation" ) + "/" +
-                         VLMC_PROJECT_GET_STRING( "general/ProjectName" ) + 
+                         VLMC_PROJECT_GET_STRING( "general/ProjectName" ) +
                          "-vlmc.mp4";
     else
         outputFileName = settings->outputFileName();
@@ -666,23 +666,23 @@ MainWindow::on_actionShare_On_Internet_triggered()
 
         if( !renderVideoSettings( true ) )
             return;
-                   
+
         checkFolders();
         QString fileName = VLMC_GET_STRING( "general/TempFolderLocation" ) + "/" +
-                           VLMC_PROJECT_GET_STRING( "general/ProjectName" ) + 
+                           VLMC_PROJECT_GET_STRING( "general/ProjectName" ) +
                            "-vlmc.mp4";
 
         loadGlobalProxySettings();
 
         ShareOnInternet *shareVideo = new ShareOnInternet();
         shareVideo->setVideoFile( fileName );
- 
+
         if ( shareVideo->exec() == QDialog::Rejected )
         {
             delete shareVideo;
             return;
         }
- 
+
         delete shareVideo;
     }
 }



More information about the Vlmc-devel mailing list