#7236 Rewrite window closing in ResInsight

This commit is contained in:
Gaute Lindkvist
2021-01-19 13:25:48 +01:00
parent 1d0705de46
commit 953e7bd18e
4 changed files with 30 additions and 59 deletions

View File

@@ -283,25 +283,19 @@ void RiuMainWindow::cleanupGuiBeforeProjectClose()
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::closeEvent( QCloseEvent* event )
{
this->saveWinGeoAndDockToolBarLayout();
RiaGuiApplication* app = RiaGuiApplication::instance();
if ( app->isMainPlotWindowVisible() )
{
event->ignore(); // Make Qt think we don't do anything, otherwise it closes the window.
this->hide(); // Instead we just hide it.
return;
}
if ( !app->askUserToSaveModifiedProject() )
if ( !app->isMainPlotWindowVisible() )
{
event->ignore();
return;
if ( !app->askUserToSaveModifiedProject() )
{
event->ignore();
return;
}
}
this->saveWinGeoAndDockToolBarLayout();
this->hideAllDockWidgets();
app->closeMainPlotWindowIfOpenButHidden();
app->closeProject();
QMainWindow::closeEvent( event );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -197,26 +197,18 @@ void RiuPlotMainWindow::cleanUpTemporaryWidgets()
//--------------------------------------------------------------------------------------------------
void RiuPlotMainWindow::closeEvent( QCloseEvent* event )
{
this->saveWinGeoAndDockToolBarLayout();
RiaGuiApplication* app = RiaGuiApplication::instance();
if ( app->isMain3dWindowVisible() )
if ( !app->isMain3dWindowVisible() )
{
event->ignore();
this->hide();
return;
if ( !app->askUserToSaveModifiedProject() )
{
event->ignore();
return;
}
}
if ( !app->askUserToSaveModifiedProject() )
{
event->ignore();
return;
}
this->saveWinGeoAndDockToolBarLayout();
this->hideAllDockWidgets();
app->closeMainWindowIfOpenButHidden();
app->closeProject();
QMainWindow::closeEvent( event );
}
//--------------------------------------------------------------------------------------------------