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

ProjectManager: Check for a backup file even when the project is loaded from the CLI.

This is not performed in non GUI mode.
parent 63af3ca5
...@@ -215,19 +215,14 @@ GUIProjectManager::loadTimeline( const QDomElement &root ) ...@@ -215,19 +215,14 @@ GUIProjectManager::loadTimeline( const QDomElement &root )
} }
void void
GUIProjectManager::loadProject() GUIProjectManager::loadProject( const QString &fileName )
{ {
QString fileName =
QFileDialog::getOpenFileName( NULL, "Enter the output file name",
VLMC_PROJECT_GET_STRING( "general/VLMCWorkspace" ),
"VLMC project file(*.vlmc)" );
if ( fileName.length() <= 0 ) //If the user canceled.
return ;
QFile projectFile( fileName ); QFile projectFile( fileName );
//If for some reason this happens... better safe than sorry //If for some reason this happens... better safe than sorry
if ( projectFile.exists() == false ) if ( projectFile.exists() == false )
return ; return ;
QString fileToLoad = fileName;
QString backupFilename = createAutoSaveOutputFileName( fileName ); QString backupFilename = createAutoSaveOutputFileName( fileName );
QFile autoBackup( backupFilename ); QFile autoBackup( backupFilename );
if ( autoBackup.exists() == true ) if ( autoBackup.exists() == true )
...@@ -242,7 +237,7 @@ GUIProjectManager::loadProject() ...@@ -242,7 +237,7 @@ GUIProjectManager::loadProject()
"Do you want to load it ?" ), "Do you want to load it ?" ),
QMessageBox::Ok | QMessageBox::No ) == QMessageBox::Ok ) QMessageBox::Ok | QMessageBox::No ) == QMessageBox::Ok )
{ {
fileName = backupFilename; fileToLoad = backupFilename;
} }
} }
else else
...@@ -256,5 +251,17 @@ GUIProjectManager::loadProject() ...@@ -256,5 +251,17 @@ GUIProjectManager::loadProject()
} }
} }
} }
ProjectManager::loadProject( fileName ); ProjectManager::loadProject( fileToLoad );
}
void
GUIProjectManager::loadProject()
{
QString fileName =
QFileDialog::getOpenFileName( NULL, "Enter the output file name",
VLMC_PROJECT_GET_STRING( "general/VLMCWorkspace" ),
"VLMC project file(*.vlmc)" );
if ( fileName.length() <= 0 ) //If the user canceled.
return ;
loadProject( fileName );
} }
...@@ -52,10 +52,17 @@ public: ...@@ -52,10 +52,17 @@ public:
/** /**
* \brief Display the open file name dialog, and call the actual project loading * \brief Display the open file name dialog, and call the actual project loading
* method. * method.
*
* \warning This is not an overload for the ProjectManager::loadProject() method.
*/ */
void loadProject(); void loadProject();
/**
* \brief Check for a project backup file, and load the appropriate file,
* according to the user input.
*
* if an outdated project backup is found, the used is asked if she wants to delete
* it.
* This is handled here as there's no use for this in non-GUI mode.
*/
void loadProject( const QString& fileName );
protected: protected:
virtual void failedToLoad( const QString &reason ) const; virtual void failedToLoad( const QString &reason ) const;
......
...@@ -102,7 +102,7 @@ VLMCmain( int argc, char **argv ) ...@@ -102,7 +102,7 @@ VLMCmain( int argc, char **argv )
MainWindow w; MainWindow w;
if ( argc > 1 ) if ( argc > 1 )
GUIProjectManager::getInstance()->ProjectManager::loadProject( argv[argc - 1] ); GUIProjectManager::getInstance()->loadProject( argv[argc - 1] );
w.show(); w.show();
return app.exec(); return app.exec();
} }
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