Commit 876a7b7e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Renderer: Save the effects to the project file.

parent 55ae968a
...@@ -159,3 +159,23 @@ EffectsEngine::applyEffects( const EffectList &effects, Workflow::Frame* frame, ...@@ -159,3 +159,23 @@ EffectsEngine::applyEffects( const EffectList &effects, Workflow::Frame* frame,
} }
} }
} }
void
EffectsEngine::saveEffects( const EffectList &effects, QXmlStreamWriter &project )
{
if ( effects.size() <= 0 )
return ;
EffectsEngine::EffectList::const_iterator it = effects.begin();
EffectsEngine::EffectList::const_iterator ite = effects.end();
project.writeStartElement( "effects" );
while ( it != ite )
{
project.writeStartElement( "effect" );
project.writeAttribute( "name", (*it)->effect->effect()->name() );
project.writeAttribute( "start", QString::number( (*it)->start ) );
project.writeAttribute( "end", QString::number( (*it)->end ) );
project.writeEndElement();
++it;
}
project.writeEndElement();
}
...@@ -53,8 +53,10 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine> ...@@ -53,8 +53,10 @@ class EffectsEngine : public QObject, public Singleton<EffectsEngine>
bool loadEffect( const QString& fileName ); bool loadEffect( const QString& fileName );
void browseDirectory( const QString& path ); void browseDirectory( const QString& path );
static void applyEffects( const EffectList& effects, static void applyEffects( const EffectList &effects,
Workflow::Frame *frame, qint64 currentFrame ); Workflow::Frame *frame, qint64 currentFrame );
static void saveEffects( const EffectList &effects, QXmlStreamWriter &project );
private: private:
EffectsEngine(); EffectsEngine();
~EffectsEngine(); ~EffectsEngine();
......
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
TracksRuler* tracksRuler() { return m_tracksRuler; } TracksRuler* tracksRuler() { return m_tracksRuler; }
/// Return a pointer to the Timeline instance (singleton). /// Return a pointer to the Timeline instance (singleton).
static Timeline* getInstance() { return m_instance; } static Timeline* getInstance() { return m_instance; }
const WorkflowRenderer *renderer() const { return m_renderer; }
void save( QXmlStreamWriter& project ) const; void save( QXmlStreamWriter& project ) const;
void load( const QDomElement &root ); void load( const QDomElement &root );
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include "project/GuiProjectManager.h" #include "project/GuiProjectManager.h"
#include "ProjectManager.h" #include "ProjectManager.h"
#include "SettingsManager.h" #include "SettingsManager.h"
#include "Timeline.h"
#include "WorkflowRenderer.h"
#include "Workspace.h" #include "Workspace.h"
#include <QDir> #include <QDir>
...@@ -163,6 +165,7 @@ void ProjectManager::__saveProject( const QString &fileName ) ...@@ -163,6 +165,7 @@ void ProjectManager::__saveProject( const QString &fileName )
Library::getInstance()->saveProject( project ); Library::getInstance()->saveProject( project );
MainWorkflow::getInstance()->saveProject( project ); MainWorkflow::getInstance()->saveProject( project );
Timeline::getInstance()->renderer()->saveProject( project );
SettingsManager::getInstance()->save( project ); SettingsManager::getInstance()->save( project );
saveTimeline( project ); saveTimeline( project );
......
...@@ -393,6 +393,17 @@ WorkflowRenderer::appendEffect( Effect *effect, qint64 start, qint64 end ) ...@@ -393,6 +393,17 @@ WorkflowRenderer::appendEffect( Effect *effect, qint64 start, qint64 end )
m_effects.push_back( new EffectsEngine::EffectHelper( effectInstance, start, end ) ); m_effects.push_back( new EffectsEngine::EffectHelper( effectInstance, start, end ) );
} }
void
WorkflowRenderer::saveProject( QXmlStreamWriter &project ) const
{
project.writeStartElement( "renderer" );
{
QReadLocker lock( m_effectsLock );
EffectsEngine::getInstance()->saveEffects( m_effects, project );
}
project.writeEndElement();
}
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
/////SLOTS : /////SLOTS :
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
......
...@@ -133,6 +133,8 @@ class WorkflowRenderer : public GenericRenderer ...@@ -133,6 +133,8 @@ class WorkflowRenderer : public GenericRenderer
void appendEffect( Effect* effect, qint64 start = 0, qint64 end = -1 ); void appendEffect( Effect* effect, qint64 start = 0, qint64 end = -1 );
void saveProject( QXmlStreamWriter &project ) const;
private: private:
/** /**
* \brief This is a subpart of the togglePlayPause( bool ) method * \brief This is a subpart of the togglePlayPause( bool ) method
......
...@@ -228,21 +228,7 @@ void ...@@ -228,21 +228,7 @@ void
VideoClipWorkflow::saveEffects( QXmlStreamWriter &project ) const VideoClipWorkflow::saveEffects( QXmlStreamWriter &project ) const
{ {
QReadLocker lock( m_effectsLock ); QReadLocker lock( m_effectsLock );
if ( m_effects.size() <= 0 ) EffectsEngine::getInstance()->saveEffects( m_effects, project );
return ;
EffectsEngine::EffectList::const_iterator it = m_effects.begin();
EffectsEngine::EffectList::const_iterator ite = m_effects.end();
project.writeStartElement( "effects" );
while ( it != ite )
{
project.writeStartElement( "effect" );
project.writeAttribute( "name", (*it)->effect->effect()->name() );
project.writeAttribute( "start", QString::number( (*it)->start ) );
project.writeAttribute( "end", QString::number( (*it)->end ) );
project.writeEndElement();
++it;
}
project.writeEndElement();
} }
void void
......
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