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

ProjectManager: Don't overwrite the project file when autosaving.

Fixes #88
parent 28fa777a
......@@ -122,13 +122,13 @@ GUIProjectManager::createNewProjectFile( bool saveAs )
}
void
GUIProjectManager::saveProject( bool saveAs /*= true*/ )
GUIProjectManager::saveProject( bool saveAs /* = false */ )
{
//If the project is still unsaved, or if we want to
//save the project with a new name
if ( createNewProjectFile( saveAs ) == false )
return ;
ProjectManager::saveProject( saveAs );
ProjectManager::saveProject( outputFileName() );
}
bool
......@@ -154,7 +154,7 @@ GUIProjectManager::autoSaveRequired()
{
if ( m_projectFile == NULL )
return ;
saveProject( false );
ProjectManager::__saveProject( createAutoSaveOutputFileName() );
}
void
......@@ -219,3 +219,9 @@ GUIProjectManager::loadTimeline( const QDomElement &root )
{
Timeline::getInstance()->load( root );
}
QString
GUIProjectManager::createAutoSaveOutputFileName() const
{
return m_projectFile->fileName() + "~";
}
......@@ -42,6 +42,9 @@ public:
* \return The project to load.
*/
QString acquireProjectFileName();
/**
* \brief Save the project using the current project file.
*/
void saveProject( bool saveAs = false );
/**
* \brief Ask the project manager to close current project.
......@@ -60,6 +63,7 @@ protected:
private:
bool createNewProjectFile( bool saveAs );
QString createAutoSaveOutputFileName() const;
private:
QTimer* m_timer;
......
......@@ -223,9 +223,9 @@ ProjectManager::closeProject()
}
void
ProjectManager::saveProject( bool )
ProjectManager::saveProject( const QString &outputFileName )
{
__saveProject( m_projectFile->fileName() );
__saveProject( outputFileName );
emit projectSaved();
emit projectUpdated( projectName(), true );
}
......@@ -251,3 +251,9 @@ ProjectManager::failedToLoad( const QString &reason ) const
qCritical() << tr( "Failed to load the project file: %1. Aborting." ).arg( reason );
abort();
}
QString
ProjectManager::outputFileName() const
{
return m_projectFile->fileName();
}
......@@ -49,7 +49,7 @@ public:
void loadProject( const QString& fileName );
QStringList recentsProjects() const;
virtual bool closeProject();
virtual void saveProject( bool saveAs = false );
virtual void saveProject( const QString &outputFileName );
bool loadEmergencyBackup();
void emergencyBackup();
......@@ -76,6 +76,7 @@ protected:
* \return The project name.
*/
QString projectName() const;
virtual QString outputFileName() const;
virtual void failedToLoad( const QString& reason ) const;
virtual void loadTimeline( const QDomElement& ){};
......
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