mirror of
https://github.com/leozide/leocad
synced 2025-01-18 22:26:44 +01:00
Fixed recent file being removed from menu when cancelling saving the current file.
This commit is contained in:
parent
6891c59d38
commit
636f84ad6c
2 changed files with 20 additions and 5 deletions
|
@ -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:
|
||||
|
|
|
@ -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++)
|
||||
|
|
Loading…
Reference in a new issue