Split general settings page in two

It was too crowded to add anything to it. Split it into "interface" and
"system" related pages.

Change-Id: I2aa7984de4d672ca000e991b0cfb32a3f706c988
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
Eike Ziller
2015-08-14 13:25:31 +02:00
parent f1e8aec7ac
commit 2db21dc201
13 changed files with 570 additions and 409 deletions

View File

@@ -232,10 +232,11 @@ const char WIZARD_KIND_FILE[] = "file";
const char SETTINGS_CATEGORY_CORE[] = "A.Core";
const char SETTINGS_CATEGORY_CORE_ICON[] = ":/core/images/category_core.png";
const char SETTINGS_TR_CATEGORY_CORE[] = QT_TRANSLATE_NOOP("Core", "Environment");
const char SETTINGS_ID_ENVIRONMENT[] = "A.General";
const char SETTINGS_ID_SHORTCUTS[] = "B.Keyboard";
const char SETTINGS_ID_TOOLS[] = "C.ExternalTools";
const char SETTINGS_ID_MIMETYPES[] = "D.MimeTypes";
const char SETTINGS_ID_INTERFACE[] = "A.Interface";
const char SETTINGS_ID_SYSTEM[] = "B.Core.System";
const char SETTINGS_ID_SHORTCUTS[] = "C.Keyboard";
const char SETTINGS_ID_TOOLS[] = "D.ExternalTools";
const char SETTINGS_ID_MIMETYPES[] = "E.MimeTypes";
const char SETTINGS_DEFAULTTEXTENCODING[] = "General/DefaultFileEncoding";

View File

@@ -117,7 +117,8 @@ SOURCES += corejsextensions.cpp \
themeeditor/themesettingsitemdelegate.cpp \
messagebox.cpp \
iwelcomepage.cpp \
externaltoolmanager.cpp
externaltoolmanager.cpp \
systemsettings.cpp
HEADERS += corejsextensions.h \
mainwindow.h \
@@ -234,7 +235,8 @@ HEADERS += corejsextensions.h \
themeeditor/sectionedtablemodel.h \
themeeditor/themesettingsitemdelegate.h \
messagebox.h \
iwelcomepage.h
iwelcomepage.h \
systemsettings.h
FORMS += dialogs/newdialog.ui \
dialogs/saveitemsdialog.ui \
@@ -247,7 +249,8 @@ FORMS += dialogs/newdialog.ui \
mimetypemagicdialog.ui \
removefiledialog.ui \
dialogs/addtovcsdialog.ui \
themeeditor/themeeditorwidget.ui
themeeditor/themeeditorwidget.ui \
systemsettings.ui
RESOURCES += core.qrc \
fancyactionbar.qrc

View File

@@ -97,6 +97,7 @@ QtcPlugin {
"statusbarmanager.cpp", "statusbarmanager.h",
"statusbarwidget.cpp", "statusbarwidget.h",
"styleanimator.cpp", "styleanimator.h",
"systemsettings.cpp", "systemsettings.h", "systemsettings.ui",
"tabpositionindicator.cpp", "tabpositionindicator.h",
"textdocument.cpp", "textdocument.h",
"themesettings.cpp", "themesettings.h", "themesettings.ui",

View File

@@ -67,7 +67,7 @@ static void showGraphicalShellError(QWidget *parent, const QString &app, const Q
QMessageBox::ActionRole);
mbox.exec();
if (mbox.clickedButton() == settingsButton)
ICore::showOptionsDialog(Constants::SETTINGS_ID_ENVIRONMENT, parent);
ICore::showOptionsDialog(Constants::SETTINGS_ID_INTERFACE, parent);
}
void FileUtils::showInGraphicalShell(QWidget *parent, const QString &pathIn)

View File

@@ -32,23 +32,15 @@
#include "coreconstants.h"
#include "icore.h"
#include "infobar.h"
#include "patchtool.h"
#include "vcsmanager.h"
#include "editormanager/editormanager_p.h"
#include <utils/checkablemessagebox.h>
#include <utils/consoleprocess.h>
#include <utils/environment.h>
#include <utils/hostosinfo.h>
#include <utils/stylehelper.h>
#include <utils/unixutils.h>
#include <QCoreApplication>
#include <QDir>
#include <QLibraryInfo>
#include <QMessageBox>
#include <QSettings>
#include <QTextStream>
#include "ui_generalsettings.h"
@@ -60,8 +52,8 @@ namespace Internal {
GeneralSettings::GeneralSettings()
: m_page(0), m_dialog(0)
{
setId(Constants::SETTINGS_ID_ENVIRONMENT);
setDisplayName(tr("General"));
setId(Constants::SETTINGS_ID_INTERFACE);
setDisplayName(tr("Interface"));
setCategory(Constants::SETTINGS_CATEGORY_CORE);
setDisplayCategory(QCoreApplication::translate("Core", Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CORE_ICON));
@@ -114,58 +106,12 @@ QWidget *GeneralSettings::widget()
fillLanguageBox();
m_page->colorButton->setColor(StyleHelper::requestedBaseColor());
m_page->reloadBehavior->setCurrentIndex(EditorManager::reloadSetting());
if (HostOsInfo::isAnyUnixHost()) {
const QStringList availableTerminals = ConsoleProcess::availableTerminalEmulators();
const QString currentTerminal = ConsoleProcess::terminalEmulator(ICore::settings(), false);
m_page->terminalComboBox->addItems(availableTerminals);
m_page->terminalComboBox->lineEdit()->setText(currentTerminal);
m_page->terminalComboBox->lineEdit()->setPlaceholderText(ConsoleProcess::defaultTerminalEmulator());
} else {
m_page->terminalLabel->hide();
m_page->terminalComboBox->hide();
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());
m_page->autoSaveInterval->setValue(EditorManagerPrivate::autoSaveInterval());
m_page->warnBeforeOpeningBigFiles->setChecked(
EditorManagerPrivate::warnBeforeOpeningBigFilesEnabled());
m_page->bigFilesLimitSpinBox->setValue(EditorManagerPrivate::bigFileSizeLimit());
m_page->resetWarningsButton->setEnabled(canResetWarnings());
connect(m_page->resetColorButton, SIGNAL(clicked()),
this, SLOT(resetInterfaceColor()));
connect(m_page->resetWarningsButton, SIGNAL(clicked()),
this, SLOT(resetWarnings()));
if (HostOsInfo::isAnyUnixHost()) {
connect(m_page->resetTerminalButton, SIGNAL(clicked()), this, SLOT(resetTerminal()));
if (!HostOsInfo::isMacHost()) {
connect(m_page->resetFileBrowserButton, SIGNAL(clicked()), this, SLOT(resetFileBrowser()));
connect(m_page->helpExternalFileBrowserButton, SIGNAL(clicked()),
this, SLOT(showHelpForFileBrowser()));
}
}
updatePath();
connect(VcsManager::instance(), SIGNAL(configurationChanged(const IVersionControl*)),
this, SLOT(updatePath()));
}
return m_widget;
}
@@ -178,21 +124,6 @@ void GeneralSettings::apply()
setLanguage(m_page->languageBox->itemData(currentIndex, Qt::UserRole).toString());
// Apply the new base color if accepted
StyleHelper::setBaseColor(m_page->colorButton->color());
EditorManager::setReloadSetting(IDocument::ReloadSetting(m_page->reloadBehavior->currentIndex()));
if (HostOsInfo::isAnyUnixHost()) {
ConsoleProcess::setTerminalEmulator(ICore::settings(),
m_page->terminalComboBox->lineEdit()->text());
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());
EditorManagerPrivate::setWarnBeforeOpeningBigFilesEnabled(
m_page->warnBeforeOpeningBigFiles->isChecked());
EditorManagerPrivate::setBigFileSizeLimit(m_page->bigFilesLimitSpinBox->value());
m_page->themeWidget->apply();
}
@@ -215,59 +146,12 @@ void GeneralSettings::resetWarnings()
m_page->resetWarningsButton->setEnabled(false);
}
void GeneralSettings::resetTerminal()
{
if (HostOsInfo::isAnyUnixHost())
m_page->terminalComboBox->lineEdit()->clear();
}
void GeneralSettings::resetFileBrowser()
{
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
m_page->externalFileBrowserEdit->setText(UnixUtils::defaultFileBrowser());
}
void GeneralSettings::updatePath()
{
Environment env = Environment::systemEnvironment();
QStringList toAdd = VcsManager::additionalToolsPath();
env.appendOrSetPath(toAdd.join(HostOsInfo::pathListSeparator()));
m_page->patchChooser->setEnvironment(env);
}
bool GeneralSettings::canResetWarnings() const
{
return InfoBar::anyGloballySuppressed()
|| CheckableMessageBox::hasSuppressedQuestions(ICore::settings());
}
void GeneralSettings::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 GeneralSettings::showHelpForFileBrowser()
{
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
variableHelpDialogCreator(UnixUtils::fileBrowserHelpText());
}
void GeneralSettings::resetLanguage()
{
// system language is default

View File

@@ -58,14 +58,9 @@ private slots:
void resetInterfaceColor();
void resetWarnings();
void resetLanguage();
void showHelpForFileBrowser();
void resetFileBrowser();
void resetTerminal();
void updatePath();
private:
bool canResetWarnings() const;
void variableHelpDialogCreator(const QString &helpText);
void fillLanguageBox() const;
QString language() const;
void setLanguage(const QString&);

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>527</width>
<height>366</height>
<height>469</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -22,9 +22,6 @@
<property name="text">
<string>Color:</string>
</property>
<property name="buddy">
<cstring>colorButton</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
@@ -130,232 +127,6 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="systemBox">
<property name="title">
<string>System</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="terminalLabel">
<property name="text">
<string>Terminal:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="terminalComboBox">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="resetTerminalButton">
<property name="toolTip">
<string comment="Terminal">Reset to default.</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="externalFileBrowserLabel">
<property name="text">
<string>External file browser:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="externalFileBrowserEdit"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="resetFileBrowserButton">
<property name="toolTip">
<string comment="File Browser">Reset to default.</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QToolButton" name="helpExternalFileBrowserButton">
<property name="text">
<string>?</string>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/help.png</normaloff>:/core/images/help.png</iconset>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="patchCommandLabel">
<property name="text">
<string>Patch command:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="Utils::PathChooser" name="patchChooser" native="true"/>
</item>
<item row="3" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="modifiedLabel">
<property name="text">
<string>When files are externally modified:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="reloadBehavior">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Always Ask</string>
</property>
</item>
<item>
<property name="text">
<string>Reload All Unchanged Editors</string>
</property>
</item>
<item>
<property name="text">
<string>Ignore Modifications</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="autoSaveCheckBox">
<property name="toolTip">
<string>Automatically creates temporary copies of modified files. If Qt Creator is restarted after a crash or power failure, it asks whether to recover the auto-saved content.</string>
</property>
<property name="text">
<string>Auto-save modified files</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="autoSaveIntervalLabel">
<property name="text">
<string>Interval:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="autoSaveInterval">
<property name="suffix">
<string extracomment="unit for minutes">min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="5" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="warnBeforeOpeningBigFiles">
<property name="text">
<string>Warn before opening text files greater than</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="bigFilesLimitSpinBox">
<property name="suffix">
<string>MB</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
@@ -377,16 +148,6 @@
<extends>QToolButton</extends>
<header location="global">utils/qtcolorbutton.h</header>
</customwidget>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
<slots>
<signal>editingFinished()</signal>
<signal>browsingFinished()</signal>
</slots>
</customwidget>
<customwidget>
<class>Core::Internal::ThemeSettingsWidget</class>
<extends>QWidget</extends>
@@ -394,41 +155,6 @@
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="core.qrc"/>
</resources>
<connections>
<connection>
<sender>autoSaveCheckBox</sender>
<signal>toggled(bool)</signal>
<receiver>autoSaveInterval</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>181</x>
<y>310</y>
</hint>
<hint type="destinationlabel">
<x>340</x>
<y>311</y>
</hint>
</hints>
</connection>
<connection>
<sender>warnBeforeOpeningBigFiles</sender>
<signal>toggled(bool)</signal>
<receiver>bigFilesLimitSpinBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>124</x>
<y>330</y>
</hint>
<hint type="destinationlabel">
<x>305</x>
<y>332</y>
</hint>
</hints>
</connection>
</connections>
<resources/>
<connections/>
</ui>

View File

@@ -53,6 +53,7 @@
#include "rightpane.h"
#include "editormanager/ieditorfactory.h"
#include "statusbarwidget.h"
#include "systemsettings.h"
#include "externaltoolmanager.h"
#include "editormanager/systemeditor.h"
#include "windowsupport.h"
@@ -130,6 +131,7 @@ MainWindow::MainWindow() :
m_rightPaneWidget(0),
m_versionDialog(0),
m_generalSettings(new GeneralSettings),
m_systemSettings(new SystemSettings),
m_shortcutSettings(new ShortcutSettings),
m_toolSettings(new ToolSettings),
m_mimeTypeSettings(new MimeTypeSettings),
@@ -246,6 +248,7 @@ MainWindow::~MainWindow()
PluginManager::removeObject(m_shortcutSettings);
PluginManager::removeObject(m_generalSettings);
PluginManager::removeObject(m_systemSettings);
PluginManager::removeObject(m_toolSettings);
PluginManager::removeObject(m_mimeTypeSettings);
PluginManager::removeObject(m_systemEditor);
@@ -257,6 +260,8 @@ MainWindow::~MainWindow()
m_shortcutSettings = 0;
delete m_generalSettings;
m_generalSettings = 0;
delete m_systemSettings;
m_systemSettings = 0;
delete m_toolSettings;
m_toolSettings = 0;
delete m_mimeTypeSettings;
@@ -309,6 +314,7 @@ bool MainWindow::init(QString *errorMessage)
m_progressManager->init(); // needs the status bar manager
PluginManager::addObject(m_generalSettings);
PluginManager::addObject(m_systemSettings);
PluginManager::addObject(m_shortcutSettings);
PluginManager::addObject(m_toolSettings);
PluginManager::addObject(m_mimeTypeSettings);

View File

@@ -76,6 +76,7 @@ class StatusBarManager;
class VersionDialog;
class WindowSupport;
class SystemEditor;
class SystemSettings;
class MainWindow : public Utils::AppMainWindow
{
@@ -174,6 +175,7 @@ private:
QMap<QWidget *, IContext *> m_contextWidgets;
GeneralSettings *m_generalSettings;
SystemSettings *m_systemSettings;
ShortcutSettings *m_shortcutSettings;
ToolSettings *m_toolSettings;
MimeTypeSettings *m_mimeTypeSettings;

View File

@@ -0,0 +1,199 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** 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
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "systemsettings.h"
#include "coreconstants.h"
#include "editormanager/editormanager_p.h"
#include "icore.h"
#include "patchtool.h"
#include "vcsmanager.h"
#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()
: m_page(0), m_dialog(0)
{
setId(Constants::SETTINGS_ID_SYSTEM);
setDisplayName(tr("System"));
setCategory(Constants::SETTINGS_CATEGORY_CORE);
setDisplayCategory(QCoreApplication::translate("Core", Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CORE_ICON));
}
QWidget *SystemSettings::widget()
{
if (!m_widget) {
m_page = new Ui::SystemSettings();
m_widget = new QWidget;
m_page->setupUi(m_widget);
m_page->reloadBehavior->setCurrentIndex(EditorManager::reloadSetting());
if (HostOsInfo::isAnyUnixHost()) {
const QStringList availableTerminals = ConsoleProcess::availableTerminalEmulators();
const QString currentTerminal = ConsoleProcess::terminalEmulator(ICore::settings(), false);
m_page->terminalComboBox->addItems(availableTerminals);
m_page->terminalComboBox->lineEdit()->setText(currentTerminal);
m_page->terminalComboBox->lineEdit()->setPlaceholderText(ConsoleProcess::defaultTerminalEmulator());
} else {
m_page->terminalLabel->hide();
m_page->terminalComboBox->hide();
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());
m_page->autoSaveInterval->setValue(EditorManagerPrivate::autoSaveInterval());
m_page->warnBeforeOpeningBigFiles->setChecked(
EditorManagerPrivate::warnBeforeOpeningBigFilesEnabled());
m_page->bigFilesLimitSpinBox->setValue(EditorManagerPrivate::bigFileSizeLimit());
if (HostOsInfo::isAnyUnixHost()) {
connect(m_page->resetTerminalButton, SIGNAL(clicked()), this, SLOT(resetTerminal()));
if (!HostOsInfo::isMacHost()) {
connect(m_page->resetFileBrowserButton, SIGNAL(clicked()), this, SLOT(resetFileBrowser()));
connect(m_page->helpExternalFileBrowserButton, SIGNAL(clicked()),
this, SLOT(showHelpForFileBrowser()));
}
}
updatePath();
connect(VcsManager::instance(), SIGNAL(configurationChanged(const IVersionControl*)),
this, SLOT(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(),
m_page->terminalComboBox->lineEdit()->text());
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());
EditorManagerPrivate::setWarnBeforeOpeningBigFilesEnabled(
m_page->warnBeforeOpeningBigFiles->isChecked());
EditorManagerPrivate::setBigFileSizeLimit(m_page->bigFilesLimitSpinBox->value());
}
void SystemSettings::finish()
{
delete m_widget;
delete m_page;
m_page = 0;
}
void SystemSettings::resetTerminal()
{
if (HostOsInfo::isAnyUnixHost())
m_page->terminalComboBox->lineEdit()->clear();
}
void SystemSettings::resetFileBrowser()
{
if (HostOsInfo::isAnyUnixHost() && !HostOsInfo::isMacHost())
m_page->externalFileBrowserEdit->setText(UnixUtils::defaultFileBrowser());
}
void SystemSettings::updatePath()
{
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

View File

@@ -0,0 +1,73 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** 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
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef SYSTEMSETTINGS_H
#define SYSTEMSETTINGS_H
#include <coreplugin/dialogs/ioptionspage.h>
#include <QPointer>
QT_BEGIN_NAMESPACE
class QMessageBox;
QT_END_NAMESPACE
namespace Core {
namespace Internal {
namespace Ui { class SystemSettings; }
class SystemSettings : public IOptionsPage
{
Q_OBJECT
public:
SystemSettings();
QWidget *widget();
void apply();
void finish();
private slots:
void showHelpForFileBrowser();
void resetFileBrowser();
void resetTerminal();
void updatePath();
private:
void variableHelpDialogCreator(const QString &helpText);
Ui::SystemSettings *m_page;
QPointer<QMessageBox> m_dialog;
QPointer<QWidget> m_widget;
};
} // namespace Internal
} // namespace Core
#endif // SYSTEMSETTINGS_H

View File

@@ -0,0 +1,271 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Core::Internal::SystemSettings</class>
<widget class="QWidget" name="Core::Internal::SystemSettings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>527</width>
<height>469</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="systemBox">
<property name="title">
<string>System</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="terminalLabel">
<property name="text">
<string>Terminal:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="terminalComboBox">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="resetTerminalButton">
<property name="toolTip">
<string comment="Terminal">Reset to default.</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="externalFileBrowserLabel">
<property name="text">
<string>External file browser:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="externalFileBrowserEdit"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="resetFileBrowserButton">
<property name="toolTip">
<string comment="File Browser">Reset to default.</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QToolButton" name="helpExternalFileBrowserButton">
<property name="text">
<string>?</string>
</property>
<property name="icon">
<iconset resource="core.qrc">
<normaloff>:/core/images/help.png</normaloff>:/core/images/help.png</iconset>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="patchCommandLabel">
<property name="text">
<string>Patch command:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="Utils::PathChooser" name="patchChooser" native="true"/>
</item>
<item row="3" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="modifiedLabel">
<property name="text">
<string>When files are externally modified:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="reloadBehavior">
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Always Ask</string>
</property>
</item>
<item>
<property name="text">
<string>Reload All Unchanged Editors</string>
</property>
</item>
<item>
<property name="text">
<string>Ignore Modifications</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="4" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QCheckBox" name="autoSaveCheckBox">
<property name="toolTip">
<string>Automatically creates temporary copies of modified files. If Qt Creator is restarted after a crash or power failure, it asks whether to recover the auto-saved content.</string>
</property>
<property name="text">
<string>Auto-save modified files</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="autoSaveIntervalLabel">
<property name="text">
<string>Interval:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="autoSaveInterval">
<property name="suffix">
<string extracomment="unit for minutes">min</string>
</property>
<property name="minimum">
<number>1</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="5" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="warnBeforeOpeningBigFiles">
<property name="text">
<string>Warn before opening text files greater than</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="bigFilesLimitSpinBox">
<property name="suffix">
<string>MB</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>500</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>30</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
<slots>
<signal>editingFinished()</signal>
<signal>browsingFinished()</signal>
</slots>
</customwidget>
</customwidgets>
<resources>
<include location="core.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -40,7 +40,7 @@ namespace Internal {
ThemeSettings::ThemeSettings() :
m_widget(0)
{
setId(Constants::SETTINGS_ID_ENVIRONMENT);
setId(Constants::SETTINGS_ID_INTERFACE);
setDisplayName(tr("Theme"));
setCategory(Constants::SETTINGS_CATEGORY_CORE);
setDisplayCategory(QCoreApplication::translate("Core", Constants::SETTINGS_TR_CATEGORY_CORE));