[vlmc-devel] commit: EffectsEngine: Cache the plugins. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Wed Jul 28 00:22:08 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Tue Jul 27 23:13:56 2010 +0200| [9252c44988dd7b4172abb4cb429e4fc9348cbcc7] | committer: Hugo Beauzée-Luyssen
EffectsEngine: Cache the plugins.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=9252c44988dd7b4172abb4cb429e4fc9348cbcc7
---
src/EffectsEngine/EffectsEngine.cpp | 31 +++++++++++++++++++++++++++++--
src/EffectsEngine/EffectsEngine.h | 3 +++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/EffectsEngine/EffectsEngine.cpp b/src/EffectsEngine/EffectsEngine.cpp
index fa96dc1..d8cf2ec 100644
--- a/src/EffectsEngine/EffectsEngine.cpp
+++ b/src/EffectsEngine/EffectsEngine.cpp
@@ -26,11 +26,16 @@
#include "EffectInstance.h"
#include "Types.h"
+#include <QDesktopServices>
#include <QDir>
+#include <QSettings>
#include <QtDebug>
EffectsEngine::EffectsEngine()
{
+ m_cache = new QSettings( QDesktopServices::storageLocation(
+ QDesktopServices::CacheLocation ) + "/effects",
+ QSettings::IniFormat, this );
}
EffectsEngine::~EffectsEngine()
@@ -61,14 +66,36 @@ EffectsEngine::effect( const QString& name )
bool
EffectsEngine::loadEffect( const QString &fileName )
{
- Effect* e = new Effect( fileName );
+ Effect* e = new Effect( fileName );
+ QString name;
+ Effect::Type type;
+
+ if ( m_cache->contains( fileName + "/name" ) == true &&
+ m_cache->contains( fileName + "/type" ) == true )
+ {
+ name = m_cache->value( fileName + "/name" ).toString();
+ int typeInt = m_cache->value( fileName + "/type" ).toInt();
+ if ( typeInt < Effect::Unknown || typeInt > Effect::Mixer3 )
+ qWarning() << "Invalid plugin type.";
+ else
+ {
+ type = static_cast<Effect::Type>( typeInt );
+ m_effects[name] = e;
+ emit effectAdded( e, type );
+ return true;
+ }
+ }
if ( e->load() == false )
{
delete e;
return false;
}
m_effects[e->name()] = e;
- emit effectAdded( e, e->type() );
+ m_cache->setValue( fileName + "/name", e->name() );
+ m_cache->setValue( fileName + "/type", e->type() );
+ name = e->name();
+ type = e->type();
+ emit effectAdded( e, type );
return true;
}
diff --git a/src/EffectsEngine/EffectsEngine.h b/src/EffectsEngine/EffectsEngine.h
index 302fbe7..fb8d886 100644
--- a/src/EffectsEngine/EffectsEngine.h
+++ b/src/EffectsEngine/EffectsEngine.h
@@ -31,6 +31,8 @@
#include <QObject>
#include <QHash>
+class QSettings;
+
class EffectsEngine : public QObject, public Singleton<EffectsEngine>
{
Q_OBJECT
@@ -58,6 +60,7 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine>
~EffectsEngine();
QHash<QString, Effect*> m_effects;
+ QSettings *m_cache;
signals:
void effectAdded( Effect*, Effect::Type );
More information about the Vlmc-devel
mailing list