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()
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes );
if ( res == QMessageBox::Yes )
{
QStringList recentProjects = s.value( "RecentsProjects" ).toStringList();
if ( recentProjects.count() == 0 )
{
qDebug() << "No old project";
}
if ( ProjectManager::getInstance()->loadEmergencyBackup() == true )
ret = true;
else
{
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" ) );
}
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 )
void ProjectManager::emergencyBackup()
{
QString name;
if ( m_projectFile != NULL )
{
QString name = m_projectFile->fileName();
name = m_projectFile->fileName();
name += "backup";
__saveProject( name );
}
else
{
QString name = QDir::currentPath() + "unsavedproject.vlmcbackup";
name = QDir::currentPath() + "/unsavedproject.vlmcbackup";
__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 )
{
loadProject( lastProject );
......
......@@ -45,7 +45,7 @@ public:
QStringList recentsProjects() const;
bool closeProject();
bool askForSaveIfModified();
bool loadEmergencyBackup( const QString& projectFile );
bool loadEmergencyBackup();
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