@@ -362,14 +362,22 @@ bool MainWindow::on_actionQuit_triggered()
362362 if (!editor->confirmClosing ()) return false ;
363363
364364 // Close the project, remembering IDE state for restoring at the next session
365- if (!on_actionCloseProject_triggered ()) return false ;
365+ auto && settings = qobject_cast<Application*>(qApp)->getSettings ()->getQSettings ();
366+ if (auto currProject = CEGUIManager::Instance ().getCurrentProject ())
367+ {
368+ settings->setValue (" lastProject" , currProject->filePath );
369+ if (!on_actionCloseProject_triggered ()) return false ;
370+ }
371+ else
372+ {
373+ settings->remove (" lastProject" );
374+ }
366375
367376 // Close all remaining project-independent tabs
368377 on_actionCloseAllTabs_triggered ();
369378 if (ui->tabs ->count () > 0 ) return false ;
370379
371380 // Save geometry and state of this window to QSettings
372- auto && settings = qobject_cast<Application*>(qApp)->getSettings ()->getQSettings ();
373381 settings->setValue (" window-geometry" , saveGeometry ());
374382 settings->setValue (" window-state" , saveState ());
375383
@@ -818,7 +826,7 @@ void MainWindow::openEditorTab(const QString& absolutePath)
818826{
819827 if (activateEditorTabByFilePath (absolutePath)) return ;
820828
821- openNewEditor (createEditorForFile (absolutePath));
829+ initEditor (createEditorForFile (absolutePath));
822830}
823831
824832// Closes given editor tab.
@@ -994,14 +1002,6 @@ void MainWindow::on_actionOpenFile_triggered()
9941002 openEditorTab (fileName);
9951003}
9961004
997- void MainWindow::openMostRecentProject ()
998- {
999- QStringList items;
1000- recentlyUsedProjects->getRecentlyUsed (items);
1001- if (!items.empty () && QFileInfo (items[0 ]).exists () && confirmProjectClosing (false ))
1002- loadProject (items[0 ]);
1003- }
1004-
10051005void MainWindow::openRecentProject (const QString& path)
10061006{
10071007 if (QFileInfo (path).exists ())
@@ -1320,7 +1320,7 @@ void MainWindow::on_actionNewLayout_triggered()
13201320 {
13211321 if (auto typedFactory = dynamic_cast <LayoutEditorFactory*>(factory.get ()))
13221322 {
1323- openNewEditor (typedFactory-> create ( QString ()) );
1323+ openNewEditor (typedFactory);
13241324 return ;
13251325 }
13261326 }
@@ -1332,7 +1332,7 @@ void MainWindow::on_actionNewImageset_triggered()
13321332 {
13331333 if (auto typedFactory = dynamic_cast <ImagesetEditorFactory*>(factory.get ()))
13341334 {
1335- openNewEditor (typedFactory-> create ( QString ()) );
1335+ openNewEditor (typedFactory);
13361336 return ;
13371337 }
13381338 }
@@ -1344,7 +1344,7 @@ void MainWindow::on_actionNewOtherFile_triggered()
13441344 {
13451345 if (auto typedFactory = dynamic_cast <TextEditorFactory*>(factory.get ()))
13461346 {
1347- openNewEditor (typedFactory-> create ( QString ()) );
1347+ openNewEditor (typedFactory);
13481348 return ;
13491349 }
13501350 }
@@ -1358,7 +1358,20 @@ void MainWindow::on_actionCheckForUpdates_triggered()
13581358 app->checkForUpdates ();
13591359}
13601360
1361- void MainWindow::openNewEditor (EditorBasePtr editor)
1361+ void MainWindow::openNewEditor (EditorFactoryBase* factory)
1362+ {
1363+ if (!factory) return ;
1364+
1365+ if (factory->requiresProject () && !CEGUIManager::Instance ().isProjectLoaded ())
1366+ {
1367+ QMessageBox::warning (this , _title, tr (" Creating this file requires you to have a project opened!" ));
1368+ return ;
1369+ }
1370+
1371+ initEditor (factory->create (QString ()));
1372+ }
1373+
1374+ void MainWindow::initEditor (EditorBasePtr editor)
13621375{
13631376 if (!editor) return ;
13641377
@@ -1367,7 +1380,7 @@ void MainWindow::openNewEditor(EditorBasePtr editor)
13671380 // Will cleanup itself inside if something went wrong
13681381 editor->initialize ();
13691382
1370- // Intentionally before ui->tabs->... to make getEditorForTab() in on_tabs_currentChanged() work
1383+ // NB: intentionally before ui->tabs->... to make getEditorForTab() in on_tabs_currentChanged() work
13711384 auto editorPtr = editor.get ();
13721385 activeEditors.push_back (std::move (editor));
13731386
0 commit comments