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

Make WorkflowRenderer a project class.

It is now being constructed when a project is created.
parent 8ea45a58
...@@ -390,9 +390,7 @@ MainWindow::createStatusBar() ...@@ -390,9 +390,7 @@ MainWindow::createStatusBar()
void void
MainWindow::initializeDockWidgets() MainWindow::initializeDockWidgets()
{ {
m_renderer = new WorkflowRenderer( m_backend ); m_timeline = new Timeline( this );
m_renderer->initializeRenderer();
m_timeline = new Timeline( m_renderer, this );
m_timeline->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); m_timeline->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_timeline->show(); m_timeline->show();
setCentralWidget( m_timeline ); setCentralWidget( m_timeline );
...@@ -466,7 +464,6 @@ MainWindow::setupProjectPreview() ...@@ -466,7 +464,6 @@ MainWindow::setupProjectPreview()
QDockWidget::AllDockWidgetFeatures ); QDockWidget::AllDockWidgetFeatures );
m_projectPreview = new PreviewWidget( dockedWidget ); m_projectPreview = new PreviewWidget( dockedWidget );
m_projectPreview->setRenderer( m_renderer );
m_projectPreview->setClipEdition( false ); m_projectPreview->setClipEdition( false );
KeyboardShortcutHelper* renderShortcut = new KeyboardShortcutHelper( "keyboard/renderpreview", this ); KeyboardShortcutHelper* renderShortcut = new KeyboardShortcutHelper( "keyboard/renderpreview", this );
connect( renderShortcut, SIGNAL( activated() ), m_projectPreview, SLOT( on_pushButtonPlay_clicked() ) ); connect( renderShortcut, SIGNAL( activated() ), m_projectPreview, SLOT( on_pushButtonPlay_clicked() ) );
...@@ -582,13 +579,12 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h ...@@ -582,13 +579,12 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h
{ {
if ( m_fileRenderer ) if ( m_fileRenderer )
delete m_fileRenderer; delete m_fileRenderer;
m_fileRenderer = new WorkflowFileRenderer( m_backend ); m_fileRenderer = new WorkflowFileRenderer( m_backend, Project::getInstance()->workflow() );
WorkflowFileRendererDialog *dialog = new WorkflowFileRendererDialog( m_fileRenderer, width, height ); WorkflowFileRendererDialog *dialog = new WorkflowFileRendererDialog( m_fileRenderer, width, height );
dialog->setModal( true ); dialog->setModal( true );
dialog->setOutputFileName( outputFileName ); dialog->setOutputFileName( outputFileName );
m_fileRenderer->initializeRenderer();
m_fileRenderer->run( outputFileName, width, height, fps, vbitrate, abitrate ); m_fileRenderer->run( outputFileName, width, height, fps, vbitrate, abitrate );
if ( dialog->exec() == QDialog::Rejected ) if ( dialog->exec() == QDialog::Rejected )
...@@ -604,6 +600,8 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h ...@@ -604,6 +600,8 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h
bool bool
MainWindow::renderVideoSettings( bool shareOnInternet ) MainWindow::renderVideoSettings( bool shareOnInternet )
{ {
Project::getInstance()->workflowRenderer()->stop();
RendererSettings *settings = new RendererSettings( shareOnInternet ); RendererSettings *settings = new RendererSettings( shareOnInternet );
if ( settings->exec() == QDialog::Rejected ) if ( settings->exec() == QDialog::Rejected )
...@@ -629,7 +627,6 @@ MainWindow::on_actionRender_triggered() ...@@ -629,7 +627,6 @@ MainWindow::on_actionRender_triggered()
{ {
if ( checkVideoLength() ) if ( checkVideoLength() )
{ {
m_renderer->stop();
//Setup dialog box for querying render parameters. //Setup dialog box for querying render parameters.
renderVideoSettings( false ); renderVideoSettings( false );
} }
...@@ -640,8 +637,6 @@ MainWindow::on_actionShare_On_Internet_triggered() ...@@ -640,8 +637,6 @@ MainWindow::on_actionShare_On_Internet_triggered()
{ {
if ( checkVideoLength() ) if ( checkVideoLength() )
{ {
m_renderer->stop();
if( !renderVideoSettings( true ) ) if( !renderVideoSettings( true ) )
return; return;
...@@ -849,6 +844,9 @@ MainWindow::onProjectLoaded(Project* project) ...@@ -849,6 +844,9 @@ MainWindow::onProjectLoaded(Project* project)
const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() ); const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() );
connect( project->library(), SIGNAL( clipRemoved( const QUuid& ) ), clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) ); connect( project->library(), SIGNAL( clipRemoved( const QUuid& ) ), clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
m_timeline->setRenderer( project->workflowRenderer() );
m_projectPreview->setRenderer( project->workflowRenderer() );
} }
#ifdef WITH_CRASHBUTTON #ifdef WITH_CRASHBUTTON
......
...@@ -129,7 +129,6 @@ private: ...@@ -129,7 +129,6 @@ private:
PreviewWidget* m_clipPreview; PreviewWidget* m_clipPreview;
PreviewWidget* m_projectPreview; PreviewWidget* m_projectPreview;
WorkflowFileRenderer* m_fileRenderer; WorkflowFileRenderer* m_fileRenderer;
WorkflowRenderer* m_renderer;
SettingsDialog* m_globalPreferences; SettingsDialog* m_globalPreferences;
SettingsDialog* m_DefaultProjectPreferences; SettingsDialog* m_DefaultProjectPreferences;
SettingsDialog* m_projectPreferences; SettingsDialog* m_projectPreferences;
......
...@@ -38,8 +38,9 @@ ...@@ -38,8 +38,9 @@
Timeline* Timeline::m_instance = NULL; Timeline* Timeline::m_instance = NULL;
Timeline::Timeline( WorkflowRenderer* renderer, QWidget *parent ) : Timeline::Timeline( QWidget *parent )
QWidget( parent ), m_scale( 1.0 ), m_renderer( renderer ) : QWidget( parent )
, m_scale( 1.0 )
{ {
Q_ASSERT( m_instance == NULL ); Q_ASSERT( m_instance == NULL );
m_instance = this; m_instance = this;
...@@ -228,3 +229,9 @@ Timeline::load( const QDomElement &root ) ...@@ -228,3 +229,9 @@ Timeline::load( const QDomElement &root )
elem = elem.nextSiblingElement(); elem = elem.nextSiblingElement();
} }
} }
void
Timeline::setRenderer( WorkflowRenderer* renderer )
{
m_renderer = renderer;
}
...@@ -46,7 +46,7 @@ class Timeline : public QWidget ...@@ -46,7 +46,7 @@ class Timeline : public QWidget
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY( Timeline ) Q_DISABLE_COPY( Timeline )
public: public:
explicit Timeline( WorkflowRenderer* renderer, QWidget *parent = 0 ); explicit Timeline( QWidget *parent = 0 );
virtual ~Timeline(); virtual ~Timeline();
/// Return a pointer to the TracksView instance. /// Return a pointer to the TracksView instance.
TracksView* tracksView() { return m_tracksView; } TracksView* tracksView() { return m_tracksView; }
...@@ -62,6 +62,7 @@ public: ...@@ -62,6 +62,7 @@ public:
void save( QXmlStreamWriter& project ) const; void save( QXmlStreamWriter& project ) const;
void load( const QDomElement &root ); void load( const QDomElement &root );
void setRenderer( WorkflowRenderer* renderer );
public slots: public slots:
/** /**
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <QUndoStack> #include <QUndoStack>
#include "AutomaticBackup.h" #include "AutomaticBackup.h"
#include "Backend/IBackend.h"
#include "Library/Library.h" #include "Library/Library.h"
#include "Project.h" #include "Project.h"
#include "ProjectCallbacks.h" #include "ProjectCallbacks.h"
...@@ -56,7 +57,7 @@ Project::Project() ...@@ -56,7 +57,7 @@ Project::Project()
m_workflow = new MainWorkflow(); m_workflow = new MainWorkflow();
m_workspace = new Workspace( m_settings ); m_workspace = new Workspace( m_settings );
m_library = new Library( m_workspace ); m_library = new Library( m_workspace );
m_workflowRenderer = new WorkflowRenderer( Backend::getBackend(), m_workflow );
connectComponents(); connectComponents();
} }
...@@ -82,6 +83,12 @@ Project::workflow() ...@@ -82,6 +83,12 @@ Project::workflow()
return m_workflow; return m_workflow;
} }
WorkflowRenderer*
Project::workflowRenderer()
{
return m_workflowRenderer;
}
QUndoStack* QUndoStack*
Project::undoStack() Project::undoStack()
{ {
......
...@@ -42,6 +42,7 @@ class MainWorkflow; ...@@ -42,6 +42,7 @@ class MainWorkflow;
class ProjectManager; class ProjectManager;
class Settings; class Settings;
class Workspace; class Workspace;
class WorkflowRenderer;
class Project : public QObject, public Singleton<Project> class Project : public QObject, public Singleton<Project>
{ {
...@@ -141,9 +142,10 @@ class Project : public QObject, public Singleton<Project> ...@@ -141,9 +142,10 @@ class Project : public QObject, public Singleton<Project>
// Dependent components part below: // Dependent components part below:
public: public:
Library* library(); Library* library();
MainWorkflow* workflow();
QUndoStack* undoStack(); QUndoStack* undoStack();
Settings* settings(); Settings* settings();
MainWorkflow* workflow();
WorkflowRenderer* workflowRenderer();
Workspace* workspace(); Workspace* workspace();
private: private:
...@@ -152,6 +154,7 @@ class Project : public QObject, public Singleton<Project> ...@@ -152,6 +154,7 @@ class Project : public QObject, public Singleton<Project>
QUndoStack* m_undoStack; QUndoStack* m_undoStack;
Settings* m_settings; Settings* m_settings;
Workspace* m_workspace; Workspace* m_workspace;
WorkflowRenderer* m_workflowRenderer;
friend class Singleton<Project>; friend class Singleton<Project>;
}; };
......
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
#include <QTime> #include <QTime>
WorkflowFileRenderer::WorkflowFileRenderer( Backend::IBackend* backend ) WorkflowFileRenderer::WorkflowFileRenderer( Backend::IBackend* backend, MainWorkflow* workflow )
: WorkflowRenderer( backend ) : WorkflowRenderer( backend, workflow )
, m_renderVideoFrame( NULL ) , m_renderVideoFrame( NULL )
{ {
} }
......
...@@ -35,7 +35,7 @@ class WorkflowFileRenderer : public WorkflowRenderer ...@@ -35,7 +35,7 @@ class WorkflowFileRenderer : public WorkflowRenderer
Q_OBJECT Q_OBJECT
public: public:
WorkflowFileRenderer( Backend::IBackend* backend ); WorkflowFileRenderer( Backend::IBackend* backend , MainWorkflow* workflow );
virtual ~WorkflowFileRenderer(); virtual ~WorkflowFileRenderer();
void run(const QString& outputFileName, quint32 width, void run(const QString& outputFileName, quint32 width,
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
#include "Tools/VlmcDebug.h" #include "Tools/VlmcDebug.h"
#include "Workflow/Types.h" #include "Workflow/Types.h"
WorkflowRenderer::WorkflowRenderer( Backend::IBackend* backend ) : WorkflowRenderer::WorkflowRenderer( Backend::IBackend* backend, MainWorkflow* mainWorkflow ) :
m_mainWorkflow( Project::getInstance()->workflow() ), m_mainWorkflow( mainWorkflow ),
m_stopping( false ), m_stopping( false ),
m_outputFps( 0.0f ), m_outputFps( 0.0f ),
m_aspectRatio( "" ), m_aspectRatio( "" ),
...@@ -56,11 +56,6 @@ WorkflowRenderer::WorkflowRenderer( Backend::IBackend* backend ) : ...@@ -56,11 +56,6 @@ WorkflowRenderer::WorkflowRenderer( Backend::IBackend* backend ) :
m_effectFrame( NULL ) m_effectFrame( NULL )
{ {
m_source = backend->createMemorySource(); m_source = backend->createMemorySource();
}
void
WorkflowRenderer::initializeRenderer()
{
m_esHandler = new EsHandler; m_esHandler = new EsHandler;
m_esHandler->self = this; m_esHandler->self = this;
......
...@@ -58,15 +58,9 @@ class WorkflowRenderer : public GenericRenderer ...@@ -58,15 +58,9 @@ class WorkflowRenderer : public GenericRenderer
double fps; ///< The fps to use for this rendering session. double fps; ///< The fps to use for this rendering session.
}; };
WorkflowRenderer( Backend::IBackend *backend ); WorkflowRenderer( Backend::IBackend *backend, MainWorkflow* workflow );
~WorkflowRenderer(); ~WorkflowRenderer();
/**
* \brief Initialize the renderer.
*
* This will set the imem string, instantiate EsHandlers, connect signals.
*/
void initializeRenderer();
/** /**
* \brief Play or pause the media. * \brief Play or pause the media.
* *
......
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