MainWindow: ask confirmation before closing Qt Creator

When working with multiple windows, pressing the close button multiple
times can close Qt Creator too.

This patch adds a system option, asking for a confirmation before
closing the IDE. By default it's not enabled.

Fixes: QTCREATORBUG-7637
Change-Id: Ifc5e8c97511f9227ce0634c8a7064d95775c76c2
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Antonio Di Monaco
2019-11-26 11:20:02 +01:00
committed by André Hartmann
parent 70b226144f
commit 6e4ca8b6af
4 changed files with 47 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
#include "fileutils.h"
#include "icore.h"
#include "iversioncontrol.h"
#include "mainwindow.h"
#include "patchtool.h"
#include "vcsmanager.h"
@@ -112,6 +113,8 @@ public:
m_ui.maxRecentFilesSpinBox->setMinimum(1);
m_ui.maxRecentFilesSpinBox->setMaximum(99);
m_ui.maxRecentFilesSpinBox->setValue(EditorManagerPrivate::maxRecentFiles());
m_ui.askBeforeExitCheckBox->setChecked(
static_cast<Core::Internal::MainWindow *>(ICore::mainWindow())->askConfirmationBeforeExit());
if (HostOsInfo::isAnyUnixHost()) {
connect(m_ui.resetTerminalButton, &QAbstractButton::clicked,
@@ -191,6 +194,8 @@ void SystemSettingsWidget::apply()
m_ui.warnBeforeOpeningBigFiles->isChecked());
EditorManagerPrivate::setBigFileSizeLimit(m_ui.bigFilesLimitSpinBox->value());
EditorManagerPrivate::setMaxRecentFiles(m_ui.maxRecentFilesSpinBox->value());
static_cast<Core::Internal::MainWindow *>(ICore::mainWindow())->setAskConfirmationBeforeExit(
m_ui.askBeforeExitCheckBox->isChecked());
if (HostOsInfo::isMacHost()) {
Qt::CaseSensitivity defaultSensitivity