Fixed recent file being removed from menu when cancelling saving the current file.

This commit is contained in:
Leonardo Zide 2020-01-04 11:25:52 -08:00
parent 6891c59d38
commit 636f84ad6c
2 changed files with 20 additions and 5 deletions

View file

@ -2210,19 +2210,32 @@ bool lcMainWindow::OpenProject(const QString& FileName)
lcSetProfileString(LC_PROFILE_PROJECTS_PATH, QFileInfo(LoadFileName).absolutePath());
}
return OpenProjectFile(LoadFileName);
}
void lcMainWindow::OpenRecentProject(int RecentFileIndex)
{
if (!SaveProjectIfModified())
return;
if (!OpenProjectFile(mRecentFiles[RecentFileIndex]))
RemoveRecentFile(RecentFileIndex);
}
bool lcMainWindow::OpenProjectFile(const QString& FileName)
{
Project* NewProject = new Project();
if (NewProject->Load(LoadFileName))
if (NewProject->Load(FileName))
{
gApplication->SetProject(NewProject);
AddRecentFile(LoadFileName);
AddRecentFile(FileName);
UpdateAllViews();
return true;
}
delete NewProject;
return false;
}
@ -2495,8 +2508,7 @@ void lcMainWindow::HandleCommand(lcCommandId CommandId)
case LC_FILE_RECENT2:
case LC_FILE_RECENT3:
case LC_FILE_RECENT4:
if (!OpenProject(mRecentFiles[CommandId - LC_FILE_RECENT1]))
RemoveRecentFile(CommandId - LC_FILE_RECENT1);
OpenRecentProject(CommandId - LC_FILE_RECENT1);
break;
case LC_FILE_EXIT:

View file

@ -292,6 +292,7 @@ public:
void NewProject();
bool OpenProject(const QString& FileName);
void OpenRecentProject(int RecentFileIndex);
void MergeProject();
void ImportLDD();
void ImportInventory();
@ -373,6 +374,8 @@ protected:
void ShowRenderDialog();
void ShowPrintDialog();
bool OpenProjectFile(const QString& FileName);
lcModelTabWidget* GetTabWidgetForModel(lcModel* Model) const
{
for (int TabIdx = 0; TabIdx < mModelTabWidget->count(); TabIdx++)