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

Project class is now part of Core, and is no longer a singleton

parent 5c33d274
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "Commands.h" #include "Commands.h"
#include "Project/Project.h" #include "Project/Project.h"
#include "Main/Core.h"
#include "Media/Clip.h" #include "Media/Clip.h"
#include "Workflow/ClipHelper.h" #include "Workflow/ClipHelper.h"
#include "EffectsEngine/EffectHelper.h" #include "EffectsEngine/EffectHelper.h"
...@@ -34,7 +35,7 @@ ...@@ -34,7 +35,7 @@
void void
Commands::trigger( QUndoCommand* command ) Commands::trigger( QUndoCommand* command )
{ {
Project::getInstance()->undoStack()->push( command ); Core::getInstance()->currentProject()->undoStack()->push( command );
} }
Commands::Generic::Generic() : Commands::Generic::Generic() :
...@@ -42,7 +43,7 @@ Commands::Generic::Generic() : ...@@ -42,7 +43,7 @@ Commands::Generic::Generic() :
{ {
//This is connected using a direct connection to ensure the view can be refreshed //This is connected using a direct connection to ensure the view can be refreshed
//just after the signal has been emited. //just after the signal has been emited.
connect( Project::getInstance()->undoStack(), SIGNAL( retranslateRequired() ), connect( Core::getInstance()->currentProject()->undoStack(), SIGNAL( retranslateRequired() ),
this, SLOT( retranslate() ), Qt::DirectConnection ); this, SLOT( retranslate() ), Qt::DirectConnection );
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "EffectsEngine/EffectHelper.h" #include "EffectsEngine/EffectHelper.h"
#include "EffectsEngine/EffectUser.h" #include "EffectsEngine/EffectUser.h"
#include "Main/Core.h"
#include "Project/Project.h" #include "Project/Project.h"
#include "Workflow/MainWorkflow.h" #include "Workflow/MainWorkflow.h"
...@@ -31,8 +32,8 @@ EffectHelper::EffectHelper( EffectInstance *effectInstance, qint64 begin, qint64 ...@@ -31,8 +32,8 @@ EffectHelper::EffectHelper( EffectInstance *effectInstance, qint64 begin, qint64
m_effectInstance( effectInstance ), m_effectInstance( effectInstance ),
m_target( NULL ) m_target( NULL )
{ {
if ( Project::getInstance()->workflow()->getLengthFrame() > 0 ) if ( Core::getInstance()->currentProject()->workflow()->getLengthFrame() > 0 )
m_end = Project::getInstance()->workflow()->getLengthFrame(); m_end = Core::getInstance()->currentProject()->workflow()->getLengthFrame();
else else
m_end = Effect::TrackEffectDefaultLength; m_end = Effect::TrackEffectDefaultLength;
} }
......
...@@ -318,13 +318,13 @@ MainWindow::initVlmcPreferences() ...@@ -318,13 +318,13 @@ MainWindow::initVlmcPreferences()
void void
MainWindow::on_actionSave_triggered() MainWindow::on_actionSave_triggered()
{ {
Project::getInstance()->save(); Core::getInstance()->currentProject()->save();
} }
void void
MainWindow::on_actionSave_As_triggered() MainWindow::on_actionSave_As_triggered()
{ {
Project::getInstance()->saveAs(); Core::getInstance()->currentProject()->saveAs();
} }
void void
...@@ -335,7 +335,7 @@ MainWindow::on_actionLoad_Project_triggered() ...@@ -335,7 +335,7 @@ MainWindow::on_actionLoad_Project_triggered()
"", tr( "VLMC project file(*.vlmc)" ) ); "", tr( "VLMC project file(*.vlmc)" ) );
if ( fileName.isEmpty() == true ) if ( fileName.isEmpty() == true )
return ; return ;
Project::load( fileName ); Core::getInstance()->loadProject( fileName );
} }
void void
...@@ -517,7 +517,7 @@ void ...@@ -517,7 +517,7 @@ void
MainWindow::createProjectPreferences() MainWindow::createProjectPreferences()
{ {
delete m_projectPreferences; delete m_projectPreferences;
m_projectPreferences = new SettingsDialog( Project::getInstance()->settings(), tr( "Project preferences" ), this ); m_projectPreferences = new SettingsDialog( Core::getInstance()->currentProject()->settings(), tr( "Project preferences" ), this );
m_projectPreferences->addCategory( "general", QT_TRANSLATE_NOOP( "Settings", "General" ), QIcon( ":/images/vlmc" ) ); m_projectPreferences->addCategory( "general", QT_TRANSLATE_NOOP( "Settings", "General" ), QIcon( ":/images/vlmc" ) );
m_projectPreferences->addCategory( "video", QT_TRANSLATE_NOOP( "Settings", "Video" ), QIcon( ":/images/video" ) ); m_projectPreferences->addCategory( "video", QT_TRANSLATE_NOOP( "Settings", "Video" ), QIcon( ":/images/video" ) );
m_projectPreferences->addCategory( "audio", QT_TRANSLATE_NOOP( "Settings", "Audio" ), QIcon( ":/images/audio" ) ); m_projectPreferences->addCategory( "audio", QT_TRANSLATE_NOOP( "Settings", "Audio" ), QIcon( ":/images/audio" ) );
...@@ -567,7 +567,7 @@ MainWindow::on_actionAbout_triggered() ...@@ -567,7 +567,7 @@ MainWindow::on_actionAbout_triggered()
bool bool
MainWindow::checkVideoLength() MainWindow::checkVideoLength()
{ {
if ( Project::getInstance()->workflow()->getLengthFrame() <= 0 ) if ( Core::getInstance()->currentProject()->workflow()->getLengthFrame() <= 0 )
{ {
QMessageBox::warning( NULL, tr ( "VLMC Renderer" ), tr( "There is nothing to render." ) ); QMessageBox::warning( NULL, tr ( "VLMC Renderer" ), tr( "There is nothing to render." ) );
return false; return false;
...@@ -580,7 +580,7 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h ...@@ -580,7 +580,7 @@ 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, Project::getInstance()->workflow() ); m_fileRenderer = new WorkflowFileRenderer( m_backend, Core::getInstance()->currentProject()->workflow() );
WorkflowFileRendererDialog *dialog = new WorkflowFileRendererDialog( m_fileRenderer, width, height ); WorkflowFileRendererDialog *dialog = new WorkflowFileRendererDialog( m_fileRenderer, width, height );
dialog->setModal( true ); dialog->setModal( true );
...@@ -601,7 +601,7 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h ...@@ -601,7 +601,7 @@ MainWindow::renderVideo( const QString& outputFileName, quint32 width, quint32 h
bool bool
MainWindow::renderVideoSettings( bool shareOnInternet ) MainWindow::renderVideoSettings( bool shareOnInternet )
{ {
Project::getInstance()->workflowRenderer()->stop(); Core::getInstance()->currentProject()->workflowRenderer()->stop();
RendererSettings *settings = new RendererSettings( shareOnInternet ); RendererSettings *settings = new RendererSettings( shareOnInternet );
...@@ -736,7 +736,7 @@ MainWindow::saveSettings() ...@@ -736,7 +736,7 @@ MainWindow::saveSettings()
settings->setValue( "private/MainWindowState", saveState() ); settings->setValue( "private/MainWindowState", saveState() );
settings->setValue( "private/CleanQuit", true ); settings->setValue( "private/CleanQuit", true );
settings->save(); settings->save();
Project::getInstance()->save(); Core::getInstance()->currentProject()->save();
return true; return true;
} }
...@@ -772,13 +772,13 @@ MainWindow::cleanStateChanged( bool isClean ) ...@@ -772,13 +772,13 @@ MainWindow::cleanStateChanged( bool isClean )
void void
MainWindow::on_actionUndo_triggered() MainWindow::on_actionUndo_triggered()
{ {
Project::getInstance()->undoStack()->undo(); Core::getInstance()->currentProject()->undoStack()->undo();
} }
void void
MainWindow::on_actionRedo_triggered() MainWindow::on_actionRedo_triggered()
{ {
Project::getInstance()->undoStack()->redo(); Core::getInstance()->currentProject()->undoStack()->redo();
} }
void void
...@@ -803,7 +803,7 @@ MainWindow::restoreSession() ...@@ -803,7 +803,7 @@ MainWindow::restoreSession()
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ); QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
if ( res == QMessageBox::Yes ) if ( res == QMessageBox::Yes )
{ {
if ( Project::getInstance()->loadEmergencyBackup() == true ) if ( Core::getInstance()->restoreProject() == true )
ret = true; ret = true;
else else
QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We apology for the inconvenience" ) ); QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We apology for the inconvenience" ) );
......
...@@ -101,7 +101,7 @@ private: ...@@ -101,7 +101,7 @@ private:
/** /**
* \brief Will check if there is any video on the Project Timeline. * \brief Will check if there is any video on the Project Timeline.
* \return true, if ( Project::getInstance()->workflow()->getLengthFrame() > 0 ) * \return true, if ( Core::getInstance()->currentProject()->workflow()->getLengthFrame() > 0 )
* else false * else false
*/ */
bool checkVideoLength(); bool checkVideoLength();
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "WorkflowFileRendererDialog.h" #include "WorkflowFileRendererDialog.h"
#include "Main/Core.h"
#include "Project/Project.h" #include "Project/Project.h"
#include "vlmc.h" #include "vlmc.h"
#include "Workflow/MainWorkflow.h" #include "Workflow/MainWorkflow.h"
...@@ -68,7 +69,7 @@ WorkflowFileRendererDialog::updatePreview( const uchar* buff ) ...@@ -68,7 +69,7 @@ WorkflowFileRendererDialog::updatePreview( const uchar* buff )
void void
WorkflowFileRendererDialog::frameChanged( qint64 frame ) WorkflowFileRendererDialog::frameChanged( qint64 frame )
{ {
qint64 totalFrames = Project::getInstance()->workflow()->getLengthFrame(); qint64 totalFrames = Core::getInstance()->currentProject()->workflow()->getLengthFrame();
if ( frame <= totalFrames ) if ( frame <= totalFrames )
{ {
......
...@@ -157,7 +157,7 @@ void ...@@ -157,7 +157,7 @@ void
ImportController::importMedia( const QString &filePath ) ImportController::importMedia( const QString &filePath )
{ {
vlmcDebug() << "Importing" << filePath; vlmcDebug() << "Importing" << filePath;
if ( Project::getInstance()->library()->mediaAlreadyLoaded( filePath ) == true || if ( Core::getInstance()->currentProject()->library()->mediaAlreadyLoaded( filePath ) == true ||
m_temporaryMedias->mediaAlreadyLoaded( filePath ) == true ) m_temporaryMedias->mediaAlreadyLoaded( filePath ) == true )
return ; return ;
...@@ -242,7 +242,7 @@ ImportController::accept() ...@@ -242,7 +242,7 @@ ImportController::accept()
{ {
if ( clip->getMedia()->source()->length() == 0 ) if ( clip->getMedia()->source()->length() == 0 )
invalidMedias = true; invalidMedias = true;
Project::getInstance()->library()->addClip( clip ); Core::getInstance()->currentProject()->library()->addClip( clip );
} }
if ( invalidMedias == true ) if ( invalidMedias == true )
handleInvalidMedias(); handleInvalidMedias();
......
...@@ -230,7 +230,7 @@ MediaCellView::mouseMoveEvent( QMouseEvent* event ) ...@@ -230,7 +230,7 @@ MediaCellView::mouseMoveEvent( QMouseEvent* event )
void void
MediaCellView::deleteButtonClicked( QWidget*, QMouseEvent* ) MediaCellView::deleteButtonClicked( QWidget*, QMouseEvent* )
{ {
if ( Project::getInstance()->workflow()->contains( m_clip->uuid() ) == true ) if ( Core::getInstance()->currentProject()->workflow()->contains( m_clip->uuid() ) == true )
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText( tr( "This clip or some of its children are contained in the timeline." ) ); msgBox.setText( tr( "This clip or some of its children are contained in the timeline." ) );
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "Project/Project.h" #include "Project/Project.h"
#include "Media/Clip.h" #include "Media/Clip.h"
#include "Library/Library.h" #include "Library/Library.h"
#include "Main/Core.h"
#include "Media/Media.h" #include "Media/Media.h"
#include "MediaCellView.h" #include "MediaCellView.h"
#include "MediaListView.h" #include "MediaListView.h"
...@@ -166,7 +167,7 @@ MediaLibrary::dropEvent( QDropEvent *event ) ...@@ -166,7 +167,7 @@ MediaLibrary::dropEvent( QDropEvent *event )
return; return;
} }
Q_ASSERT( Project::getInstance()->library() != NULL ); Q_ASSERT( Core::getInstance()->currentProject()->library() != NULL );
foreach ( const QUrl &url, fileList ) foreach ( const QUrl &url, fileList )
{ {
...@@ -175,13 +176,13 @@ MediaLibrary::dropEvent( QDropEvent *event ) ...@@ -175,13 +176,13 @@ MediaLibrary::dropEvent( QDropEvent *event )
if ( fileName.isEmpty() ) if ( fileName.isEmpty() )
continue; continue;
Media *media = Project::getInstance()->library()->addMedia( fileName ); Media *media = Core::getInstance()->currentProject()->library()->addMedia( fileName );
if ( media != NULL ) if ( media != NULL )
{ {
Clip* clip = new Clip( media ); Clip* clip = new Clip( media );
media->setBaseClip( clip ); media->setBaseClip( clip );
Project::getInstance()->library()->addClip( clip ); Core::getInstance()->currentProject()->library()->addClip( clip );
event->accept(); event->accept();
} }
else else
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QList> #include <QList>
#include "Main/Core.h"
#include "Project/Project.h" #include "Project/Project.h"
#include "TracksView.h" #include "TracksView.h"
#include "GraphicsTrack.h" #include "GraphicsTrack.h"
...@@ -35,7 +36,7 @@ GraphicsTrack::GraphicsTrack( Workflow::TrackType type, quint32 trackNumber, ...@@ -35,7 +36,7 @@ GraphicsTrack::GraphicsTrack( Workflow::TrackType type, quint32 trackNumber,
m_type = type; m_type = type;
m_trackNumber = trackNumber; m_trackNumber = trackNumber;
m_enabled = true; m_enabled = true;
m_trackWorkflow = Project::getInstance()->workflow()->track( type, trackNumber ); m_trackWorkflow = Core::getInstance()->currentProject()->workflow()->track( type, trackNumber );
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
setContentsMargins( 0, 0, 0, 0 ); setContentsMargins( 0, 0, 0, 0 );
...@@ -64,9 +65,9 @@ GraphicsTrack::setTrackEnabled( bool enabled ) ...@@ -64,9 +65,9 @@ GraphicsTrack::setTrackEnabled( bool enabled )
m_enabled = enabled; m_enabled = enabled;
if( enabled ) if( enabled )
Project::getInstance()->workflow()->unmuteTrack( m_trackNumber, m_type ); Core::getInstance()->currentProject()->workflow()->unmuteTrack( m_trackNumber, m_type );
else else
Project::getInstance()->workflow()->muteTrack( m_trackNumber, m_type ); Core::getInstance()->currentProject()->workflow()->muteTrack( m_trackNumber, m_type );
} }
bool bool
......
...@@ -105,7 +105,7 @@ TracksScene::askRemoveSelectedItems() ...@@ -105,7 +105,7 @@ TracksScene::askRemoveSelectedItems()
} }
} }
Project::getInstance()->undoStack()->beginMacro( "Remove clip(s)" ); Core::getInstance()->currentProject()->undoStack()->beginMacro( "Remove clip(s)" );
QList<QGraphicsItem*> items = selectedItems(); QList<QGraphicsItem*> items = selectedItems();
for (int i = 0; i < items.size(); ++i ) for (int i = 0; i < items.size(); ++i )
...@@ -132,5 +132,5 @@ TracksScene::askRemoveSelectedItems() ...@@ -132,5 +132,5 @@ TracksScene::askRemoveSelectedItems()
} }
} }
Project::getInstance()->undoStack()->endMacro(); Core::getInstance()->currentProject()->undoStack()->endMacro();
} }
...@@ -375,7 +375,7 @@ void ...@@ -375,7 +375,7 @@ void
TracksView::clipDragEnterEvent( QDragEnterEvent *event ) TracksView::clipDragEnterEvent( QDragEnterEvent *event )
{ {
const QString fullId = QString( event->mimeData()->data( "vlmc/uuid" ) ); const QString fullId = QString( event->mimeData()->data( "vlmc/uuid" ) );
Clip *clip = Project::getInstance()->library()->clip( fullId ); Clip *clip = Core::getInstance()->currentProject()->library()->clip( fullId );
if ( clip == NULL ) if ( clip == NULL )
return; return;
bool hasVideo = clip->getMedia()->source()->hasVideo(); bool hasVideo = clip->getMedia()->source()->hasVideo();
...@@ -799,7 +799,7 @@ TracksView::dropEvent( QDropEvent *event ) ...@@ -799,7 +799,7 @@ TracksView::dropEvent( QDropEvent *event )
if ( m_dragAudioItem != NULL || m_dragVideoItem != NULL ) if ( m_dragAudioItem != NULL || m_dragVideoItem != NULL )
{ {
Project::getInstance()->undoStack()->beginMacro( "Add clip" ); Core::getInstance()->currentProject()->undoStack()->beginMacro( "Add clip" );
if ( m_dragAudioItem ) if ( m_dragAudioItem )
{ {
...@@ -835,7 +835,7 @@ TracksView::dropEvent( QDropEvent *event ) ...@@ -835,7 +835,7 @@ TracksView::dropEvent( QDropEvent *event )
m_dragVideoItem = NULL; m_dragVideoItem = NULL;
} }
Project::getInstance()->undoStack()->endMacro(); Core::getInstance()->currentProject()->undoStack()->endMacro();
m_lastKnownTrack = NULL; m_lastKnownTrack = NULL;
} }
...@@ -1183,7 +1183,7 @@ TracksView::mouseReleaseEvent( QMouseEvent *event ) ...@@ -1183,7 +1183,7 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
} }
} }
else else
Project::getInstance()->undoStack()->beginMacro( "Move clip" ); Core::getInstance()->currentProject()->undoStack()->beginMacro( "Move clip" );
m_actionItem->triggerMove( target, targetPos ); m_actionItem->triggerMove( target, targetPos );
// Update the linked item too // Update the linked item too
if ( m_actionItem->groupItem() ) if ( m_actionItem->groupItem() )
...@@ -1194,7 +1194,7 @@ TracksView::mouseReleaseEvent( QMouseEvent *event ) ...@@ -1194,7 +1194,7 @@ TracksView::mouseReleaseEvent( QMouseEvent *event )
} }
if ( effectItem == NULL ) if ( effectItem == NULL )
Project::getInstance()->undoStack()->endMacro(); Core::getInstance()->currentProject()->undoStack()->endMacro();
m_actionItem->m_oldTrack = m_actionItem->track()->trackWorkflow(); m_actionItem->m_oldTrack = m_actionItem->track()->trackWorkflow();
m_actionRelativeX = -1; m_actionRelativeX = -1;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include "Main/Core.h"
#include "OpenPage.h" #include "OpenPage.h"
#include "project/GuiProjectManager.h" #include "project/GuiProjectManager.h"
#include "ProjectWizard.h" #include "ProjectWizard.h"
...@@ -54,7 +55,7 @@ bool ...@@ -54,7 +55,7 @@ bool
OpenPage::validatePage() OpenPage::validatePage()
{ {
if ( WelcomePage::projectPath().isEmpty() == false ) if ( WelcomePage::projectPath().isEmpty() == false )
return Project::load( WelcomePage::projectPath() ); return Core::getInstance()->loadProject( WelcomePage::projectPath() );
return false; return false;
} }
......
...@@ -101,8 +101,8 @@ ProjectWizard::accept() ...@@ -101,8 +101,8 @@ ProjectWizard::accept()
{ {
Settings* preferences = Core::getInstance()->settings(); Settings* preferences = Core::getInstance()->settings();
Project::create( field( "projectName" ).toString(), field( "projectPath" ).toString() ); Core::getInstance()->newProject( field( "projectName" ).toString(), field( "projectPath" ).toString() );
Settings* projectPreferences = Project::getInstance()->settings(); Settings* projectPreferences = Core::getInstance()->currentProject()->settings();
preferences->setValue( "vlmc/DefaultProjectLocation", field( "workspace" ) ); preferences->setValue( "vlmc/DefaultProjectLocation", field( "workspace" ) );
...@@ -119,7 +119,7 @@ ProjectWizard::accept() ...@@ -119,7 +119,7 @@ ProjectWizard::accept()
void void
ProjectWizard::reject() ProjectWizard::reject()
{ {
if ( Project::isProjectLoaded() ) if ( Core::getInstance()->isProjectLoaded() == true )
return QWizard::reject(); return QWizard::reject();
qApp->quit(); qApp->quit();
} }
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "Project/Workspace.h" #include "Project/Workspace.h"
Core::Core() Core::Core()
: m_currentProject( NULL )
{ {
m_backend = Backend::getBackend(); m_backend = Backend::getBackend();
m_effectsEngine = new EffectsEngine; m_effectsEngine = new EffectsEngine;
...@@ -60,6 +61,7 @@ Core::Core() ...@@ -60,6 +61,7 @@ Core::Core()
Core::~Core() Core::~Core()
{ {
delete m_currentProject;
delete m_workspace; delete m_workspace;
delete m_automaticBackup; delete m_automaticBackup;
delete m_settings; delete m_settings;
...@@ -98,13 +100,49 @@ Core::automaticBackup() ...@@ -98,13 +100,49 @@ Core::automaticBackup()
return m_automaticBackup; return m_automaticBackup;
} }
void bool
Core::onProjectLoaded( Project* project ) Core::loadProject(const QString& fileName)
{ {
m_automaticBackup->setProject( project ); if ( fileName.isEmpty() == true )
m_recentProjects->setProject( project ); return false;
QFile* projectFile = new QFile( fileName );
if ( projectFile->exists() == false )
return false;
//FIXME: What if the project was unsaved, and the user wants to cancel the operation?
delete m_currentProject;
//FIXME: Doesn't check for proper project loading
m_currentProject = new Project( projectFile );
m_automaticBackup->setProject( m_currentProject );
m_recentProjects->setProject( m_currentProject );
emit projectLoading( m_currentProject );
return true;
}
bool Core::newProject(const QString& projectName, const QString& projectPath)
{
delete m_currentProject;
//FIXME: Doesn't check for proper project creation
m_currentProject = new Project( projectName, projectPath );
return true;
}
emit projectLoading( project ); bool
Core::restoreProject()
{
//FIXME: This doesn't make sense when no GUI is attached, so I'm not sure it fits in the Core class.
Q_ASSERT( m_currentProject == NULL );
QFile* backupFile = Project::emergencyBackupFile();
if ( backupFile == NULL )
return false;
//FIXME: This lacks error handling
m_currentProject = new Project( backupFile );
return true;
}
bool Core::isProjectLoaded()
{
return m_currentProject != NULL;
} }
Settings* Settings*
...@@ -119,3 +157,8 @@ Core::workspace() ...@@ -119,3 +157,8 @@ Core::workspace()
{ {
return m_workspace; return m_workspace;
} }
Project* Core::currentProject()
{
return m_currentProject;
}
...@@ -53,8 +53,12 @@ class Core : public QObject, public Singleton<Core> ...@@ -53,8 +53,12 @@ class Core : public QObject, public Singleton<Core>
RecentProjects* recentProjects(); RecentProjects* recentProjects();
AutomaticBackup* automaticBackup(); AutomaticBackup* automaticBackup();
Workspace* workspace(); Workspace* workspace();
Project* currentProject();
void onProjectLoaded( Project* project ); bool loadProject( const QString& fileName );
bool newProject( const QString& projectName, const QString& projectPath );
bool restoreProject();
bool isProjectLoaded();
signals: signals:
/** /**
...@@ -77,6 +81,7 @@ class Core : public QObject, public Singleton<Core> ...@@ -77,6 +81,7 @@ class Core : public QObject, public Singleton<Core>
RecentProjects* m_recentProjects; RecentProjects* m_recentProjects;
AutomaticBackup* m_automaticBackup; AutomaticBackup* m_automaticBackup;
Workspace* m_workspace; Workspace* m_workspace;
Project* m_currentProject;
friend class Singleton<Core>; friend class Singleton<Core>;
}; };
......
...@@ -96,7 +96,7 @@ VLMCGuimain( int argc, char **argv ) ...@@ -96,7 +96,7 @@ VLMCGuimain( int argc, char **argv )
if ( argc > ( i + 1 ) && ( arg == "--project" || arg == "-p" ) ) if ( argc > ( i + 1 ) && ( arg == "--project" || arg == "-p" ) )
{ {
Project::load( argv[i+1] ); Core::getInstance()->loadProject( argv[i+1] );
project = true; project = true;
break; break;
} }
...@@ -183,7 +183,7 @@ VLMCCoremain( int argc, char **argv ) ...@@ -183,7 +183,7 @@ VLMCCoremain( int argc, char **argv )
#ifndef WITH_GUI #ifndef WITH_GUI
ConsoleRenderer renderer; ConsoleRenderer renderer;
ProjectManager *pm = Project::getInstance(); ProjectManager *pm = Core::getInstance()->currentProject();
QCoreApplication::connect( pm, SIGNAL( projectLoaded() ), &renderer, SLOT( startRender() ) ); QCoreApplication::connect( pm, SIGNAL( projectLoaded() ), &renderer, SLOT( startRender() ) );
pm->loadProject( app.arguments()[1] ); pm->loadProject( app.arguments()[1] );
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "config.h" #include "config.h"
#include "Main/Core.h"
#include "Workflow/Types.h" #include "Workflow/Types.h"
#include "Tools/VlmcDebug.h" #include "Tools/VlmcDebug.h"
#include "Project/Project.h" #include "Project/Project.h"
...@@ -52,7 +53,7 @@ signalHandler( int sig ) ...@@ -52,7 +53,7 @@ signalHandler( int sig )
{ {
signal( sig, SIG_DFL ); signal( sig, SIG_DFL );
Project::getInstance()->emergencyBackup(); Core::getInstance()->currentProject()->emergencyBackup();
#ifdef WITH_CRASHHANDLER_GUI #ifdef WITH_CRASHHANDLER_GUI
CrashHandler* ch = new CrashHandler( sig ); CrashHandler* ch = new CrashHandler( sig );
......
...@@ -46,12 +46,15 @@ ...@@ -46,12 +46,15 @@
const QString Project::unNamedProject = Project::tr( "Untitled Project" ); const QString Project::unNamedProject = Project::tr( "Untitled Project" );
const QString Project::backupSuffix = "~"; const QString Project::backupSuffix = "~";
Project::Project() Project::Project( QFile* projectFile )
: m_projectFile( NULL ) : m_projectFile( projectFile )
, m_isClean( true ) , m_isClean( true )
, m_libraryCleanState( true ) , m_libraryCleanState( true )