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>
|
2015-08-14 13:25:31 +02:00
|
|
|
#include <utils/checkablemessagebox.h>
|
|
|
|
|
#include <utils/consoleprocess.h>
|
|
|
|
|
#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>
|
|
|
|
|
#include <utils/unixutils.h>
|
|
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
|
|
|
|
|
#include "ui_systemsettings.h"
|
|
|
|
|
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
m_ui.setupUi(this);
|
|
|
|
|
m_ui.terminalOpenArgs->setToolTip(
|
2019-04-26 20:47:23 +02:00
|
|
|
tr("Command line arguments used for \"%1\".").arg(FileUtils::msgTerminalHereAction()));
|
2015-08-14 13:25:31 +02:00
|
|
|
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.reloadBehavior->setCurrentIndex(EditorManager::reloadSetting());
|
2015-08-14 13:25:31 +02:00
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
2018-08-24 10:56:13 +02:00
|
|
|
const QVector<TerminalCommand> availableTerminals = ConsoleProcess::availableTerminalEmulators();
|
|
|
|
|
for (const TerminalCommand &term : availableTerminals)
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.terminalComboBox->addItem(term.command, QVariant::fromValue(term));
|
2018-08-24 10:56:13 +02:00
|
|
|
updateTerminalUi(ConsoleProcess::terminalEmulator(ICore::settings()));
|
2020-01-08 19:06:42 +01:00
|
|
|
connect(m_ui.terminalComboBox,
|
2018-08-24 10:56:13 +02:00
|
|
|
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
|
this,
|
|
|
|
|
[this](int index) {
|
|
|
|
|
updateTerminalUi(
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.terminalComboBox->itemData(index).value<TerminalCommand>());
|
2018-08-24 10:56:13 +02:00
|
|
|
});
|
2015-08-14 13:25:31 +02:00
|
|
|
} else {
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.terminalLabel->hide();
|
|
|
|
|
m_ui.terminalComboBox->hide();
|
|
|
|
|
m_ui.terminalOpenArgs->hide();
|
|
|
|
|
m_ui.terminalExecuteArgs->hide();
|
|
|
|
|
m_ui.resetTerminalButton->hide();
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost()) {
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.externalFileBrowserEdit->setText(UnixUtils::fileBrowser(ICore::settings()));
|
2015-08-14 13:25:31 +02:00
|
|
|
} else {
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.externalFileBrowserLabel->hide();
|
2020-11-16 15:50:04 +01:00
|
|
|
m_ui.externalFileBrowserWidget->hide();
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString patchToolTip = tr("Command used for reverting diff chunks.");
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.patchCommandLabel->setToolTip(patchToolTip);
|
|
|
|
|
m_ui.patchChooser->setToolTip(patchToolTip);
|
|
|
|
|
m_ui.patchChooser->setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
m_ui.patchChooser->setHistoryCompleter(QLatin1String("General.PatchCommand.History"));
|
|
|
|
|
m_ui.patchChooser->setPath(PatchTool::patchCommand());
|
|
|
|
|
m_ui.autoSaveCheckBox->setChecked(EditorManagerPrivate::autoSaveEnabled());
|
|
|
|
|
m_ui.autoSaveCheckBox->setToolTip(tr("Automatically creates temporary copies of "
|
2017-08-29 11:48:48 +02:00
|
|
|
"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));
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.autoSaveInterval->setValue(EditorManagerPrivate::autoSaveInterval());
|
|
|
|
|
m_ui.autoSuspendCheckBox->setChecked(EditorManagerPrivate::autoSuspendEnabled());
|
|
|
|
|
m_ui.autoSuspendMinDocumentCount->setValue(EditorManagerPrivate::autoSuspendMinDocumentCount());
|
|
|
|
|
m_ui.warnBeforeOpeningBigFiles->setChecked(
|
2015-08-14 13:25:31 +02:00
|
|
|
EditorManagerPrivate::warnBeforeOpeningBigFilesEnabled());
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.bigFilesLimitSpinBox->setValue(EditorManagerPrivate::bigFileSizeLimit());
|
|
|
|
|
m_ui.maxRecentFilesSpinBox->setMinimum(1);
|
|
|
|
|
m_ui.maxRecentFilesSpinBox->setMaximum(99);
|
|
|
|
|
m_ui.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;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_ui.enableCrashReportingCheckBox->setChecked(
|
|
|
|
|
ICore::settings()->value(crashReportingEnabledKey).toBool());
|
|
|
|
|
connect(m_ui.helpCrashReportingButton, &QAbstractButton::clicked, this, [this] {
|
|
|
|
|
showHelpDialog(tr("Crash Reporting"), CorePlugin::msgCrashpadInformation());
|
|
|
|
|
});
|
|
|
|
|
connect(m_ui.enableCrashReportingCheckBox,
|
|
|
|
|
QOverload<int>::of(&QCheckBox::stateChanged), this, [this] {
|
|
|
|
|
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();
|
|
|
|
|
connect(m_ui.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();
|
|
|
|
|
});
|
|
|
|
|
#else
|
|
|
|
|
m_ui.enableCrashReportingCheckBox->setVisible(false);
|
|
|
|
|
m_ui.helpCrashReportingButton->setVisible(false);
|
|
|
|
|
m_ui.clearCrashReportsButton->setVisible(false);
|
|
|
|
|
m_ui.crashReportsSizeText->setVisible(false);
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-11-26 11:20:02 +01:00
|
|
|
m_ui.askBeforeExitCheckBox->setChecked(
|
|
|
|
|
static_cast<Core::Internal::MainWindow *>(ICore::mainWindow())->askConfirmationBeforeExit());
|
2015-08-14 13:25:31 +02:00
|
|
|
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
2020-01-08 19:06:42 +01:00
|
|
|
connect(m_ui.resetTerminalButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &SystemSettingsWidget::resetTerminal);
|
2015-08-14 13:25:31 +02:00
|
|
|
if (!HostOsInfo::isMacHost()) {
|
2020-01-08 19:06:42 +01:00
|
|
|
connect(m_ui.resetFileBrowserButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &SystemSettingsWidget::resetFileBrowser);
|
|
|
|
|
connect(m_ui.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) {
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.fileSystemCaseSensitivityChooser->addItem(tr("Case Sensitive (Default)"),
|
2015-08-14 16:45:23 +02:00
|
|
|
Qt::CaseSensitive);
|
|
|
|
|
} else {
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.fileSystemCaseSensitivityChooser->addItem(tr("Case Sensitive"),
|
2015-08-14 16:45:23 +02:00
|
|
|
Qt::CaseSensitive);
|
|
|
|
|
}
|
|
|
|
|
if (defaultSensitivity == Qt::CaseInsensitive) {
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.fileSystemCaseSensitivityChooser->addItem(tr("Case Insensitive (Default)"),
|
2015-08-14 16:45:23 +02:00
|
|
|
Qt::CaseInsensitive);
|
|
|
|
|
} else {
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.fileSystemCaseSensitivityChooser->addItem(tr("Case Insensitive"),
|
2015-08-14 16:45:23 +02:00
|
|
|
Qt::CaseInsensitive);
|
|
|
|
|
}
|
|
|
|
|
if (HostOsInfo::fileNameCaseSensitivity() == Qt::CaseSensitive)
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.fileSystemCaseSensitivityChooser->setCurrentIndex(0);
|
2015-08-14 16:45:23 +02:00
|
|
|
else
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.fileSystemCaseSensitivityChooser->setCurrentIndex(1);
|
2015-08-14 16:45:23 +02:00
|
|
|
} else {
|
2020-11-16 15:50:04 +01:00
|
|
|
m_ui.fileSystemCaseSensitivityLabel->hide();
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.fileSystemCaseSensitivityWidget->hide();
|
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
|
|
|
|
2020-11-16 16:40:12 +01:00
|
|
|
m_ui.environmentChangesLabel->setElideMode(Qt::ElideRight);
|
|
|
|
|
m_environmentChanges = CorePlugin::environmentChanges();
|
|
|
|
|
updateEnvironmentChangesLabel();
|
|
|
|
|
connect(m_ui.environmentButton, &QPushButton::clicked, [this] {
|
|
|
|
|
Utils::optional<EnvironmentItems> changes
|
|
|
|
|
= Utils::EnvironmentDialog::getEnvironmentItems(m_ui.environmentButton,
|
|
|
|
|
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);
|
2020-01-08 19:06:42 +01:00
|
|
|
Ui::SystemSettings m_ui;
|
|
|
|
|
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
|
|
|
{
|
2020-01-08 19:06:42 +01:00
|
|
|
EditorManager::setReloadSetting(IDocument::ReloadSetting(m_ui.reloadBehavior->currentIndex()));
|
2015-08-14 13:25:31 +02:00
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
|
|
|
|
ConsoleProcess::setTerminalEmulator(ICore::settings(),
|
2020-01-08 19:06:42 +01:00
|
|
|
{m_ui.terminalComboBox->lineEdit()->text(),
|
|
|
|
|
m_ui.terminalOpenArgs->text(),
|
|
|
|
|
m_ui.terminalExecuteArgs->text()});
|
2015-08-14 13:25:31 +02:00
|
|
|
if (!HostOsInfo::isMacHost()) {
|
|
|
|
|
UnixUtils::setFileBrowser(ICore::settings(),
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.externalFileBrowserEdit->text());
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
2020-04-09 11:35:12 +02:00
|
|
|
PatchTool::setPatchCommand(m_ui.patchChooser->filePath().toString());
|
2020-01-08 19:06:42 +01:00
|
|
|
EditorManagerPrivate::setAutoSaveEnabled(m_ui.autoSaveCheckBox->isChecked());
|
|
|
|
|
EditorManagerPrivate::setAutoSaveInterval(m_ui.autoSaveInterval->value());
|
|
|
|
|
EditorManagerPrivate::setAutoSuspendEnabled(m_ui.autoSuspendCheckBox->isChecked());
|
|
|
|
|
EditorManagerPrivate::setAutoSuspendMinDocumentCount(m_ui.autoSuspendMinDocumentCount->value());
|
2015-08-14 13:25:31 +02:00
|
|
|
EditorManagerPrivate::setWarnBeforeOpeningBigFilesEnabled(
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.warnBeforeOpeningBigFiles->isChecked());
|
|
|
|
|
EditorManagerPrivate::setBigFileSizeLimit(m_ui.bigFilesLimitSpinBox->value());
|
|
|
|
|
EditorManagerPrivate::setMaxRecentFiles(m_ui.maxRecentFilesSpinBox->value());
|
2020-09-21 12:58:35 +03:00
|
|
|
#ifdef ENABLE_CRASHPAD
|
|
|
|
|
ICore::settings()->setValue(crashReportingEnabledKey,
|
|
|
|
|
m_ui.enableCrashReportingCheckBox->isChecked());
|
|
|
|
|
#endif
|
|
|
|
|
|
2019-11-26 11:20:02 +01:00
|
|
|
static_cast<Core::Internal::MainWindow *>(ICore::mainWindow())->setAskConfirmationBeforeExit(
|
|
|
|
|
m_ui.askBeforeExitCheckBox->isChecked());
|
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
|
|
|
Qt::CaseSensitivity selectedSensitivity = Qt::CaseSensitivity(
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.fileSystemCaseSensitivityChooser->currentData().toInt());
|
2015-08-14 16:45:23 +02:00
|
|
|
if (defaultSensitivity == selectedSensitivity)
|
|
|
|
|
HostOsInfo::unsetOverrideFileNameCaseSensitivity();
|
|
|
|
|
else
|
|
|
|
|
HostOsInfo::setOverrideFileNameCaseSensitivity(selectedSensitivity);
|
|
|
|
|
}
|
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())
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.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
|
|
|
{
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.terminalComboBox->lineEdit()->setText(term.command);
|
|
|
|
|
m_ui.terminalOpenArgs->setText(term.openArgs);
|
|
|
|
|
m_ui.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())
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.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
|
|
|
{
|
|
|
|
|
Environment env = Environment::systemEnvironment();
|
|
|
|
|
QStringList toAdd = VcsManager::additionalToolsPath();
|
|
|
|
|
env.appendOrSetPath(toAdd.join(HostOsInfo::pathListSeparator()));
|
2020-01-08 19:06:42 +01:00
|
|
|
m_ui.patchChooser->setEnvironment(env);
|
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("; ");
|
|
|
|
|
m_ui.environmentChangesLabel->setText(shortSummary.isEmpty() ? tr("No changes to apply.")
|
|
|
|
|
: shortSummary);
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
m_ui.clearCrashReportsButton->setEnabled(!crashFiles.isEmpty());
|
|
|
|
|
m_ui.crashReportsSizeText->setText(formatSize(size));
|
|
|
|
|
}
|
|
|
|
|
#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
|