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"
|
|
|
|
|
#include "editormanager/editormanager_p.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"
|
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>
|
|
|
|
|
#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 {
|
|
|
|
|
|
|
|
|
|
SystemSettings::SystemSettings()
|
2018-07-21 21:11:46 +02:00
|
|
|
: m_page(nullptr), m_dialog(nullptr)
|
2015-08-14 13:25:31 +02:00
|
|
|
{
|
|
|
|
|
setId(Constants::SETTINGS_ID_SYSTEM);
|
|
|
|
|
setDisplayName(tr("System"));
|
|
|
|
|
setCategory(Constants::SETTINGS_CATEGORY_CORE);
|
2016-06-23 15:31:58 +02:00
|
|
|
|
|
|
|
|
connect(VcsManager::instance(), &VcsManager::configurationChanged,
|
|
|
|
|
this, &SystemSettings::updatePath);
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *SystemSettings::widget()
|
|
|
|
|
{
|
|
|
|
|
if (!m_widget) {
|
|
|
|
|
m_page = new Ui::SystemSettings();
|
|
|
|
|
m_widget = new QWidget;
|
|
|
|
|
m_page->setupUi(m_widget);
|
2018-10-19 10:42:55 +02:00
|
|
|
m_page->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
|
|
|
|
|
|
|
|
m_page->reloadBehavior->setCurrentIndex(EditorManager::reloadSetting());
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
2018-08-24 10:56:13 +02:00
|
|
|
const QVector<TerminalCommand> availableTerminals = ConsoleProcess::availableTerminalEmulators();
|
|
|
|
|
for (const TerminalCommand &term : availableTerminals)
|
2019-05-27 13:32:20 +02:00
|
|
|
m_page->terminalComboBox->addItem(term.command, QVariant::fromValue(term));
|
2018-08-24 10:56:13 +02:00
|
|
|
updateTerminalUi(ConsoleProcess::terminalEmulator(ICore::settings()));
|
|
|
|
|
connect(m_page->terminalComboBox,
|
|
|
|
|
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
|
|
|
this,
|
|
|
|
|
[this](int index) {
|
|
|
|
|
updateTerminalUi(
|
|
|
|
|
m_page->terminalComboBox->itemData(index).value<TerminalCommand>());
|
|
|
|
|
});
|
2015-08-14 13:25:31 +02:00
|
|
|
} else {
|
|
|
|
|
m_page->terminalLabel->hide();
|
|
|
|
|
m_page->terminalComboBox->hide();
|
2018-08-24 10:56:13 +02:00
|
|
|
m_page->terminalOpenArgs->hide();
|
|
|
|
|
m_page->terminalExecuteArgs->hide();
|
2015-08-14 13:25:31 +02:00
|
|
|
m_page->resetTerminalButton->hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost()) {
|
|
|
|
|
m_page->externalFileBrowserEdit->setText(UnixUtils::fileBrowser(ICore::settings()));
|
|
|
|
|
} else {
|
|
|
|
|
m_page->externalFileBrowserLabel->hide();
|
|
|
|
|
m_page->externalFileBrowserEdit->hide();
|
|
|
|
|
m_page->resetFileBrowserButton->hide();
|
|
|
|
|
m_page->helpExternalFileBrowserButton->hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QString patchToolTip = tr("Command used for reverting diff chunks.");
|
|
|
|
|
m_page->patchCommandLabel->setToolTip(patchToolTip);
|
|
|
|
|
m_page->patchChooser->setToolTip(patchToolTip);
|
|
|
|
|
m_page->patchChooser->setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
m_page->patchChooser->setHistoryCompleter(QLatin1String("General.PatchCommand.History"));
|
|
|
|
|
m_page->patchChooser->setPath(PatchTool::patchCommand());
|
|
|
|
|
m_page->autoSaveCheckBox->setChecked(EditorManagerPrivate::autoSaveEnabled());
|
2017-08-29 11:48:48 +02:00
|
|
|
m_page->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));
|
2015-08-14 13:25:31 +02:00
|
|
|
m_page->autoSaveInterval->setValue(EditorManagerPrivate::autoSaveInterval());
|
2016-06-13 12:59:35 +02:00
|
|
|
m_page->autoSuspendCheckBox->setChecked(EditorManagerPrivate::autoSuspendEnabled());
|
|
|
|
|
m_page->autoSuspendMinDocumentCount->setValue(EditorManagerPrivate::autoSuspendMinDocumentCount());
|
2015-08-14 13:25:31 +02:00
|
|
|
m_page->warnBeforeOpeningBigFiles->setChecked(
|
|
|
|
|
EditorManagerPrivate::warnBeforeOpeningBigFilesEnabled());
|
|
|
|
|
m_page->bigFilesLimitSpinBox->setValue(EditorManagerPrivate::bigFileSizeLimit());
|
2019-06-24 15:09:03 +02:00
|
|
|
m_page->maxRecentFilesSpinBox->setMinimum(1);
|
|
|
|
|
m_page->maxRecentFilesSpinBox->setMaximum(99);
|
|
|
|
|
m_page->maxRecentFilesSpinBox->setValue(EditorManagerPrivate::maxRecentFiles());
|
2015-08-14 13:25:31 +02:00
|
|
|
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(m_page->resetTerminalButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &SystemSettings::resetTerminal);
|
2015-08-14 13:25:31 +02:00
|
|
|
if (!HostOsInfo::isMacHost()) {
|
2016-02-02 09:10:54 +02:00
|
|
|
connect(m_page->resetFileBrowserButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &SystemSettings::resetFileBrowser);
|
|
|
|
|
connect(m_page->helpExternalFileBrowserButton, &QAbstractButton::clicked,
|
|
|
|
|
this, &SystemSettings::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) {
|
|
|
|
|
m_page->fileSystemCaseSensitivityChooser->addItem(tr("Case Sensitive (Default)"),
|
|
|
|
|
Qt::CaseSensitive);
|
|
|
|
|
} else {
|
|
|
|
|
m_page->fileSystemCaseSensitivityChooser->addItem(tr("Case Sensitive"),
|
|
|
|
|
Qt::CaseSensitive);
|
|
|
|
|
}
|
|
|
|
|
if (defaultSensitivity == Qt::CaseInsensitive) {
|
|
|
|
|
m_page->fileSystemCaseSensitivityChooser->addItem(tr("Case Insensitive (Default)"),
|
|
|
|
|
Qt::CaseInsensitive);
|
|
|
|
|
} else {
|
|
|
|
|
m_page->fileSystemCaseSensitivityChooser->addItem(tr("Case Insensitive"),
|
|
|
|
|
Qt::CaseInsensitive);
|
|
|
|
|
}
|
|
|
|
|
if (HostOsInfo::fileNameCaseSensitivity() == Qt::CaseSensitive)
|
|
|
|
|
m_page->fileSystemCaseSensitivityChooser->setCurrentIndex(0);
|
|
|
|
|
else
|
|
|
|
|
m_page->fileSystemCaseSensitivityChooser->setCurrentIndex(1);
|
|
|
|
|
} else {
|
|
|
|
|
m_page->fileSystemCaseSensitivityWidget->hide();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-14 13:25:31 +02:00
|
|
|
updatePath();
|
|
|
|
|
}
|
|
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemSettings::apply()
|
|
|
|
|
{
|
|
|
|
|
if (!m_page) // wasn't shown, can't be changed
|
|
|
|
|
return;
|
|
|
|
|
EditorManager::setReloadSetting(IDocument::ReloadSetting(m_page->reloadBehavior->currentIndex()));
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost()) {
|
|
|
|
|
ConsoleProcess::setTerminalEmulator(ICore::settings(),
|
2018-08-24 10:56:13 +02:00
|
|
|
{m_page->terminalComboBox->lineEdit()->text(),
|
|
|
|
|
m_page->terminalOpenArgs->text(),
|
|
|
|
|
m_page->terminalExecuteArgs->text()});
|
2015-08-14 13:25:31 +02:00
|
|
|
if (!HostOsInfo::isMacHost()) {
|
|
|
|
|
UnixUtils::setFileBrowser(ICore::settings(),
|
|
|
|
|
m_page->externalFileBrowserEdit->text());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PatchTool::setPatchCommand(m_page->patchChooser->path());
|
|
|
|
|
EditorManagerPrivate::setAutoSaveEnabled(m_page->autoSaveCheckBox->isChecked());
|
|
|
|
|
EditorManagerPrivate::setAutoSaveInterval(m_page->autoSaveInterval->value());
|
2016-06-13 12:59:35 +02:00
|
|
|
EditorManagerPrivate::setAutoSuspendEnabled(m_page->autoSuspendCheckBox->isChecked());
|
|
|
|
|
EditorManagerPrivate::setAutoSuspendMinDocumentCount(m_page->autoSuspendMinDocumentCount->value());
|
2015-08-14 13:25:31 +02:00
|
|
|
EditorManagerPrivate::setWarnBeforeOpeningBigFilesEnabled(
|
|
|
|
|
m_page->warnBeforeOpeningBigFiles->isChecked());
|
|
|
|
|
EditorManagerPrivate::setBigFileSizeLimit(m_page->bigFilesLimitSpinBox->value());
|
2019-06-24 15:09:03 +02:00
|
|
|
EditorManagerPrivate::setMaxRecentFiles(m_page->maxRecentFilesSpinBox->value());
|
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(
|
|
|
|
|
m_page->fileSystemCaseSensitivityChooser->currentData().toInt());
|
|
|
|
|
if (defaultSensitivity == selectedSensitivity)
|
|
|
|
|
HostOsInfo::unsetOverrideFileNameCaseSensitivity();
|
|
|
|
|
else
|
|
|
|
|
HostOsInfo::setOverrideFileNameCaseSensitivity(selectedSensitivity);
|
|
|
|
|
}
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemSettings::finish()
|
|
|
|
|
{
|
|
|
|
|
delete m_widget;
|
|
|
|
|
delete m_page;
|
2018-07-21 21:11:46 +02:00
|
|
|
m_page = nullptr;
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemSettings::resetTerminal()
|
|
|
|
|
{
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost())
|
2018-08-24 10:56:13 +02:00
|
|
|
m_page->terminalComboBox->setCurrentIndex(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemSettings::updateTerminalUi(const TerminalCommand &term)
|
|
|
|
|
{
|
|
|
|
|
m_page->terminalComboBox->lineEdit()->setText(term.command);
|
|
|
|
|
m_page->terminalOpenArgs->setText(term.openArgs);
|
|
|
|
|
m_page->terminalExecuteArgs->setText(term.executeArgs);
|
2015-08-14 13:25:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemSettings::resetFileBrowser()
|
|
|
|
|
{
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
|
|
|
|
|
m_page->externalFileBrowserEdit->setText(UnixUtils::defaultFileBrowser());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemSettings::updatePath()
|
|
|
|
|
{
|
2016-06-23 15:31:58 +02:00
|
|
|
if (!m_page)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-08-14 13:25:31 +02:00
|
|
|
Environment env = Environment::systemEnvironment();
|
|
|
|
|
QStringList toAdd = VcsManager::additionalToolsPath();
|
|
|
|
|
env.appendOrSetPath(toAdd.join(HostOsInfo::pathListSeparator()));
|
|
|
|
|
m_page->patchChooser->setEnvironment(env);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SystemSettings::variableHelpDialogCreator(const QString &helpText)
|
|
|
|
|
{
|
|
|
|
|
if (m_dialog) {
|
|
|
|
|
if (m_dialog->text() != helpText)
|
|
|
|
|
m_dialog->setText(helpText);
|
|
|
|
|
|
|
|
|
|
m_dialog->show();
|
|
|
|
|
ICore::raiseWindow(m_dialog);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QMessageBox *mb = new QMessageBox(QMessageBox::Information,
|
|
|
|
|
tr("Variables"),
|
|
|
|
|
helpText,
|
|
|
|
|
QMessageBox::Close,
|
|
|
|
|
m_widget);
|
|
|
|
|
mb->setWindowModality(Qt::NonModal);
|
|
|
|
|
m_dialog = mb;
|
|
|
|
|
mb->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SystemSettings::showHelpForFileBrowser()
|
|
|
|
|
{
|
|
|
|
|
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
|
|
|
|
|
variableHelpDialogCreator(UnixUtils::fileBrowserHelpText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Core
|