[vlmc-devel] Project: Instantiate & connect RecentProjects & AutomaticBackup when loading/ creating a project
Hugo Beauzée-Luyssen
git at videolan.org
Mon Mar 31 17:59:21 CEST 2014
vlmc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Mar 31 02:48:40 2014 +0300| [f181c7e86f36d4f76c226262139e200e444f52fe] | committer: Hugo Beauzée-Luyssen
Project: Instantiate & connect RecentProjects & AutomaticBackup when loading/creating a project
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=f181c7e86f36d4f76c226262139e200e444f52fe
---
src/Main/Core.cpp | 9 +++++++++
src/Main/Core.h | 3 +++
src/Project/AutomaticBackup.cpp | 2 ++
src/Project/Project.cpp | 17 +++++++++++++----
src/Project/Project.h | 1 +
5 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/src/Main/Core.cpp b/src/Main/Core.cpp
index c6068e0..86a6641 100644
--- a/src/Main/Core.cpp
+++ b/src/Main/Core.cpp
@@ -35,6 +35,7 @@
#include <EffectsEngine/EffectsEngine.h>
#include <Settings/Settings.h>
#include <Tools/VlmcLogger.h>
+#include "Project/AutomaticBackup.h"
#include "Project/RecentProjects.h"
Core::Core()
@@ -52,10 +53,12 @@ Core::Core()
+ QDir::separator() + qApp->applicationName() + ".conf";
m_settings = new Settings( configPath );
m_recentProjects = new RecentProjects( m_settings );
+ m_automaticBackup = new AutomaticBackup( m_settings );
}
Core::~Core()
{
+ delete m_automaticBackup;
delete m_settings;
delete m_logger;
delete m_effectsEngine;
@@ -86,6 +89,12 @@ Core::recentProjects()
return m_recentProjects;
}
+AutomaticBackup*
+Core::automaticBackup()
+{
+ return m_automaticBackup;
+}
+
Settings*
Core::settings()
{
diff --git a/src/Main/Core.h b/src/Main/Core.h
index 9b77dab..4cabb67 100644
--- a/src/Main/Core.h
+++ b/src/Main/Core.h
@@ -23,6 +23,7 @@
#ifndef CORE_H
#define CORE_H
+class AutomaticBackup;
class EffectsEngine;
class NotificationZone;
class RecentProjects;
@@ -44,6 +45,7 @@ class Core : public Singleton<Core>
Settings* settings();
VlmcLogger* logger();
RecentProjects* recentProjects();
+ AutomaticBackup* automaticBackup();
private:
Core();
@@ -53,6 +55,7 @@ class Core : public Singleton<Core>
Settings* m_settings;
VlmcLogger* m_logger;
RecentProjects* m_recentProjects;
+ AutomaticBackup* m_automaticBackup;
friend class Singleton<Core>;
};
diff --git a/src/Project/AutomaticBackup.cpp b/src/Project/AutomaticBackup.cpp
index 67ed2d0..bc6f8f4 100644
--- a/src/Project/AutomaticBackup.cpp
+++ b/src/Project/AutomaticBackup.cpp
@@ -55,6 +55,8 @@ AutomaticBackup::setProject( Project* projectManager )
{
m_timer->disconnect();
connect( m_timer, SIGNAL( timeout() ), projectManager, SLOT(autoSaveRequired() ) );
+ connect( projectManager, SIGNAL( destroyed() ), m_timer, SLOT( stop() ) );
+ m_timer->start();
}
void
diff --git a/src/Project/Project.cpp b/src/Project/Project.cpp
index a654baa..e553d2e 100644
--- a/src/Project/Project.cpp
+++ b/src/Project/Project.cpp
@@ -26,11 +26,13 @@
#include <QFileInfo>
#include <QUndoStack>
+#include "AutomaticBackup.h"
#include "Library/Library.h"
-#include "Workflow/MainWorkflow.h"
-#include "Project/Project.h"
-#include "Project/Workspace.h"
+#include "Project.h"
+#include "RecentProjects.h"
#include "Settings/Settings.h"
+#include "Workflow/MainWorkflow.h"
+#include "Workspace.h"
#include "Tools/VlmcDebug.h"
@@ -100,7 +102,7 @@ Project::workspace()
//////////////////////////////////////////////////////////////////////////////////////////
bool
-Project::load(const QString& fileName )
+Project::load( const QString& fileName )
{
Project* self = getInstance();
if ( fileName.isEmpty() == true )
@@ -117,6 +119,8 @@ Project::load(const QString& fileName )
self->loadProject( fileName );
self->connectComponents();
+ Core::getInstance()->automaticBackup()->setProject( self );
+ Core::getInstance()->recentProjects()->setProject( self );
return true;
}
@@ -129,6 +133,11 @@ Project::create(const QString& projectName, const QString& projectPath )
Project::destroyInstance();
self = Project::getInstance();
self->newProject( projectName, projectPath );
+
+ self->connectComponents();
+ Core::getInstance()->automaticBackup()->setProject( self );
+ Core::getInstance()->recentProjects()->setProject( self );
+
return true;
}
diff --git a/src/Project/Project.h b/src/Project/Project.h
index 78fa48f..83b9fbc 100644
--- a/src/Project/Project.h
+++ b/src/Project/Project.h
@@ -35,6 +35,7 @@ class QString;
class QUndoStack;
class QXmlStreamWriter;
+class AutomaticBackup;
class Library;
class MainWorkflow;
class ProjectManager;
More information about the Vlmc-devel
mailing list