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

Solved backup file problemes.

The last backup file is now stored in a qsettings, to restore as often as possible.
parent 34bd55c7
...@@ -509,18 +509,10 @@ bool MainWindow::restoreSession() ...@@ -509,18 +509,10 @@ bool MainWindow::restoreSession()
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ); QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
if ( res == QMessageBox::Yes ) if ( res == QMessageBox::Yes )
{ {
QStringList recentProjects = s.value( "RecentsProjects" ).toStringList(); if ( ProjectManager::getInstance()->loadEmergencyBackup() == true )
if ( recentProjects.count() == 0 ) ret = true;
{
qDebug() << "No old project";
}
else else
{ QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We appology for the inconvenience" ) );
if ( ProjectManager::getInstance()->loadEmergencyBackup( recentProjects.first() ) == true )
ret = true;
else
QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We appology for the inconvenience" ) );
}
} }
} }
......
...@@ -262,22 +262,28 @@ void ProjectManager::nameChanged( const QVariant& name ) ...@@ -262,22 +262,28 @@ void ProjectManager::nameChanged( const QVariant& name )
void ProjectManager::emergencyBackup() void ProjectManager::emergencyBackup()
{ {
QString name;
if ( m_projectFile != NULL ) if ( m_projectFile != NULL )
{ {
QString name = m_projectFile->fileName(); name = m_projectFile->fileName();
name += "backup"; name += "backup";
__saveProject( name ); __saveProject( name );
} }
else else
{ {
QString name = QDir::currentPath() + "unsavedproject.vlmcbackup"; name = QDir::currentPath() + "/unsavedproject.vlmcbackup";
__saveProject( name ); __saveProject( name );
} }
QSettings s;
s.setValue( "EmergencyBackup", name );
s.sync();
} }
bool ProjectManager::loadEmergencyBackup( const QString& projectName ) bool ProjectManager::loadEmergencyBackup()
{ {
QString lastProject = projectName + "backup"; QSettings s;
QString lastProject = s.value( "EmergencyBackup" ).toString();
if ( QFile::exists( lastProject ) == true ) if ( QFile::exists( lastProject ) == true )
{ {
loadProject( lastProject ); loadProject( lastProject );
......
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
QStringList recentsProjects() const; QStringList recentsProjects() const;
bool closeProject(); bool closeProject();
bool askForSaveIfModified(); bool askForSaveIfModified();
bool loadEmergencyBackup( const QString& projectFile ); bool loadEmergencyBackup();
static void signalHandler( int sig ); static void signalHandler( int sig );
......
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