Commit 55ae968a authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Project: Load the ClipWorkflow's effects that was saved.

This prepares the MainWorkflow for effects undo/redo
parent 8f1cedc4
......@@ -91,7 +91,8 @@ QStringList ProjectManager::recentsProjects() const
return m_recentsProjects;
}
void ProjectManager::loadWorkflow()
void
ProjectManager::loadWorkflow()
{
QDomElement root = m_domDocument->documentElement();
bool savedState;
......@@ -110,7 +111,8 @@ void ProjectManager::loadWorkflow()
delete m_domDocument;
}
void ProjectManager::loadProject( const QString& fileName )
void
ProjectManager::loadProject( const QString& fileName )
{
//FIXME:this is probably useless, as this is handled by the gui part now.
//Don't print an error. The user most likely canceled the open project dialog.
......
......@@ -53,7 +53,8 @@ class AudioClipWorkflow : public ClipWorkflow
void *getLockCallback() const;
void *getUnlockCallback() const;
virtual void *getOutput( ClipWorkflow::GetMode mode );
virtual void saveEffects( QXmlStreamWriter & ) const {} //Nothing to do here now.
virtual bool appendEffect( Effect *, qint64, qint64 ) { return false; }; //Nothing to do here now.
protected:
virtual quint32 getNbComputedBuffers() const;
virtual quint32 getMaxComputedBuffers() const;
......
......@@ -30,13 +30,14 @@
#include <QUuid>
#include <QXmlStreamWriter>
class Clip;
class Effect;
class WaitCondition;
class QMutex;
class QReadWriteLock;
class QWaitCondition;
class Clip;
class WaitCondition;
namespace Workflow
{
class Frame;
......@@ -198,10 +199,9 @@ class ClipWorkflow : public QObject
void stopRenderer();
void save( QXmlStreamWriter& project ) const;
virtual void saveEffects( QXmlStreamWriter& ) const
{
//Empty implementation, as some clipworkflow does not have effects for now.
}
virtual void saveEffects( QXmlStreamWriter& ) const = 0;
virtual bool appendEffect( Effect *effect, qint64 start = 0,
qint64 end = -1 ) = 0;
private:
void setState( State state );
......
......@@ -43,6 +43,8 @@ class ImageClipWorkflow : public ClipWorkflow
void *getLockCallback() const;
void *getUnlockCallback() const;
virtual void *getOutput( ClipWorkflow::GetMode mode );
virtual void saveEffects( QXmlStreamWriter & ) const {} //Nothing to do here now.
virtual bool appendEffect( Effect *, qint64, qint64 ) { return false; }; //Nothing to do here now.
protected:
virtual void initVlcOutput();
virtual quint32 getNbComputedBuffers() const;
......
......@@ -84,6 +84,12 @@ MainWorkflow::addClip( ClipHelper *clipHelper, unsigned int trackId,
emit clipAdded( clipHelper, trackId, start, trackType );
}
void
MainWorkflow::addEffect( Effect *effect, quint32 trackId, const QUuid &uuid, TrackType type )
{
m_tracks[type]->addEffect( effect, trackId, uuid );
}
void
MainWorkflow::computeLength()
{
......@@ -340,6 +346,27 @@ MainWorkflow::loadProject( const QDomElement &root )
end.toLongLong(), chUuid );
addClip( ch, trackId, startFrame.toLongLong(), type, true );
}
QDomElement effects = clip.firstChildElement( "effects" );
if ( effects.isNull() == false )
{
QDomElement effect = effects.firstChildElement( "effect" );
while ( effect.isNull() == false )
{
if ( effect.hasAttribute( "name" ) == true &&
effect.hasAttribute( "start" ) == true &&
effect.hasAttribute( "end" ) == true )
{
Effect *e = EffectsEngine::getInstance()->effect( effect.attribute( "name" ) );
if ( e != NULL )
addEffect( e, trackId, uuid, type );
else
qCritical() << "Can't load effect" << effect.attribute( "name" );
}
effect = effect.nextSibling().toElement();
}
}
clip = clip.nextSibling().toElement();
}
elem = elem.nextSibling().toElement();
......
......@@ -27,14 +27,10 @@
#include "Singleton.hpp"
#include <QXmlStreamWriter>
class QDomDocument;
class QDomElement;
class QMutex;
class QReadWriteLock;
class Clip;
class ClipHelper;
class EffectsEngine;
class Effect;
class TrackHandler;
class TrackWorkflow;
namespace Workflow
......@@ -43,6 +39,11 @@ namespace Workflow
class AudioSample;
}
class QDomDocument;
class QDomElement;
class QMutex;
class QReadWriteLock;
#include <QObject>
#include <QUuid>
......@@ -106,9 +107,13 @@ class MainWorkflow : public QObject, public Singleton<MainWorkflow>
* \sa removeClip( const QUuid&, unsigned int, MainWorkflow::TrackType )
* \sa clipAdded( Clip*, unsigned int, qint64, MainWorkflow::TrackType )
*/
void addClip( ClipHelper* clipHelper, unsigned int trackId, qint64 start,
void addClip( ClipHelper* clipHelper, quint32 trackId, qint64 start,
TrackType type, bool informGui );
void addEffect( Effect* effect, quint32 trackId, const QUuid &uuid,
TrackType type );
/**
* \brief Initialize the workflow for the render.
*
......
......@@ -64,6 +64,12 @@ TrackHandler::addClip( ClipHelper* ch, unsigned int trackId, qint64 start )
activateTrack( trackId );
}
void
TrackHandler::addEffect( Effect *effect, quint32 trackId, const QUuid &uuid )
{
m_tracks[trackId]->addEffect( effect, uuid );
}
void
TrackHandler::startRender()
{
......
......@@ -47,6 +47,8 @@ class TrackHandler : public QObject
* \param start The new clip starting position.
*/
void addClip( ClipHelper* clip, unsigned int trackId, qint64 start );
void addEffect( Effect *effect, quint32 trackId, const QUuid &uuid );
/**
* Returns the number of tracks in this handler
*/
......
......@@ -88,6 +88,20 @@ TrackWorkflow::addClip( ClipWorkflow* cw, qint64 start )
computeLength();
}
void
TrackWorkflow::addEffect( Effect *effect, const QUuid &uuid )
{
QMap<qint64, ClipWorkflow*>::const_iterator it = m_clips.begin();
QMap<qint64, ClipWorkflow*>::const_iterator end = m_clips.end();
while ( it != end )
{
if ( it.value()->getClipHelper()->clip()->fullId() == uuid )
it.value()->appendEffect( effect );
++it;
}
}
//Must be called from a thread safe method (m_clipsLock locked)
void
TrackWorkflow::computeLength()
......
......@@ -58,6 +58,7 @@ class TrackWorkflow : public QObject
ClipWorkflow* removeClipWorkflow( const QUuid& id );
void addClip( ClipHelper*, qint64 start );
void addClip( ClipWorkflow*, qint64 start );
void addEffect( Effect *effect, const QUuid &uuid );
qint64 getClipPosition( const QUuid& uuid ) const;
Clip* getClip( const QUuid& uuid );
......
......@@ -212,6 +212,7 @@ VideoClipWorkflow::flushComputedBuffers()
bool
VideoClipWorkflow::appendEffect( Effect *effect, qint64 start, qint64 end )
{
qDebug() << "Adding effect:" << effect;
if ( effect->type() != Effect::Filter )
{
qWarning() << "VideoClipWorkflow does not handle non filter effects.";
......
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