Unsaved changes bugfix, added close event for start window

This commit is contained in:
parax0
2016-02-01 22:15:28 -07:00
parent 0fe0c667a1
commit 8e1b66fa5a
9 changed files with 20 additions and 12 deletions

View File

@@ -28,24 +28,29 @@ CStartWindow::~CStartWindow()
delete mpModelEditor;
}
void CStartWindow::closeEvent(QCloseEvent *pEvent)
{
if (mpWorldEditor->close())
qApp->quit();
else
pEvent->ignore();
}
void CStartWindow::on_actionOpen_MLVL_triggered()
{
QString WorldFile = QFileDialog::getOpenFileName(this, "Open MLVL", "", "Metroid Prime World (*.MLVL)");
if (WorldFile.isEmpty()) return;
if (mpWorldEditor->CheckUnsavedChanges())
if (mpWorldEditor->close())
{
gResCache.SetFolder(TString(WorldFile.toStdString()).GetFileDirectory());
mpWorld = gResCache.GetResource(WorldFile.toStdString());
mpWorldEditor->close();
FillWorldUI();
}
}
void CStartWindow::FillWorldUI()
{
CStringTable *pWorldName = mpWorld->GetWorldName();
if (pWorldName)
{

View File

@@ -26,6 +26,7 @@ class CStartWindow : public QMainWindow
public:
explicit CStartWindow(QWidget *parent = 0);
~CStartWindow();
void closeEvent(QCloseEvent *pEvent);
private slots:
void on_actionOpen_MLVL_triggered();

View File

@@ -93,6 +93,8 @@ void CWorldEditor::closeEvent(QCloseEvent *pEvent)
if (ShouldClose)
{
mUndoStack.clear();
if (mpPoiDialog)
mpPoiDialog->close();
}