Commit 09b1ea40 authored by luyikei's avatar luyikei

Move Core::instance()->undoStack() to Mainworkflow

parent 6cc0d9b7
......@@ -32,12 +32,6 @@
#include "AbstractUndoStack.h"
#include "Backend/IFilter.h"
void
Commands::trigger( Generic* command )
{
Core::instance()->undoStack()->push( command );
}
Commands::Generic::Generic() :
m_valid( true )
{
......
......@@ -74,8 +74,6 @@ namespace Commands
void invalidated();
};
void trigger( Generic* command );
namespace Clip
{
class Add : public Generic
......
......@@ -439,7 +439,7 @@ MainWindow::setupUndoRedoWidget()
m_undoView = new QUndoView;
m_undoView->setObjectName( QStringLiteral( "History" ) );
m_dockedUndoView = dockWidget( m_undoView, Qt::TopDockWidgetArea );
auto stack = Core::instance()->undoStack();
auto stack = Core::instance()->workflow()->undoStack();
connect( stack, SIGNAL( canUndoChanged( bool ) ), this, SLOT( canUndoChanged( bool ) ) );
connect( stack, SIGNAL( canRedoChanged( bool ) ), this, SLOT( canRedoChanged( bool ) ) );
canUndoChanged( stack->canUndo() );
......@@ -803,13 +803,13 @@ MainWindow::onProjectSaved()
void
MainWindow::on_actionUndo_triggered()
{
Core::instance()->undoStack()->undo();
Core::instance()->workflow()->undoStack()->undo();
}
void
MainWindow::on_actionRedo_triggered()
{
Core::instance()->undoStack()->redo();
Core::instance()->workflow()->undoStack()->redo();
}
void
......
......@@ -35,7 +35,6 @@
#include <Settings/Settings.h>
#include <Tools/VlmcLogger.h>
#include "Workflow/MainWorkflow.h"
#include "Commands/AbstractUndoStack.h"
Core::Core()
{
......@@ -48,12 +47,9 @@ Core::Core()
m_recentProjects = new RecentProjects( m_settings );
m_workspace = new Workspace( m_settings );
m_workflow = new MainWorkflow( m_currentProject->settings() );
m_undoStack = new Commands::AbstractUndoStack;
QObject::connect( m_undoStack, &Commands::AbstractUndoStack::cleanChanged,
m_currentProject, &Project::cleanChanged );
QObject::connect( m_currentProject, &Project::projectSaved,
m_undoStack, &Commands::AbstractUndoStack::setClean );
QObject::connect( m_workflow, &MainWorkflow::cleanChanged, m_currentProject, &Project::cleanChanged );
QObject::connect( m_currentProject, &Project::projectSaved, m_workflow, &MainWorkflow::setClean );
QObject::connect( m_library, &Library::cleanStateChanged, m_currentProject, &Project::libraryCleanChanged );
QObject::connect( m_currentProject, &Project::projectLoaded, m_recentProjects, &RecentProjects::projectLoaded );
QObject::connect( m_currentProject, &Project::projectClosed, m_library, &Library::clear );
......@@ -66,7 +62,6 @@ Core::Core()
Core::~Core()
{
delete m_library;
delete m_undoStack;
delete m_workflow;
delete m_currentProject;
delete m_workspace;
......@@ -149,12 +144,6 @@ Core::workflow()
return m_workflow;
}
Commands::AbstractUndoStack*
Core::undoStack()
{
return m_undoStack;
}
Library*
Core::library()
{
......
......@@ -38,11 +38,6 @@ namespace Backend
class IBackend;
}
namespace Commands
{
class AbstractUndoStack;
}
#include <QElapsedTimer>
#include "Tools/Singleton.hpp"
......@@ -56,7 +51,6 @@ class Core : public ScopedSingleton<Core>
Workspace* workspace();
Project* project();
MainWorkflow* workflow();
Commands::AbstractUndoStack* undoStack();
Library* library();
/**
* @brief runtime returns the application runtime
......@@ -81,7 +75,6 @@ class Core : public ScopedSingleton<Core>
Workspace* m_workspace;
Project* m_currentProject;
MainWorkflow* m_workflow;
Commands::AbstractUndoStack* m_undoStack;
Library* m_library;
QElapsedTimer m_timer;
......
......@@ -53,7 +53,8 @@ MainWorkflow::MainWorkflow( Settings* projectSettings, int trackCount ) :
m_trackCount( trackCount ),
m_settings( new Settings ),
m_renderer( new AbstractRenderer ),
m_multitrack( new Backend::MLT::MLTMultiTrack )
m_multitrack( new Backend::MLT::MLTMultiTrack ),
m_undoStack( new Commands::AbstractUndoStack )
{
m_renderer->setInput( m_multitrack );
......@@ -71,6 +72,8 @@ MainWorkflow::MainWorkflow( Settings* projectSettings, int trackCount ) :
connect( m_settings, &Settings::postLoad, this, &MainWorkflow::postLoad, Qt::DirectConnection );
connect( m_settings, &Settings::preSave, this, &MainWorkflow::preSave, Qt::DirectConnection );
projectSettings->addSettings( "Workspace", *m_settings );
connect( m_undoStack.get(), &Commands::AbstractUndoStack::cleanChanged, this, &MainWorkflow::cleanChanged );
}
MainWorkflow::~MainWorkflow()
......@@ -119,6 +122,12 @@ MainWorkflow::clip( const QUuid &uuid, unsigned int trackId )
return track( trackId )->clip( uuid );
}
void
MainWorkflow::trigger( Commands::Generic* command )
{
m_undoStack->push( command );
}
void
MainWorkflow::clear()
{
......@@ -127,6 +136,12 @@ MainWorkflow::clear()
emit cleared();
}
void
MainWorkflow::setClean()
{
m_undoStack->setClean();
}
void
MainWorkflow::setPosition( qint64 newFrame )
{
......@@ -146,6 +161,12 @@ MainWorkflow::renderer()
return m_renderer;
}
Commands::AbstractUndoStack*
MainWorkflow::undoStack()
{
return m_undoStack.get();
}
int
MainWorkflow::getTrackCount() const
{
......@@ -201,7 +222,7 @@ MainWorkflow::addClip( const QString& uuid, quint32 trackId, qint32 pos, bool is
else
newClip->setFormats( Clip::Video );
Commands::trigger( new Commands::Clip::Add( newClip, track( trackId ), pos ) );
trigger( new Commands::Clip::Add( newClip, track( trackId ), pos ) );
emit clipAdded( newClip->uuid().toString() );
return newClip->uuid().toString();
}
......@@ -256,7 +277,7 @@ MainWorkflow::moveClip( const QString& uuid, quint32 trackId, qint64 startFrame
if ( startFrame == getClipPosition( uuid, oldTrackId ) )
return;
Commands::trigger( new Commands::Clip::Move( track( oldTrackId ), track( trackId ), clip, startFrame ) );
trigger( new Commands::Clip::Move( track( oldTrackId ), track( trackId ), clip, startFrame ) );
m_clips.erase( it );
m_clips.insertMulti( trackId, clip );
......@@ -276,7 +297,7 @@ MainWorkflow::resizeClip( const QString& uuid, qint64 newBegin, qint64 newEnd, q
auto trackId = it.key();
auto clip = it.value();
Commands::trigger( new Commands::Clip::Resize( track( trackId ), clip, newBegin, newEnd, newPos ) );
trigger( new Commands::Clip::Resize( track( trackId ), clip, newBegin, newEnd, newPos ) );
emit clipResized( uuid );
return;
}
......@@ -293,7 +314,7 @@ MainWorkflow::removeClip( const QString& uuid )
auto trackId = it.key();
auto clip = it.value();
Commands::trigger( new Commands::Clip::Remove( clip, track( trackId ) ) );
trigger( new Commands::Clip::Remove( clip, track( trackId ) ) );
emit clipRemoved( uuid );
return;
}
......@@ -309,7 +330,7 @@ MainWorkflow::linkClips( const QString& uuidA, const QString& uuidB )
for ( auto clipB : m_clips )
if ( clipB->uuid().toString() == uuidB )
{
Commands::trigger( new Commands::Clip::Link( clipA, clipB ) );
trigger( new Commands::Clip::Link( clipA, clipB ) );
emit clipLinked( uuidA, uuidB );
return;
}
......@@ -332,7 +353,7 @@ MainWorkflow::addEffect( const QString &clipUuid, const QString &effectId )
for ( auto clip : m_clips )
if ( clip->uuid().toString() == clipUuid )
{
Commands::trigger( new Commands::Effect::Add(
trigger( new Commands::Effect::Add(
std::shared_ptr<EffectHelper>( newEffect ), clip->input() )
);
return newEffect->uuid().toString();
......
......@@ -36,6 +36,12 @@ class Effect;
class TrackWorkflow;
class AbstractRenderer;
namespace Commands
{
class AbstractUndoStack;
class Generic;
}
namespace Backend
{
class IMultiTrack;
......@@ -174,6 +180,8 @@ class MainWorkflow : public QObject
AbstractRenderer* renderer();
Commands::AbstractUndoStack* undoStack();
private:
/**
......@@ -184,6 +192,8 @@ class MainWorkflow : public QObject
*/
std::shared_ptr<Clip> clip( const QUuid& uuid, unsigned int trackId );
void trigger( Commands::Generic* command );
void preSave();
void postLoad();
......@@ -197,6 +207,8 @@ class MainWorkflow : public QObject
AbstractRenderer* m_renderer;
Backend::IMultiTrack* m_multitrack;
std::unique_ptr<Commands::AbstractUndoStack> m_undoStack;
public slots:
/**
* \brief Clear the workflow.
......@@ -209,6 +221,8 @@ class MainWorkflow : public QObject
*/
void clear();
void setClean();
void setPosition( qint64 newFrame );
void setFps( double fps );
......@@ -248,6 +262,8 @@ class MainWorkflow : public QObject
void fpsChanged( double fps );
void cleanChanged( bool isClean );
void clipAdded( const QString& uuid );
void clipResized( const QString& uuid );
void clipRemoved( const QString& uuid );
......
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