2015-08-14 13:25:31 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-08-14 13:25:31 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2015-08-14 13:25:31 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2015-08-14 13:25:31 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "systemsettings.h"
|
|
|
|
|
#include "coreconstants.h"
|
2020-11-16 16:40:12 +01:00
|
|
|
#include "coreplugin.h"
|
2015-08-14 13:25:31 +02:00
|
|
|
#include "editormanager/editormanager_p.h"
|
2020-09-21 12:58:35 +03:00
|
|
|
#include "dialogs/restartdialog.h"
|
2018-10-19 10:42:55 +02:00
|
|
|
#include "fileutils.h"
|
2015-08-14 13:25:31 +02:00
|
|
|
#include "icore.h"
|
2016-02-02 09:10:54 +02:00
|
|
|
#include "iversioncontrol.h"
|
2019-11-26 11:20:02 +01:00
|
|
|
#include "mainwindow.h"
|
2015-08-14 13:25:31 +02:00
|
|
|
#include "patchtool.h"
|
|
|
|
|
#include "vcsmanager.h"
|
|
|
|
|
|
2017-08-29 11:48:48 +02:00
|
|
|
#include <app/app_version.h>
|
2021-11-09 18:20:14 +01:00
|
|
|
|
|
|
|
|
#include <utils/algorithm.h>
|
2015-08-14 13:25:31 +02:00
|
|
|
#include <utils/checkablemessagebox.h>
|
2022-07-20 10:42:06 +02:00
|
|
|
#include <utils/elidinglabel.h>
|
2015-08-14 13:25:31 +02:00
|
|
|
#include <utils/environment.h>
|
2020-11-16 16:40:12 +01:00
|
|
|
#include <utils/environmentdialog.h>
|
2015-08-14 13:25:31 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2022-07-20 10:42:06 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
2022-01-21 14:38:50 +01:00
|
|
|
#include <utils/terminalcommand.h>
|
2015-08-14 13:25:31 +02:00
|
|
|
#include <utils/unixutils.h>
|
|
|
|
|
|
2022-07-20 10:42:06 +02:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QComboBox>
|
2015-08-14 13:25:31 +02:00
|
|
|
#include <QCoreApplication>
|
2022-07-20 10:42:06 +02:00
|
|
|
#include <QLineEdit>
|
2015-08-14 13:25:31 +02:00
|
|
|
#include <QMessageBox>
|
2022-07-20 10:42:06 +02:00
|
|
|
#include <QPushButton>
|
2015-08-14 13:25:31 +02:00
|
|
|
#include <QSettings>
|
2022-07-20 10:42:06 +02:00
|
|
|
#include <QSpinBox>
|
|
|
|
|
#include <QToolButton>
|
2015-08-14 13:25:31 +02:00
|
|
|
|
|
|
|
|
using namespace Utils;
|
2022-07-20 10:42:06 +02:00
|
|
|
using namespace Layouting;
|
2015-08-14 13:25:31 +02:00
|
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2021-01-25 18:00:52 +01:00
|
|
|
#ifdef ENABLE_CRASHPAD
|
2021-02-16 08:46:52 +01:00
|
|
|
const char crashReportingEnabledKey[] = "CrashReportingEnabled";
|
|
|
|
|
const char showCrashButtonKey[] = "ShowCrashButton";
|
|
|
|
|
|
|
|
|
|
// TODO: move to somewhere in Utils
|
2020-09-21 12:58:35 +03:00
|
|
|
static QString formatSize(qint64 size)
|
|
|
|
|
{
|
|
|
|
|
QStringList units {QObject::tr("Bytes"), QObject::tr("KB"), QObject::tr("MB"),
|
|
|
|
|
QObject::tr("GB"), QObject::tr("TB")};
|
|
|
|
|
double outputSize = size;
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < units.size() - 1; ++i) {
|
|
|
|
|
if (outputSize < 1024)
|
|
|
|
|
break;
|
|
|
|
|
outputSize /= 1024;
|
|
|
|
|
}
|
|
|
|
|
return i == 0 ? QString("%0 %1").arg(outputSize).arg(units[i]) // Bytes
|
|
|
|
|
: QString("%0 %1").arg(outputSize, 0, 'f', 2).arg(units[i]); // KB, MB, GB, TB
|
|
|
|
|
}
|
2021-01-25 18:00:52 +01:00
|
|
|
#endif // ENABLE_CRASHPAD
|
2020-09-21 12:58:35 +03:00
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
class SystemSettingsWidget : public IOptionsPageWidget
|
2015-08-14 13:25:31 +02:00
|
|
|
{
|
2020-02-24 13:44:34 +01:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(Core::Internal::SystemSettingsWidget)
|
2016-06-23 15:31:58 +02:00
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
public:
|
|
|
|
|
SystemSettingsWidget()
|
2022-07-20 10:42:06 +02:00
|
|
|
: m_fileSystemCaseSensitivityChooser(new QComboBox)
|
|
|
|
|
, m_autoSuspendMinDocumentCount(new QSpinBox)
|
|
|
|
|
, m_externalFileBrowserEdit(new QLineEdit)
|
|
|
|
|
, m_autoSuspendCheckBox(new QCheckBox(tr("Auto-suspend unmodified files")))
|
|
|
|
|
, m_maxRecentFilesSpinBox(new QSpinBox)
|
|
|
|
|
, m_enableCrashReportingCheckBox(new QCheckBox(tr("Enable crash reporting")))
|
|
|
|
|
, m_warnBeforeOpeningBigFiles(
|
|
|
|
|
new QCheckBox(tr("Warn before opening text files greater than")))
|
|
|
|
|
, m_bigFilesLimitSpinBox(new QSpinBox)
|
|
|
|
|
, m_terminalComboBox(new QComboBox)
|
|
|
|
|
, m_terminalOpenArgs(new QLineEdit)
|
|
|
|
|
, m_terminalExecuteArgs(new QLineEdit)
|
|
|
|
|
, m_patchChooser(new Utils::PathChooser)
|
|
|
|
|
, m_environmentChangesLabel(new Utils::ElidingLabel)
|
|
|
|
|
, m_askBeforeExitCheckBox(new QCheckBox(tr("Ask for confirmation before exiting")))
|
|
|
|
|
, m_reloadBehavior(new QComboBox)
|
|
|
|
|
, m_autoSaveCheckBox(new QCheckBox(tr("Auto-save modified files")))
|
|
|
|
|
, m_clearCrashReportsButton(new QPushButton(tr("Clear Local Crash Reports")))
|
|
|
|
|
, m_crashReportsSizeText(new QLabel)
|
|
|
|
|
, m_autoSaveInterval(new QSpinBox)
|
|
|
|
|
, m_autoSaveRefactoringCheckBox(new QCheckBox(tr("Auto-save files after refactoring")))
|
|
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
{
|
2022-07-20 10:42:06 +02:00
|
|
|
m_autoSuspendCheckBox->setToolTip(
|
|
|
|
|
tr("Automatically free resources of old documents that are not visible and not "
|
|
|
|
|
"modified. They stay visible in the list of open documents."));
|
|
|
|
|
m_autoSuspendMinDocumentCount->setMinimum(1);
|
|
|
|
|
m_autoSuspendMinDocumentCount->setMaximum(500);
|
|
|
|
|
m_autoSuspendMinDocumentCount->setValue(30);
|
|
|
|
|
m_enableCrashReportingCheckBox->setToolTip(
|
|
|
|
|
tr("Allow crashes to be automatically reported. Collected reports are "
|
|
|
|
|
"used for the sole purpose of fixing bugs."));
|
|
|
|
|
m_bigFilesLimitSpinBox->setSuffix(tr("MB"));
|
|
|
|
|
m_bigFilesLimitSpinBox->setMinimum(1);
|
|
|
|
|
m_bigFilesLimitSpinBox->setMaximum(500);
|
|
|
|
|
m_bigFilesLimitSpinBox->setValue(5);
|
|
|
|
|
m_terminalExecuteArgs->setToolTip(
|
|
|
|
|
tr("Command line arguments used for \"Run in terminal\"."));
|
|
|
|
|
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
|
|
|
sizePolicy.setHorizontalStretch(5);
|
|
|
|
|
m_environmentChangesLabel->setSizePolicy(sizePolicy);
|
|
|
|
|
m_reloadBehavior->addItem(tr("Always Ask"));
|
|
|
|
|
m_reloadBehavior->addItem(tr("Reload All Unchanged Editors"));
|
|
|
|
|
m_reloadBehavior->addItem(tr("Ignore Modifications"));
|
|
|
|
|
m_autoSaveInterval->setSuffix(tr("min"));
|
|
|
|
|
QSizePolicy termSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
|
|
|
|
termSizePolicy.setHorizontalStretch(3);
|
|
|
|
|
m_terminalComboBox->setSizePolicy(termSizePolicy);
|
|
|
|
|
m_terminalComboBox->setMinimumSize(QSize(100, 0));
|
|
|
|
|
m_terminalComboBox->setEditable(true);
|
|
|
|
|
m_terminalOpenArgs->setToolTip(
|
2019-04-26 20:47:23 +02:00
|
|
|
tr("Command line arguments used for \"%1\".").arg(FileUtils::msgTerminalHereAction()));
|
2022-07-20 10:42:06 +02:00
|
|
|
m_autoSaveInterval->setMinimum(1);
|
|
|
|
|
|
|
|
|
|
auto fileSystemCaseSensitivityLabel = new QLabel(tr("File system case sensitivity:"));
|
|
|
|
|
fileSystemCaseSensitivityLabel->setToolTip(
|
|
|
|
|
tr("Influences how file names are matched to decide if they are the same."));
|
|
|
|
|
auto autoSuspendLabel = new QLabel(tr("Files to keep open:"));
|
|
|
|
|
autoSuspendLabel->setToolTip(
|
|
|
|
|
tr("Minimum number of open documents that should be kept in memory. Increasing this "
|
|
|
|
|
"number will lead to greater resource usage when not manually closing documents."));
|
|
|
|
|
auto resetFileBrowserButton = new QPushButton(tr("Reset"));
|
|
|
|
|
resetFileBrowserButton->setToolTip(tr("Reset to default."));
|
|
|
|
|
auto helpExternalFileBrowserButton = new QToolButton;
|
|
|
|
|
helpExternalFileBrowserButton->setText(tr("?"));
|
|
|
|
|
auto helpCrashReportingButton = new QToolButton;
|
|
|
|
|
helpCrashReportingButton->setText(tr("?"));
|
|
|
|
|
auto resetTerminalButton = new QPushButton(tr("Reset"));
|
|
|
|
|
resetTerminalButton->setToolTip(tr("Reset to default.", "Terminal"));
|
|
|
|
|
auto patchCommandLabel = new QLabel(tr("Patch command:"));
|
|
|
|
|
auto environmentButton = new QPushButton(tr("Change..."));
|
|
|
|
|
environmentButton->setSizePolicy(QSizePolicy::Fixed,
|
|
|
|
|
environmentButton->sizePolicy().verticalPolicy());
|
|
|
|
|
|
|
|
|
|
Grid form;
|
|
|
|
|
form.addRow(
|
|
|
|
|
{tr("Environment:"), Span(2, Row{m_environmentChangesLabel, environmentButton})});
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
|
|
|
|
form.addRow({tr("Terminal:"),
|
|
|
|
|
Span(2,
|
|
|
|
|
Row{m_terminalComboBox,
|
|
|
|
|
m_terminalOpenArgs,
|
|
|
|
|
m_terminalExecuteArgs,
|
|
|
|
|
resetTerminalButton})});
|
|
|
|
|
}
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost()) {
|
|
|
|
|
form.addRow({tr("External file browser:"),
|
|
|
|
|
Span(2,
|
|
|
|
|
Row{m_externalFileBrowserEdit,
|
|
|
|
|
resetFileBrowserButton,
|
|
|
|
|
helpExternalFileBrowserButton})});
|
|
|
|
|
}
|
|
|
|
|
form.addRow({patchCommandLabel, Span(2, m_patchChooser)});
|
|
|
|
|
if (HostOsInfo::isMacHost()) {
|
|
|
|
|
form.addRow({fileSystemCaseSensitivityLabel,
|
|
|
|
|
Span(2, Row{m_fileSystemCaseSensitivityChooser, Stretch()})});
|
|
|
|
|
}
|
|
|
|
|
form.addRow(
|
|
|
|
|
{tr("When files are externally modified:"), Span(2, Row{m_reloadBehavior, Stretch()})});
|
|
|
|
|
form.addRow(
|
|
|
|
|
{m_autoSaveCheckBox, Span(2, Row{tr("Interval:"), m_autoSaveInterval, Stretch()})});
|
|
|
|
|
form.addRow(Span(3, m_autoSaveRefactoringCheckBox));
|
|
|
|
|
form.addRow({m_autoSuspendCheckBox,
|
|
|
|
|
Span(2, Row{autoSuspendLabel, m_autoSuspendMinDocumentCount, Stretch()})});
|
|
|
|
|
form.addRow(Span(3, Row{m_warnBeforeOpeningBigFiles, m_bigFilesLimitSpinBox, Stretch()}));
|
|
|
|
|
form.addRow(Span(3,
|
|
|
|
|
Row{tr("Maximum number of entries in \"Recent Files\":"),
|
|
|
|
|
m_maxRecentFilesSpinBox,
|
|
|
|
|
Stretch()}));
|
|
|
|
|
form.addRow(m_askBeforeExitCheckBox);
|
|
|
|
|
#ifdef ENABLE_CRASHPAD
|
|
|
|
|
form.addRow(
|
|
|
|
|
Span(3, Row{m_enableCrashReportingCheckBox, helpCrashReportingButton, Stretch()}));
|
|
|
|
|
form.addRow(Span(3, Row{m_clearCrashReportsButton, m_crashReportsSizeText, Stretch()}));
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-07-21 11:10:34 +02:00
|
|
|
Column {
|
|
|
|
|
Group {
|
|
|
|
|
Title(tr("System")),
|
|
|
|
|
Column { form, Stretch() }
|
|
|
|
|
}
|
|
|
|
|
}.attachTo(this);
|
2015-08-14 13:25:31 +02:00
|
|
|
|
2022-07-20 10:42:06 +02:00
|
|
|
m_reloadBehavior->setCurrentIndex(EditorManager::reloadSetting());
|
2015-08-14 13:25:31 +02:00
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
2022-07-20 10:42:06 +02:00
|
|
|
const QVector<TerminalCommand> availableTerminals
|
|
|
|
|
= TerminalCommand::availableTerminalEmulators();
|
2018-08-24 10:56:13 +02:00
|
|
|
for (const TerminalCommand &term : availableTerminals)
|
2022-07-20 10:42:06 +02:00
|
|
|
m_terminalComboBox->addItem(term.command, QVariant::fromValue(term));
|
2022-01-21 14:38:50 +01:00
|
|
|
updateTerminalUi(TerminalCommand::terminalEmulator());
|
2022-07-20 10:42:06 +02:00
|
|
|
connect(m_terminalComboBox, &QComboBox::currentIndexChanged, this, [this](int index) {
|
|
|
|
|
updateTerminalUi(m_terminalComboBox->itemData(index).value<TerminalCommand>());
|
2022-07-19 22:37:03 +02:00
|
|
|
});
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost()) {
|
2022-07-20 10:42:06 +02:00
|
|
|
m_externalFileBrowserEdit->setText(UnixUtils::fileBrowser(ICore::settings()));
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString patchToolTip = tr("Command used for reverting diff chunks.");
|
2022-07-20 10:42:06 +02:00
|
|
|
patchCommandLabel->setToolTip(patchToolTip);
|
|
|
|
|
m_patchChooser->setToolTip(patchToolTip);
|
|
|
|
|
m_patchChooser->setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
m_patchChooser->setHistoryCompleter(QLatin1String("General.PatchCommand.History"));
|
|
|
|
|
m_patchChooser->setFilePath(PatchTool::patchCommand());
|
|
|
|
|
m_autoSaveCheckBox->setChecked(EditorManagerPrivate::autoSaveEnabled());
|
|
|
|
|
m_autoSaveCheckBox->setToolTip(tr("Automatically creates temporary copies of "
|
|
|
|
|
"modified files. If %1 is restarted after "
|
|
|
|
|
"a crash or power failure, it asks whether to "
|
|
|
|
|
"recover the auto-saved content.")
|
|
|
|
|
.arg(Constants::IDE_DISPLAY_NAME));
|
|
|
|
|
m_autoSaveRefactoringCheckBox->setChecked(EditorManager::autoSaveAfterRefactoring());
|
|
|
|
|
m_autoSaveRefactoringCheckBox->setToolTip(
|
|
|
|
|
tr("Automatically saves all open files "
|
|
|
|
|
"affected by a refactoring operation,\n provided they were unmodified before the "
|
|
|
|
|
"refactoring."));
|
|
|
|
|
m_autoSaveInterval->setValue(EditorManagerPrivate::autoSaveInterval());
|
|
|
|
|
m_autoSuspendCheckBox->setChecked(EditorManagerPrivate::autoSuspendEnabled());
|
|
|
|
|
m_autoSuspendMinDocumentCount->setValue(EditorManagerPrivate::autoSuspendMinDocumentCount());
|
|
|
|
|
m_warnBeforeOpeningBigFiles->setChecked(
|
|
|
|
|
EditorManagerPrivate::warnBeforeOpeningBigFilesEnabled());
|
|
|
|
|
m_bigFilesLimitSpinBox->setValue(EditorManagerPrivate::bigFileSizeLimit());
|
|
|
|
|
m_maxRecentFilesSpinBox->setMinimum(1);
|
|
|
|
|
m_maxRecentFilesSpinBox->setMaximum(99);
|
|
|
|
|
m_maxRecentFilesSpinBox->setValue(EditorManagerPrivate::maxRecentFiles());
|
2020-09-21 12:58:35 +03:00
|
|
|
#ifdef ENABLE_CRASHPAD
|
|
|
|
|
if (ICore::settings()->value(showCrashButtonKey).toBool()) {
|
|
|
|
|
auto crashButton = new QPushButton("CRASH!!!");
|
|
|
|
|
crashButton->show();
|
|
|
|
|
connect(crashButton, &QPushButton::clicked, []() {
|
|
|
|
|
// do a real crash
|
|
|
|
|
volatile int* a = reinterpret_cast<volatile int *>(NULL); *a = 1;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-20 10:42:06 +02:00
|
|
|
m_enableCrashReportingCheckBox->setChecked(
|
|
|
|
|
ICore::settings()->value(crashReportingEnabledKey).toBool());
|
|
|
|
|
connect(helpCrashReportingButton, &QAbstractButton::clicked, this, [this] {
|
2020-09-21 12:58:35 +03:00
|
|
|
showHelpDialog(tr("Crash Reporting"), CorePlugin::msgCrashpadInformation());
|
|
|
|
|
});
|
2022-07-20 10:42:06 +02:00
|
|
|
connect(m_enableCrashReportingCheckBox, &QCheckBox::stateChanged, this, [this] {
|
2020-09-21 12:58:35 +03:00
|
|
|
const QString restartText = tr("The change will take effect after restart.");
|
|
|
|
|
Core::RestartDialog restartDialog(Core::ICore::dialogParent(), restartText);
|
|
|
|
|
restartDialog.exec();
|
|
|
|
|
if (restartDialog.result() == QDialog::Accepted)
|
|
|
|
|
apply();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
updateClearCrashWidgets();
|
2022-07-20 10:42:06 +02:00
|
|
|
connect(m_clearCrashReportsButton, &QPushButton::clicked, this, [&] {
|
2021-06-03 08:50:31 +02:00
|
|
|
QDir crashReportsDir = ICore::crashReportsPath().toDir();
|
2020-09-21 12:58:35 +03:00
|
|
|
crashReportsDir.setFilter(QDir::Files);
|
|
|
|
|
const QStringList crashFiles = crashReportsDir.entryList();
|
|
|
|
|
for (QString file : crashFiles)
|
|
|
|
|
crashReportsDir.remove(file);
|
|
|
|
|
updateClearCrashWidgets();
|
|
|
|
|
});
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-07-20 10:42:06 +02:00
|
|
|
m_askBeforeExitCheckBox->setChecked(
|
|
|
|
|
static_cast<Core::Internal::MainWindow *>(ICore::mainWindow())
|
|
|
|
|
->askConfirmationBeforeExit());
|
2015-08-14 13:25:31 +02:00
|
|
|
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
2022-07-20 10:42:06 +02:00
|
|
|
connect(resetTerminalButton,
|
|
|
|
|
&QAbstractButton::clicked,
|
|
|
|
|
this,
|
|
|
|
|
&SystemSettingsWidget::resetTerminal);
|
2015-08-14 13:25:31 +02:00
|
|
|
if (!HostOsInfo::isMacHost()) {
|
2022-07-20 10:42:06 +02:00
|
|
|
connect(resetFileBrowserButton,
|
|
|
|
|
&QAbstractButton::clicked,
|
|
|
|
|
this,
|
|
|
|
|
&SystemSettingsWidget::resetFileBrowser);
|
|
|
|
|
connect(helpExternalFileBrowserButton,
|
|
|
|
|
&QAbstractButton::clicked,
|
|
|
|
|
this,
|
|
|
|
|
&SystemSettingsWidget::showHelpForFileBrowser);
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-14 16:45:23 +02:00
|
|
|
if (HostOsInfo::isMacHost()) {
|
|
|
|
|
Qt::CaseSensitivity defaultSensitivity
|
2018-04-23 13:34:11 +02:00
|
|
|
= OsSpecificAspects::fileNameCaseSensitivity(HostOsInfo::hostOs());
|
2015-08-14 16:45:23 +02:00
|
|
|
if (defaultSensitivity == Qt::CaseSensitive) {
|
2022-07-20 10:42:06 +02:00
|
|
|
m_fileSystemCaseSensitivityChooser->addItem(tr("Case Sensitive (Default)"),
|
|
|
|
|
Qt::CaseSensitive);
|
2015-08-14 16:45:23 +02:00
|
|
|
} else {
|
2022-07-20 10:42:06 +02:00
|
|
|
m_fileSystemCaseSensitivityChooser->addItem(tr("Case Sensitive"), Qt::CaseSensitive);
|
2015-08-14 16:45:23 +02:00
|
|
|
}
|
|
|
|
|
if (defaultSensitivity == Qt::CaseInsensitive) {
|
2022-07-20 10:42:06 +02:00
|
|
|
m_fileSystemCaseSensitivityChooser->addItem(tr("Case Insensitive (Default)"),
|
|
|
|
|
Qt::CaseInsensitive);
|
2015-08-14 16:45:23 +02:00
|
|
|
} else {
|
2022-07-20 10:42:06 +02:00
|
|
|
m_fileSystemCaseSensitivityChooser->addItem(tr("Case Insensitive"),
|
|
|
|
|
Qt::CaseInsensitive);
|
2015-08-14 16:45:23 +02:00
|
|
|
}
|
2021-12-10 09:05:17 +01:00
|
|
|
const Qt::CaseSensitivity sensitivity = EditorManagerPrivate::readFileSystemSensitivity(
|
|
|
|
|
ICore::settings());
|
|
|
|
|
if (sensitivity == Qt::CaseSensitive)
|
2022-07-20 10:42:06 +02:00
|
|
|
m_fileSystemCaseSensitivityChooser->setCurrentIndex(0);
|
2015-08-14 16:45:23 +02:00
|
|
|
else
|
2022-07-20 10:42:06 +02:00
|
|
|
m_fileSystemCaseSensitivityChooser->setCurrentIndex(1);
|
2015-08-14 16:45:23 +02:00
|
|
|
}
|
|
|
|
|
|
2015-08-14 13:25:31 +02:00
|
|
|
updatePath();
|
2020-01-08 19:06:42 +01:00
|
|
|
|
2022-07-20 10:42:06 +02:00
|
|
|
m_environmentChangesLabel->setElideMode(Qt::ElideRight);
|
2020-11-16 16:40:12 +01:00
|
|
|
m_environmentChanges = CorePlugin::environmentChanges();
|
|
|
|
|
updateEnvironmentChangesLabel();
|
2022-07-20 10:42:06 +02:00
|
|
|
connect(environmentButton, &QPushButton::clicked, this, [this, environmentButton] {
|
2020-11-16 16:40:12 +01:00
|
|
|
Utils::optional<EnvironmentItems> changes
|
2022-07-20 10:42:06 +02:00
|
|
|
= Utils::EnvironmentDialog::getEnvironmentItems(environmentButton,
|
2020-11-16 16:40:12 +01:00
|
|
|
m_environmentChanges);
|
|
|
|
|
if (!changes)
|
|
|
|
|
return;
|
|
|
|
|
m_environmentChanges = *changes;
|
|
|
|
|
updateEnvironmentChangesLabel();
|
|
|
|
|
updatePath();
|
|
|
|
|
});
|
|
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
connect(VcsManager::instance(), &VcsManager::configurationChanged,
|
|
|
|
|
this, &SystemSettingsWidget::updatePath);
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
private:
|
|
|
|
|
void apply() final;
|
|
|
|
|
|
|
|
|
|
void showHelpForFileBrowser();
|
|
|
|
|
void resetFileBrowser();
|
|
|
|
|
void resetTerminal();
|
|
|
|
|
void updateTerminalUi(const Utils::TerminalCommand &term);
|
|
|
|
|
void updatePath();
|
2020-11-16 16:40:12 +01:00
|
|
|
void updateEnvironmentChangesLabel();
|
2020-09-21 12:58:35 +03:00
|
|
|
void updateClearCrashWidgets();
|
2020-01-08 19:06:42 +01:00
|
|
|
|
2020-09-21 12:58:35 +03:00
|
|
|
void showHelpDialog(const QString &title, const QString &helpText);
|
2022-07-20 10:42:06 +02:00
|
|
|
|
|
|
|
|
QComboBox *m_fileSystemCaseSensitivityChooser;
|
|
|
|
|
QSpinBox *m_autoSuspendMinDocumentCount;
|
|
|
|
|
QLineEdit *m_externalFileBrowserEdit;
|
|
|
|
|
QCheckBox *m_autoSuspendCheckBox;
|
|
|
|
|
QSpinBox *m_maxRecentFilesSpinBox;
|
|
|
|
|
QCheckBox *m_enableCrashReportingCheckBox;
|
|
|
|
|
QCheckBox *m_warnBeforeOpeningBigFiles;
|
|
|
|
|
QSpinBox *m_bigFilesLimitSpinBox;
|
|
|
|
|
QComboBox *m_terminalComboBox;
|
|
|
|
|
QLineEdit *m_terminalOpenArgs;
|
|
|
|
|
QLineEdit *m_terminalExecuteArgs;
|
|
|
|
|
Utils::PathChooser *m_patchChooser;
|
|
|
|
|
Utils::ElidingLabel *m_environmentChangesLabel;
|
|
|
|
|
QCheckBox *m_askBeforeExitCheckBox;
|
|
|
|
|
QComboBox *m_reloadBehavior;
|
|
|
|
|
QCheckBox *m_autoSaveCheckBox;
|
|
|
|
|
QPushButton *m_clearCrashReportsButton;
|
|
|
|
|
QLabel *m_crashReportsSizeText;
|
|
|
|
|
QSpinBox *m_autoSaveInterval;
|
|
|
|
|
QCheckBox *m_autoSaveRefactoringCheckBox;
|
2020-01-08 19:06:42 +01:00
|
|
|
QPointer<QMessageBox> m_dialog;
|
2020-11-16 16:40:12 +01:00
|
|
|
EnvironmentItems m_environmentChanges;
|
2020-01-08 19:06:42 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void SystemSettingsWidget::apply()
|
2015-08-14 13:25:31 +02:00
|
|
|
{
|
2021-12-10 09:05:17 +01:00
|
|
|
QtcSettings *settings = ICore::settings();
|
2022-07-20 10:42:06 +02:00
|
|
|
EditorManager::setReloadSetting(IDocument::ReloadSetting(m_reloadBehavior->currentIndex()));
|
2015-08-14 13:25:31 +02:00
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
2022-07-20 10:42:06 +02:00
|
|
|
TerminalCommand::setTerminalEmulator({m_terminalComboBox->lineEdit()->text(),
|
|
|
|
|
m_terminalOpenArgs->text(),
|
|
|
|
|
m_terminalExecuteArgs->text()});
|
2015-08-14 13:25:31 +02:00
|
|
|
if (!HostOsInfo::isMacHost()) {
|
2022-07-20 10:42:06 +02:00
|
|
|
UnixUtils::setFileBrowser(settings, m_externalFileBrowserEdit->text());
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-07-20 10:42:06 +02:00
|
|
|
PatchTool::setPatchCommand(m_patchChooser->filePath());
|
|
|
|
|
EditorManagerPrivate::setAutoSaveEnabled(m_autoSaveCheckBox->isChecked());
|
|
|
|
|
EditorManagerPrivate::setAutoSaveInterval(m_autoSaveInterval->value());
|
|
|
|
|
EditorManagerPrivate::setAutoSaveAfterRefactoring(m_autoSaveRefactoringCheckBox->isChecked());
|
|
|
|
|
EditorManagerPrivate::setAutoSuspendEnabled(m_autoSuspendCheckBox->isChecked());
|
|
|
|
|
EditorManagerPrivate::setAutoSuspendMinDocumentCount(m_autoSuspendMinDocumentCount->value());
|
2015-08-14 13:25:31 +02:00
|
|
|
EditorManagerPrivate::setWarnBeforeOpeningBigFilesEnabled(
|
2022-07-20 10:42:06 +02:00
|
|
|
m_warnBeforeOpeningBigFiles->isChecked());
|
|
|
|
|
EditorManagerPrivate::setBigFileSizeLimit(m_bigFilesLimitSpinBox->value());
|
|
|
|
|
EditorManagerPrivate::setMaxRecentFiles(m_maxRecentFilesSpinBox->value());
|
2020-09-21 12:58:35 +03:00
|
|
|
#ifdef ENABLE_CRASHPAD
|
|
|
|
|
ICore::settings()->setValue(crashReportingEnabledKey,
|
2022-07-20 10:42:06 +02:00
|
|
|
m_enableCrashReportingCheckBox->isChecked());
|
2020-09-21 12:58:35 +03:00
|
|
|
#endif
|
|
|
|
|
|
2022-07-20 10:42:06 +02:00
|
|
|
static_cast<Core::Internal::MainWindow *>(ICore::mainWindow())
|
|
|
|
|
->setAskConfirmationBeforeExit(m_askBeforeExitCheckBox->isChecked());
|
2015-08-14 16:45:23 +02:00
|
|
|
|
|
|
|
|
if (HostOsInfo::isMacHost()) {
|
2021-12-10 09:05:17 +01:00
|
|
|
const Qt::CaseSensitivity sensitivity = EditorManagerPrivate::readFileSystemSensitivity(
|
|
|
|
|
settings);
|
|
|
|
|
const Qt::CaseSensitivity selectedSensitivity = Qt::CaseSensitivity(
|
2022-07-20 10:42:06 +02:00
|
|
|
m_fileSystemCaseSensitivityChooser->currentData().toInt());
|
2021-12-10 09:05:17 +01:00
|
|
|
if (selectedSensitivity != sensitivity) {
|
|
|
|
|
EditorManagerPrivate::writeFileSystemSensitivity(settings, selectedSensitivity);
|
|
|
|
|
RestartDialog dialog(
|
|
|
|
|
ICore::dialogParent(),
|
|
|
|
|
tr("The file system case sensitivity change will take effect after restart."));
|
|
|
|
|
dialog.exec();
|
|
|
|
|
}
|
2015-08-14 16:45:23 +02:00
|
|
|
}
|
2020-11-16 16:40:12 +01:00
|
|
|
|
|
|
|
|
CorePlugin::setEnvironmentChanges(m_environmentChanges);
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
void SystemSettingsWidget::resetTerminal()
|
2015-08-14 13:25:31 +02:00
|
|
|
{
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost())
|
2022-07-20 10:42:06 +02:00
|
|
|
m_terminalComboBox->setCurrentIndex(0);
|
2018-08-24 10:56:13 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
void SystemSettingsWidget::updateTerminalUi(const TerminalCommand &term)
|
2018-08-24 10:56:13 +02:00
|
|
|
{
|
2022-07-20 10:42:06 +02:00
|
|
|
m_terminalComboBox->lineEdit()->setText(term.command);
|
|
|
|
|
m_terminalOpenArgs->setText(term.openArgs);
|
|
|
|
|
m_terminalExecuteArgs->setText(term.executeArgs);
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
void SystemSettingsWidget::resetFileBrowser()
|
2015-08-14 13:25:31 +02:00
|
|
|
{
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
|
2022-07-20 10:42:06 +02:00
|
|
|
m_externalFileBrowserEdit->setText(UnixUtils::defaultFileBrowser());
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
void SystemSettingsWidget::updatePath()
|
2015-08-14 13:25:31 +02:00
|
|
|
{
|
2021-08-03 15:12:24 +02:00
|
|
|
EnvironmentChange change;
|
2021-11-10 16:28:53 +01:00
|
|
|
change.addAppendToPath(VcsManager::additionalToolsPath());
|
2022-07-20 10:42:06 +02:00
|
|
|
m_patchChooser->setEnvironmentChange(change);
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-16 16:40:12 +01:00
|
|
|
void SystemSettingsWidget::updateEnvironmentChangesLabel()
|
|
|
|
|
{
|
|
|
|
|
const QString shortSummary = Utils::EnvironmentItem::toStringList(m_environmentChanges)
|
|
|
|
|
.join("; ");
|
2022-07-20 10:42:06 +02:00
|
|
|
m_environmentChangesLabel->setText(shortSummary.isEmpty() ? tr("No changes to apply.")
|
|
|
|
|
: shortSummary);
|
2020-11-16 16:40:12 +01:00
|
|
|
}
|
|
|
|
|
|
2020-09-21 12:58:35 +03:00
|
|
|
void SystemSettingsWidget::showHelpDialog(const QString &title, const QString &helpText)
|
2015-08-14 13:25:31 +02:00
|
|
|
{
|
|
|
|
|
if (m_dialog) {
|
2020-09-21 12:58:35 +03:00
|
|
|
if (m_dialog->windowTitle() != title)
|
|
|
|
|
m_dialog->setText(helpText);
|
|
|
|
|
|
2015-08-14 13:25:31 +02:00
|
|
|
if (m_dialog->text() != helpText)
|
|
|
|
|
m_dialog->setText(helpText);
|
|
|
|
|
|
|
|
|
|
m_dialog->show();
|
|
|
|
|
ICore::raiseWindow(m_dialog);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-09-21 12:58:35 +03:00
|
|
|
auto mb = new QMessageBox(QMessageBox::Information, title, helpText, QMessageBox::Close, this);
|
2015-08-14 13:25:31 +02:00
|
|
|
mb->setWindowModality(Qt::NonModal);
|
|
|
|
|
m_dialog = mb;
|
|
|
|
|
mb->show();
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-21 12:58:35 +03:00
|
|
|
#ifdef ENABLE_CRASHPAD
|
|
|
|
|
void SystemSettingsWidget::updateClearCrashWidgets()
|
|
|
|
|
{
|
2021-06-03 10:55:12 +02:00
|
|
|
QDir crashReportsDir(ICore::crashReportsPath().toDir());
|
2020-09-21 12:58:35 +03:00
|
|
|
crashReportsDir.setFilter(QDir::Files);
|
|
|
|
|
qint64 size = 0;
|
|
|
|
|
const QStringList crashFiles = crashReportsDir.entryList();
|
|
|
|
|
for (QString file : crashFiles)
|
|
|
|
|
size += QFileInfo(crashReportsDir, file).size();
|
|
|
|
|
|
2022-07-20 10:42:06 +02:00
|
|
|
m_clearCrashReportsButton->setEnabled(!crashFiles.isEmpty());
|
|
|
|
|
m_crashReportsSizeText->setText(formatSize(size));
|
2020-09-21 12:58:35 +03:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
void SystemSettingsWidget::showHelpForFileBrowser()
|
2015-08-14 13:25:31 +02:00
|
|
|
{
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
|
2020-09-21 12:58:35 +03:00
|
|
|
showHelpDialog(tr("Variables"), UnixUtils::fileBrowserHelpText());
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
SystemSettings::SystemSettings()
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::SETTINGS_ID_SYSTEM);
|
2020-02-04 09:02:50 +01:00
|
|
|
setDisplayName(SystemSettingsWidget::tr("System"));
|
2020-01-08 19:06:42 +01:00
|
|
|
setCategory(Constants::SETTINGS_CATEGORY_CORE);
|
2020-01-09 14:32:38 +01:00
|
|
|
setWidgetCreator([] { return new SystemSettingsWidget; });
|
2020-01-08 19:06:42 +01:00
|
|
|
}
|
|
|
|
|
|
2015-08-14 13:25:31 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Core
|