Commit 8937d07f authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

EffectsEngine: Respecting plugin path reference.

Won't work for windows right now.
parent 3250bf1d
...@@ -71,12 +71,17 @@ EffectsEngine::loadEffect( const QString &fileName ) ...@@ -71,12 +71,17 @@ EffectsEngine::loadEffect( const QString &fileName )
else else
{ {
type = static_cast<Effect::Type>( typeInt ); type = static_cast<Effect::Type>( typeInt );
if ( m_effects.contains( name ) == true )
{
delete e;
return false;
}
m_effects[name] = e; m_effects[name] = e;
emit effectAdded( e, name, type ); emit effectAdded( e, name, type );
return true; return true;
} }
} }
if ( e->load() == false ) if ( e->load() == false || m_effects.contains( e->name() ) == true )
{ {
delete e; delete e;
return false; return false;
...@@ -94,11 +99,14 @@ void ...@@ -94,11 +99,14 @@ void
EffectsEngine::browseDirectory( const QString &path ) EffectsEngine::browseDirectory( const QString &path )
{ {
QDir dir( 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 ); 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 ...@@ -213,3 +221,22 @@ EffectsEngine::initMixers( const MixerList &mixers, quint32 width, quint32 heigh
++it; ++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] );
}
}
}
...@@ -77,7 +77,7 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine> ...@@ -77,7 +77,7 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine>
Effect* effect( const QString& name ); Effect* effect( const QString& name );
bool loadEffect( const QString& fileName ); bool loadEffect( const QString& fileName );
void browseDirectory( const QString& path ); void loadEffects();
//Filters methods: //Filters methods:
static void applyFilters( const FilterList &effects, static void applyFilters( const FilterList &effects,
...@@ -93,7 +93,9 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine> ...@@ -93,7 +93,9 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine>
private: private:
EffectsEngine(); EffectsEngine();
~EffectsEngine(); ~EffectsEngine();
void browseDirectory( const QString& path );
private:
QHash<QString, Effect*> m_effects; QHash<QString, Effect*> m_effects;
QSettings *m_cache; QSettings *m_cache;
QTime *m_time; QTime *m_time;
......
...@@ -446,7 +446,7 @@ MainWindow::initializeDockWidgets( void ) ...@@ -446,7 +446,7 @@ MainWindow::initializeDockWidgets( void )
QT_TRANSLATE_NOOP( "DockWidgetManager", "Effects List" ), QT_TRANSLATE_NOOP( "DockWidgetManager", "Effects List" ),
Qt::AllDockWidgetAreas, QDockWidget::AllDockWidgetFeatures, Qt::AllDockWidgetAreas, QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea ); Qt::LeftDockWidgetArea );
EffectsEngine::getInstance()->browseDirectory( "/usr/lib/frei0r-1" ); EffectsEngine::getInstance()->loadEffects();
m_renderer = new WorkflowRenderer(); m_renderer = new WorkflowRenderer();
m_renderer->initializeRenderer(); m_renderer->initializeRenderer();
...@@ -638,7 +638,7 @@ MainWindow::renderVideoSettings( bool exportType ) ...@@ -638,7 +638,7 @@ MainWindow::renderVideoSettings( bool exportType )
if ( exportType ) if ( exportType )
outputFileName = VLMC_GET_STRING( "general/TempFolderLocation" ) + "/" + outputFileName = VLMC_GET_STRING( "general/TempFolderLocation" ) + "/" +
VLMC_PROJECT_GET_STRING( "general/ProjectName" ) + VLMC_PROJECT_GET_STRING( "general/ProjectName" ) +
"-vlmc.mp4"; "-vlmc.mp4";
else else
outputFileName = settings->outputFileName(); outputFileName = settings->outputFileName();
...@@ -666,23 +666,23 @@ MainWindow::on_actionShare_On_Internet_triggered() ...@@ -666,23 +666,23 @@ MainWindow::on_actionShare_On_Internet_triggered()
if( !renderVideoSettings( true ) ) if( !renderVideoSettings( true ) )
return; return;
checkFolders(); checkFolders();
QString fileName = VLMC_GET_STRING( "general/TempFolderLocation" ) + "/" + QString fileName = VLMC_GET_STRING( "general/TempFolderLocation" ) + "/" +
VLMC_PROJECT_GET_STRING( "general/ProjectName" ) + VLMC_PROJECT_GET_STRING( "general/ProjectName" ) +
"-vlmc.mp4"; "-vlmc.mp4";
loadGlobalProxySettings(); loadGlobalProxySettings();
ShareOnInternet *shareVideo = new ShareOnInternet(); ShareOnInternet *shareVideo = new ShareOnInternet();
shareVideo->setVideoFile( fileName ); shareVideo->setVideoFile( fileName );
if ( shareVideo->exec() == QDialog::Rejected ) if ( shareVideo->exec() == QDialog::Rejected )
{ {
delete shareVideo; delete shareVideo;
return; return;
} }
delete shareVideo; delete shareVideo;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment