Commit ef64c99e authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Implemented autosave backend.

Not functionnal yet, it only calls the method as required in the
config.
parent d3cca047
......@@ -66,6 +66,7 @@ MainWindow::MainWindow( QWidget *parent ) :
qRegisterMetaType<MainWorkflow::TrackType>( "MainWorkflow::TrackType" );
qRegisterMetaType<MainWorkflow::FrameChangedReason>( "MainWorkflow::FrameChangedReason" );
qRegisterMetaType<QVariant>( "QVariant" );
// Settings
VLMCSettingsDefault::load( "default" );
......
......@@ -78,4 +78,5 @@ void VLMCPreferences::save()
settMan->setValue( m_settName, "VLMCTracksNb", tracksNb );
settMan->setValue( m_settName, "AutomaticBackup", autoSave );
settMan->setValue( m_settName, "AutomaticBackupInterval", autoSaveInterval );
settMan->commit();
}
......@@ -52,15 +52,27 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
{
QSettings s;
m_recentsProjects = s.value( "RecentsProjects" ).toStringList();
connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) );
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
const SettingValue* val = SettingsManager::getInstance()->getValue( "project", "ProjectName");
connect( val, SIGNAL( changed( QVariant) ), this, SLOT(nameChanged(QVariant) ) );
m_projectName = tr( "<Unsaved project>" );
signal( SIGSEGV, ProjectManager::signalHandler );
signal( SIGFPE, ProjectManager::signalHandler );
signal( SIGABRT, ProjectManager::signalHandler );
signal( SIGILL, ProjectManager::signalHandler );
connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) );
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
const SettingValue* val = SettingsManager::getInstance()->getValue( "project", "ProjectName");
connect( val, SIGNAL( changed( QVariant) ), this, SLOT(nameChanged(QVariant) ) );
//Automatic save part :
m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( autoSaveRequired() ) );
const SettingValue* autoSaveEnabled = SettingsManager::getInstance()->getValue( "VLMC", "AutomaticBackup" );
connect( autoSaveEnabled, SIGNAL( changed( QVariant ) ), this, SLOT( automaticSaveEnabledChanged( QVariant ) ), Qt::QueuedConnection );
const SettingValue* autoSaveInterval = SettingsManager::getInstance()->getValue( "VLMC", "AutomaticBackupInterval" );
connect( autoSaveInterval, SIGNAL( changed( QVariant ) ), this, SLOT( automaticSaveIntervalChanged(QVariant) ), Qt::QueuedConnection );
automaticSaveEnabledChanged( autoSaveEnabled->get() );
}
ProjectManager::~ProjectManager()
......@@ -309,3 +321,30 @@ void ProjectManager::appendToRecentProject( const QString& projectFile )
s.setValue( "RecentsProjects", m_recentsProjects );
s.sync();
}
void ProjectManager::automaticSaveEnabledChanged( const QVariant& val )
{
bool enabled = val.toBool();
if ( enabled == true )
{
const SettingValue* interval = SettingsManager::getInstance()->getValue( "VLMC", "AutomaticBackupInterval" );
m_timer->start( interval->get().toInt() * 1000 /** 60*/ );
}
else
m_timer->stop();
}
void ProjectManager::automaticSaveIntervalChanged( const QVariant& val )
{
const SettingValue* enabled = SettingsManager::getInstance()->getValue( "VLMC", "AutomaticBackup" );
if ( enabled->get().toBool() == false )
return ;
m_timer->start( val.toInt() * 1000 /** 60*/ );
}
void ProjectManager::autoSaveRequired()
{
qWarning() << "Autosave required";
}
......@@ -27,6 +27,7 @@
#include <QObject>
#include <QDomDocument>
#include <QStringList>
#include <QTimer>
#include "Singleton.hpp"
......@@ -72,6 +73,7 @@ private:
QStringList m_recentsProjects;
QString m_projectName;
QString m_projectDescription;
QTimer* m_timer;
friend class Singleton<ProjectManager>;
......@@ -79,6 +81,9 @@ private slots:
void loadTimeline();
void cleanChanged( bool val );
void nameChanged( const QVariant& name );
void automaticSaveEnabledChanged( const QVariant& enabled );
void automaticSaveIntervalChanged( const QVariant& interval );
void autoSaveRequired();
signals:
/**
......
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