mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1401 Ask user to save modified project before project close
This commit is contained in:
@@ -137,11 +137,18 @@ void RiuMainPlotWindow::cleanupGuiBeforeProjectClose()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainPlotWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
if (!app->askUserToSaveModifiedProject())
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
saveWinGeoAndDockToolBarLayout();
|
||||
|
||||
if (!RiaApplication::instance()->tryCloseMainWindow()) return;
|
||||
if (!app->tryCloseMainWindow()) return;
|
||||
|
||||
RiaApplication::instance()->closeProject();
|
||||
app->closeProject();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -197,15 +197,18 @@ void RiuMainWindow::cleanupGuiBeforeProjectClose()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuMainWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
saveWinGeoAndDockToolBarLayout();
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
if (!app->askUserToSaveModifiedProject())
|
||||
{
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
saveWinGeoAndDockToolBarLayout();
|
||||
|
||||
if (!app->tryClosePlotWindow()) return;
|
||||
|
||||
RiaApplication::instance()->closeProject();
|
||||
|
||||
event->accept();
|
||||
app->closeProject();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -122,18 +122,24 @@ void RiuRecentFileActionProvider::slotOpenRecentFile()
|
||||
QAction* action = qobject_cast<QAction *>(sender());
|
||||
if (action)
|
||||
{
|
||||
QString filename = action->data().toString();
|
||||
bool loadingSucceded = RiaApplication::instance()->openFile(filename);
|
||||
QString fileName = action->data().toString();
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
if (RiaApplication::hasValidProjectFileExtension(fileName))
|
||||
{
|
||||
if (!app->askUserToSaveModifiedProject()) return;
|
||||
}
|
||||
|
||||
bool loadingSucceded = RiaApplication::instance()->openFile(fileName);
|
||||
if (loadingSucceded)
|
||||
{
|
||||
addFileName(filename);
|
||||
addFileName(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(NULL, "File open", "Failed to import file located at\n" + filename);
|
||||
QMessageBox::warning(NULL, "File open", "Failed to import file located at\n" + fileName);
|
||||
|
||||
removeFileName(filename);
|
||||
removeFileName(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user