mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#7236 Rewrite window closing in ResInsight
This commit is contained in:
parent
1d0705de46
commit
953e7bd18e
@ -189,6 +189,8 @@ RiaGuiApplication::RiaGuiApplication( int& argc, char** argv )
|
||||
setWindowIcon( QIcon( ":/AppLogo48x48.png" ) );
|
||||
|
||||
m_recentFileActionProvider = std::make_unique<RiuRecentFileActionProvider>();
|
||||
|
||||
connect( this, SIGNAL( lastWindowClosed() ), SLOT( onLastWindowClosed() ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -972,7 +974,6 @@ void RiaGuiApplication::createMainPlotWindow()
|
||||
CVF_ASSERT( m_mainPlotWindow == nullptr );
|
||||
|
||||
m_mainPlotWindow = new RiuPlotMainWindow;
|
||||
|
||||
m_mainPlotWindow->setWindowTitle( "Plots - ResInsight" );
|
||||
m_mainPlotWindow->setDefaultWindowSize();
|
||||
m_mainPlotWindow->loadWinGeoAndDockToolBarLayout();
|
||||
@ -1106,28 +1107,6 @@ bool RiaGuiApplication::isMainPlotWindowVisible() const
|
||||
return m_mainPlotWindow && m_mainPlotWindow->isVisible();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGuiApplication::closeMainWindowIfOpenButHidden()
|
||||
{
|
||||
if ( m_mainWindow && !m_mainWindow->isVisible() )
|
||||
{
|
||||
m_mainWindow->close();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGuiApplication::closeMainPlotWindowIfOpenButHidden()
|
||||
{
|
||||
if ( m_mainPlotWindow && !m_mainPlotWindow->isVisible() )
|
||||
{
|
||||
m_mainPlotWindow->close();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1635,6 +1614,15 @@ void RiaGuiApplication::slotWorkerProcessFinished( int exitCode, QProcess::ExitS
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaGuiApplication::onLastWindowClosed()
|
||||
{
|
||||
closeProject();
|
||||
quit();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -123,9 +123,6 @@ public:
|
||||
bool isMain3dWindowVisible() const;
|
||||
bool isMainPlotWindowVisible() const;
|
||||
|
||||
void closeMainWindowIfOpenButHidden();
|
||||
void closeMainPlotWindowIfOpenButHidden();
|
||||
|
||||
std::vector<QAction*> recentFileActions() const;
|
||||
|
||||
static void clearAllSelections();
|
||||
@ -163,7 +160,6 @@ private:
|
||||
|
||||
void createMainWindow();
|
||||
void deleteMainWindow();
|
||||
|
||||
void createMainPlotWindow();
|
||||
void deleteMainPlotWindow();
|
||||
|
||||
@ -173,10 +169,11 @@ private:
|
||||
|
||||
private slots:
|
||||
void slotWorkerProcessFinished( int exitCode, QProcess::ExitStatus exitStatus );
|
||||
void onLastWindowClosed();
|
||||
|
||||
private:
|
||||
RiuMainWindow* m_mainWindow;
|
||||
RiuPlotMainWindow* m_mainPlotWindow;
|
||||
QPointer<RiuMainWindow> m_mainWindow;
|
||||
QPointer<RiuPlotMainWindow> m_mainPlotWindow;
|
||||
|
||||
std::unique_ptr<RiuRecentFileActionProvider> m_recentFileActionProvider;
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user