2016-10-05 13:36:12 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2016 Statoil ASA
|
2019-06-26 12:09:02 +02:00
|
|
|
//
|
2016-10-05 13:36:12 +02:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
2019-06-26 12:09:02 +02:00
|
|
|
//
|
2016-10-05 13:36:12 +02:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-06-26 12:09:02 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2016-10-05 13:36:12 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RicExitApplicationFeature.h"
|
|
|
|
|
|
2019-05-06 10:36:05 +02:00
|
|
|
#include "RiaGuiApplication.h"
|
2019-03-14 15:24:11 +01:00
|
|
|
#include "RiuMainWindow.h"
|
2019-06-26 12:09:02 +02:00
|
|
|
#include "RiuPlotMainWindow.h"
|
2016-10-05 13:36:12 +02:00
|
|
|
|
|
|
|
|
#include <QAction>
|
2019-03-14 15:24:11 +01:00
|
|
|
#include <QDebug>
|
2016-10-05 13:36:12 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_CMD_SOURCE_INIT( RicExitApplicationFeature, "RicExitApplicationFeature" );
|
2016-10-05 13:36:12 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-06-26 12:09:02 +02:00
|
|
|
///
|
2016-10-05 13:36:12 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicExitApplicationFeature::onActionTriggered( bool isChecked )
|
2016-10-05 13:36:12 +02:00
|
|
|
{
|
2023-08-04 09:04:14 +02:00
|
|
|
disableModelChangeContribution();
|
2017-04-20 10:38:58 +02:00
|
|
|
|
2019-05-06 10:36:05 +02:00
|
|
|
RiaGuiApplication* app = RiaGuiApplication::instance();
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( !app->askUserToSaveModifiedProject() ) return;
|
2017-04-20 10:38:58 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( app->mainPlotWindow() )
|
2019-06-26 12:09:02 +02:00
|
|
|
{
|
|
|
|
|
app->mainPlotWindow()->saveWinGeoAndDockToolBarLayout();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
if ( app->mainWindow() )
|
2019-06-26 12:09:02 +02:00
|
|
|
{
|
|
|
|
|
app->mainWindow()->saveWinGeoAndDockToolBarLayout();
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-14 15:24:11 +01:00
|
|
|
// Hide all windows first to make sure they get closed properly
|
2023-04-14 14:07:45 +02:00
|
|
|
for ( QWidget* topLevelWidget : RiaGuiApplication::topLevelWidgets() )
|
2019-03-14 15:24:11 +01:00
|
|
|
{
|
|
|
|
|
topLevelWidget->hide();
|
|
|
|
|
}
|
2022-05-23 14:25:53 +02:00
|
|
|
|
2022-05-21 16:11:55 +02:00
|
|
|
if ( app->mainWindow() )
|
|
|
|
|
{
|
|
|
|
|
app->mainWindow()->close();
|
|
|
|
|
}
|
2022-05-23 14:25:53 +02:00
|
|
|
|
|
|
|
|
if ( app->mainPlotWindow() )
|
|
|
|
|
{
|
|
|
|
|
app->mainPlotWindow()->close();
|
|
|
|
|
}
|
2024-09-30 11:21:17 +02:00
|
|
|
|
|
|
|
|
// This was required after moving to Qt6, causing the application not to shut down properly, and ghost processes remains after a forced
|
|
|
|
|
// shutdown. The slot onLastWindowClosed() configured in RiaGuiApplication::RiaGuiApplication is never called. Testing with
|
|
|
|
|
// processEvents() had no effect.
|
2024-10-15 08:29:40 +02:00
|
|
|
app->closeProject();
|
2024-09-30 11:21:17 +02:00
|
|
|
app->quit();
|
2016-10-05 13:36:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-06-26 12:09:02 +02:00
|
|
|
///
|
2016-10-05 13:36:12 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
void RicExitApplicationFeature::setupActionLook( QAction* actionToSetup )
|
2016-10-05 13:36:12 +02:00
|
|
|
{
|
2019-09-06 10:40:57 +02:00
|
|
|
actionToSetup->setText( "E&xit" );
|
2019-10-25 12:48:17 +02:00
|
|
|
|
|
|
|
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Quit );
|
2016-10-05 13:36:12 +02:00
|
|
|
}
|