forked from qt-creator/qt-creator
Core: Move SystemSettings page closer to current setup
Also align items a bit and use BaseAspect::setEnabler() where appropriate. Change-Id: I7497e3ce82f3685582a84b1bf383e65892d76f96 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
#include <coreplugin/editormanager/iexternaleditor.h>
|
#include <coreplugin/editormanager/iexternaleditor.h>
|
||||||
|
#include <coreplugin/systemsettings.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
@@ -1336,7 +1337,8 @@ void DocumentManager::addToRecentFiles(const FilePath &filePath, Id editorId)
|
|||||||
Utils::erase(d->m_recentFiles, [fileKey](const RecentFile &file) {
|
Utils::erase(d->m_recentFiles, [fileKey](const RecentFile &file) {
|
||||||
return fileKey == filePathKey(file.first, DocumentManager::KeepLinks);
|
return fileKey == filePathKey(file.first, DocumentManager::KeepLinks);
|
||||||
});
|
});
|
||||||
while (d->m_recentFiles.count() >= EditorManagerPrivate::maxRecentFiles())
|
const int maxRecentFiles = systemSettings().maxRecentFiles();
|
||||||
|
while (d->m_recentFiles.count() >= maxRecentFiles)
|
||||||
d->m_recentFiles.removeLast();
|
d->m_recentFiles.removeLast();
|
||||||
d->m_recentFiles.prepend(RecentFile(filePath, editorId));
|
d->m_recentFiles.prepend(RecentFile(filePath, editorId));
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "../outputpanemanager.h"
|
#include "../outputpanemanager.h"
|
||||||
#include "../rightpane.h"
|
#include "../rightpane.h"
|
||||||
#include "../settingsdatabase.h"
|
#include "../settingsdatabase.h"
|
||||||
|
#include "../systemsettings.h"
|
||||||
#include "../vcsmanager.h"
|
#include "../vcsmanager.h"
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
@@ -90,15 +91,6 @@ static const char kCurrentDocumentYPos[] = "CurrentDocument:YPos";
|
|||||||
static const char kMakeWritableWarning[] = "Core.EditorManager.MakeWritable";
|
static const char kMakeWritableWarning[] = "Core.EditorManager.MakeWritable";
|
||||||
|
|
||||||
static const char documentStatesKey[] = "EditorManager/DocumentStates";
|
static const char documentStatesKey[] = "EditorManager/DocumentStates";
|
||||||
static const char reloadBehaviorKey[] = "EditorManager/ReloadBehavior";
|
|
||||||
static const char autoSaveEnabledKey[] = "EditorManager/AutoSaveEnabled";
|
|
||||||
static const char autoSaveIntervalKey[] = "EditorManager/AutoSaveInterval";
|
|
||||||
static const char autoSaveAfterRefactoringKey[] = "EditorManager/AutoSaveAfterRefactoring";
|
|
||||||
static const char autoSuspendEnabledKey[] = "EditorManager/AutoSuspendEnabled";
|
|
||||||
static const char autoSuspendMinDocumentCountKey[] = "EditorManager/AutoSuspendMinDocuments";
|
|
||||||
static const char warnBeforeOpeningBigTextFilesKey[] = "EditorManager/WarnBeforeOpeningBigTextFiles";
|
|
||||||
static const char bigTextFileSizeLimitKey[] = "EditorManager/BigTextFileSizeLimitInMB";
|
|
||||||
static const char maxRecentFilesKey[] = "EditorManager/MaxRecentFiles";
|
|
||||||
static const char fileSystemCaseSensitivityKey[] = "Core/FileSystemCaseSensitivity";
|
static const char fileSystemCaseSensitivityKey[] = "Core/FileSystemCaseSensitivity";
|
||||||
static const char preferredEditorFactoriesKey[] = "EditorManager/PreferredEditorFactories";
|
static const char preferredEditorFactoriesKey[] = "EditorManager/PreferredEditorFactories";
|
||||||
|
|
||||||
@@ -732,7 +724,7 @@ EditorArea *EditorManagerPrivate::mainEditorArea()
|
|||||||
|
|
||||||
bool EditorManagerPrivate::skipOpeningBigTextFile(const FilePath &filePath)
|
bool EditorManagerPrivate::skipOpeningBigTextFile(const FilePath &filePath)
|
||||||
{
|
{
|
||||||
if (!d->m_settings.warnBeforeOpeningBigFilesEnabled)
|
if (!systemSettings().warnBeforeOpeningBigFiles())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!filePath.exists())
|
if (!filePath.exists())
|
||||||
@@ -745,7 +737,7 @@ bool EditorManagerPrivate::skipOpeningBigTextFile(const FilePath &filePath)
|
|||||||
|
|
||||||
const qint64 fileSize = filePath.fileSize();
|
const qint64 fileSize = filePath.fileSize();
|
||||||
const double fileSizeInMB = fileSize / 1000.0 / 1000.0;
|
const double fileSizeInMB = fileSize / 1000.0 / 1000.0;
|
||||||
if (fileSizeInMB > d->m_settings.bigFileSizeLimitInMB
|
if (fileSizeInMB > systemSettings().bigFileSizeLimitInMB()
|
||||||
&& fileSize < EditorManager::maxTextFileSize()) {
|
&& fileSize < EditorManager::maxTextFileSize()) {
|
||||||
const QString title = ::Core::Tr::tr("Continue Opening Huge Text File?");
|
const QString title = ::Core::Tr::tr("Continue Opening Huge Text File?");
|
||||||
const QString text = ::Core::Tr::tr(
|
const QString text = ::Core::Tr::tr(
|
||||||
@@ -761,7 +753,7 @@ bool EditorManagerPrivate::skipOpeningBigTextFile(const FilePath &filePath)
|
|||||||
|
|
||||||
QMessageBox::StandardButton clickedButton
|
QMessageBox::StandardButton clickedButton
|
||||||
= CheckableMessageBox::question(ICore::dialogParent(), title, text, decider);
|
= CheckableMessageBox::question(ICore::dialogParent(), title, text, decider);
|
||||||
setWarnBeforeOpeningBigFilesEnabled(askAgain);
|
systemSettings().warnBeforeOpeningBigFiles.setValue(askAgain);
|
||||||
return clickedButton != QMessageBox::Yes;
|
return clickedButton != QMessageBox::Yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1217,51 +1209,14 @@ void EditorManagerPrivate::saveSettings()
|
|||||||
{
|
{
|
||||||
ICore::settingsDatabase()->setValue(documentStatesKey, d->m_editorStates);
|
ICore::settingsDatabase()->setValue(documentStatesKey, d->m_editorStates);
|
||||||
|
|
||||||
const Settings def;
|
|
||||||
QtcSettings *qsettings = ICore::settings();
|
QtcSettings *qsettings = ICore::settings();
|
||||||
qsettings->setValueWithDefault(reloadBehaviorKey,
|
|
||||||
int(d->m_settings.reloadSetting),
|
|
||||||
int(def.reloadSetting));
|
|
||||||
qsettings->setValueWithDefault(autoSaveEnabledKey,
|
|
||||||
d->m_settings.autoSaveEnabled,
|
|
||||||
def.autoSaveEnabled);
|
|
||||||
qsettings->setValueWithDefault(autoSaveIntervalKey,
|
|
||||||
d->m_settings.autoSaveInterval,
|
|
||||||
def.autoSaveInterval);
|
|
||||||
qsettings->setValueWithDefault(autoSaveAfterRefactoringKey,
|
|
||||||
d->m_settings.autoSaveAfterRefactoring,
|
|
||||||
def.autoSaveAfterRefactoring);
|
|
||||||
qsettings->setValueWithDefault(autoSuspendEnabledKey,
|
|
||||||
d->m_settings.autoSuspendEnabled,
|
|
||||||
def.autoSuspendEnabled);
|
|
||||||
qsettings->setValueWithDefault(autoSuspendMinDocumentCountKey,
|
|
||||||
d->m_settings.autoSuspendMinDocumentCount,
|
|
||||||
def.autoSuspendMinDocumentCount);
|
|
||||||
qsettings->setValueWithDefault(warnBeforeOpeningBigTextFilesKey,
|
|
||||||
d->m_settings.warnBeforeOpeningBigFilesEnabled,
|
|
||||||
def.warnBeforeOpeningBigFilesEnabled);
|
|
||||||
qsettings->setValueWithDefault(bigTextFileSizeLimitKey,
|
|
||||||
d->m_settings.bigFileSizeLimitInMB,
|
|
||||||
def.bigFileSizeLimitInMB);
|
|
||||||
qsettings->setValueWithDefault(maxRecentFilesKey,
|
|
||||||
d->m_settings.maxRecentFiles,
|
|
||||||
def.maxRecentFiles);
|
|
||||||
qsettings->setValueWithDefault(preferredEditorFactoriesKey,
|
qsettings->setValueWithDefault(preferredEditorFactoriesKey,
|
||||||
toMap(userPreferredEditorTypes()));
|
toMap(userPreferredEditorTypes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManagerPrivate::readSettings()
|
void EditorManagerPrivate::readSettings()
|
||||||
{
|
{
|
||||||
Settings def;
|
|
||||||
QSettings *qs = ICore::settings();
|
QSettings *qs = ICore::settings();
|
||||||
d->m_settings.warnBeforeOpeningBigFilesEnabled
|
|
||||||
= qs->value(warnBeforeOpeningBigTextFilesKey, def.warnBeforeOpeningBigFilesEnabled).toBool();
|
|
||||||
d->m_settings.bigFileSizeLimitInMB
|
|
||||||
= qs->value(bigTextFileSizeLimitKey, def.bigFileSizeLimitInMB).toInt();
|
|
||||||
|
|
||||||
const int maxRecentFiles = qs->value(maxRecentFilesKey, def.maxRecentFiles).toInt();
|
|
||||||
if (maxRecentFiles > 0)
|
|
||||||
d->m_settings.maxRecentFiles = maxRecentFiles;
|
|
||||||
|
|
||||||
const Qt::CaseSensitivity defaultSensitivity = OsSpecificAspects::fileNameCaseSensitivity(
|
const Qt::CaseSensitivity defaultSensitivity = OsSpecificAspects::fileNameCaseSensitivity(
|
||||||
HostOsInfo::hostOs());
|
HostOsInfo::hostOs());
|
||||||
@@ -1281,19 +1236,6 @@ void EditorManagerPrivate::readSettings()
|
|||||||
.value<QMap<QString, QVariant> >();
|
.value<QMap<QString, QVariant> >();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->m_settings.reloadSetting = IDocument::ReloadSetting(
|
|
||||||
qs->value(reloadBehaviorKey, def.reloadSetting).toInt());
|
|
||||||
|
|
||||||
d->m_settings.autoSaveEnabled = qs->value(autoSaveEnabledKey, def.autoSaveEnabled).toBool();
|
|
||||||
d->m_settings.autoSaveInterval = qs->value(autoSaveIntervalKey, def.autoSaveInterval).toInt();
|
|
||||||
d->m_settings.autoSaveAfterRefactoring = qs->value(autoSaveAfterRefactoringKey,
|
|
||||||
def.autoSaveAfterRefactoring).toBool();
|
|
||||||
|
|
||||||
d->m_settings.autoSuspendEnabled = qs->value(autoSuspendEnabledKey, def.autoSuspendEnabled)
|
|
||||||
.toBool();
|
|
||||||
d->m_settings.autoSuspendMinDocumentCount
|
|
||||||
= qs->value(autoSuspendMinDocumentCountKey, def.autoSuspendMinDocumentCount).toInt();
|
|
||||||
|
|
||||||
updateAutoSave();
|
updateAutoSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1325,88 +1267,6 @@ void EditorManagerPrivate::writeFileSystemSensitivity(Utils::QtcSettings *settin
|
|||||||
HostOsInfo::hostOs())));
|
HostOsInfo::hostOs())));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorManagerPrivate::setAutoSaveEnabled(bool enabled)
|
|
||||||
{
|
|
||||||
d->m_settings.autoSaveEnabled = enabled;
|
|
||||||
updateAutoSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EditorManagerPrivate::autoSaveEnabled()
|
|
||||||
{
|
|
||||||
return d->m_settings.autoSaveEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorManagerPrivate::setAutoSaveInterval(int interval)
|
|
||||||
{
|
|
||||||
d->m_settings.autoSaveInterval = interval;
|
|
||||||
updateAutoSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
int EditorManagerPrivate::autoSaveInterval()
|
|
||||||
{
|
|
||||||
return d->m_settings.autoSaveInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorManagerPrivate::setAutoSaveAfterRefactoring(bool enabled)
|
|
||||||
{
|
|
||||||
d->m_settings.autoSaveAfterRefactoring = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EditorManagerPrivate::autoSaveAfterRefactoring()
|
|
||||||
{
|
|
||||||
return d->m_settings.autoSaveAfterRefactoring;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorManagerPrivate::setAutoSuspendEnabled(bool enabled)
|
|
||||||
{
|
|
||||||
d->m_settings.autoSuspendEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EditorManagerPrivate::autoSuspendEnabled()
|
|
||||||
{
|
|
||||||
return d->m_settings.autoSuspendEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorManagerPrivate::setAutoSuspendMinDocumentCount(int count)
|
|
||||||
{
|
|
||||||
d->m_settings.autoSuspendMinDocumentCount = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EditorManagerPrivate::autoSuspendMinDocumentCount()
|
|
||||||
{
|
|
||||||
return d->m_settings.autoSuspendMinDocumentCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool EditorManagerPrivate::warnBeforeOpeningBigFilesEnabled()
|
|
||||||
{
|
|
||||||
return d->m_settings.warnBeforeOpeningBigFilesEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorManagerPrivate::setWarnBeforeOpeningBigFilesEnabled(bool enabled)
|
|
||||||
{
|
|
||||||
d->m_settings.warnBeforeOpeningBigFilesEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EditorManagerPrivate::bigFileSizeLimit()
|
|
||||||
{
|
|
||||||
return d->m_settings.bigFileSizeLimitInMB;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorManagerPrivate::setMaxRecentFiles(int count)
|
|
||||||
{
|
|
||||||
d->m_settings.maxRecentFiles = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
int EditorManagerPrivate::maxRecentFiles()
|
|
||||||
{
|
|
||||||
return d->m_settings.maxRecentFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EditorManagerPrivate::setBigFileSizeLimit(int limitInMB)
|
|
||||||
{
|
|
||||||
d->m_settings.bigFileSizeLimitInMB = limitInMB;
|
|
||||||
}
|
|
||||||
|
|
||||||
EditorFactoryList EditorManagerPrivate::findFactories(Id editorId, const FilePath &filePath)
|
EditorFactoryList EditorManagerPrivate::findFactories(Id editorId, const FilePath &filePath)
|
||||||
{
|
{
|
||||||
if (debugEditorManager)
|
if (debugEditorManager)
|
||||||
@@ -2005,8 +1865,8 @@ void EditorManagerPrivate::addDocumentToRecentFiles(IDocument *document)
|
|||||||
|
|
||||||
void EditorManagerPrivate::updateAutoSave()
|
void EditorManagerPrivate::updateAutoSave()
|
||||||
{
|
{
|
||||||
if (d->m_settings.autoSaveEnabled)
|
if (systemSettings().autoSaveModifiedFiles())
|
||||||
d->m_autoSaveTimer->start(d->m_settings.autoSaveInterval * (60 * 1000));
|
d->m_autoSaveTimer->start(systemSettings().autoSaveInterval() * (60 * 1000));
|
||||||
else
|
else
|
||||||
d->m_autoSaveTimer->stop();
|
d->m_autoSaveTimer->stop();
|
||||||
}
|
}
|
||||||
@@ -2595,20 +2455,21 @@ void EditorManagerPrivate::revertToSaved(IDocument *document)
|
|||||||
|
|
||||||
void EditorManagerPrivate::autoSuspendDocuments()
|
void EditorManagerPrivate::autoSuspendDocuments()
|
||||||
{
|
{
|
||||||
if (!d->m_settings.autoSuspendEnabled)
|
if (!systemSettings().autoSuspendEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto visibleDocuments = Utils::transform<QSet>(EditorManager::visibleEditors(),
|
auto visibleDocuments = Utils::transform<QSet>(EditorManager::visibleEditors(),
|
||||||
&IEditor::document);
|
&IEditor::document);
|
||||||
int keptEditorCount = 0;
|
int keptEditorCount = 0;
|
||||||
QList<IDocument *> documentsToSuspend;
|
QList<IDocument *> documentsToSuspend;
|
||||||
|
const int minDocumentCount = systemSettings().autoSuspendMinDocumentCount();
|
||||||
for (const EditLocation &editLocation : std::as_const(d->m_globalHistory)) {
|
for (const EditLocation &editLocation : std::as_const(d->m_globalHistory)) {
|
||||||
IDocument *document = editLocation.document;
|
IDocument *document = editLocation.document;
|
||||||
if (!document || !document->isSuspendAllowed() || document->isModified()
|
if (!document || !document->isSuspendAllowed() || document->isModified()
|
||||||
|| document->isTemporary() || document->filePath().isEmpty()
|
|| document->isTemporary() || document->filePath().isEmpty()
|
||||||
|| visibleDocuments.contains(document))
|
|| visibleDocuments.contains(document))
|
||||||
continue;
|
continue;
|
||||||
if (keptEditorCount >= d->m_settings.autoSuspendMinDocumentCount)
|
if (keptEditorCount >= minDocumentCount)
|
||||||
documentsToSuspend.append(document);
|
documentsToSuspend.append(document);
|
||||||
else
|
else
|
||||||
++keptEditorCount;
|
++keptEditorCount;
|
||||||
@@ -3001,7 +2862,8 @@ void EditorManager::runWithTemporaryEditor(const Utils::FilePath &filePath,
|
|||||||
*/
|
*/
|
||||||
IDocument::ReloadSetting EditorManager::reloadSetting()
|
IDocument::ReloadSetting EditorManager::reloadSetting()
|
||||||
{
|
{
|
||||||
return d->m_settings.reloadSetting;
|
// FIXME: Used TypedSelectionAspect once we have that.
|
||||||
|
return IDocument::ReloadSetting(systemSettings().reloadSetting.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -3011,7 +2873,7 @@ IDocument::ReloadSetting EditorManager::reloadSetting()
|
|||||||
*/
|
*/
|
||||||
void EditorManager::setReloadSetting(IDocument::ReloadSetting behavior)
|
void EditorManager::setReloadSetting(IDocument::ReloadSetting behavior)
|
||||||
{
|
{
|
||||||
d->m_settings.reloadSetting = behavior;
|
systemSettings().reloadSetting.setValue(behavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -3228,7 +3090,7 @@ bool EditorManager::isAutoSaveFile(const QString &filePath)
|
|||||||
|
|
||||||
bool EditorManager::autoSaveAfterRefactoring()
|
bool EditorManager::autoSaveAfterRefactoring()
|
||||||
{
|
{
|
||||||
return EditorManagerPrivate::autoSaveAfterRefactoring();
|
return systemSettings().autoSaveAfterRefactoring();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@@ -99,22 +99,6 @@ public:
|
|||||||
static Qt::CaseSensitivity readFileSystemSensitivity(QSettings *settings);
|
static Qt::CaseSensitivity readFileSystemSensitivity(QSettings *settings);
|
||||||
static void writeFileSystemSensitivity(Utils::QtcSettings *settings,
|
static void writeFileSystemSensitivity(Utils::QtcSettings *settings,
|
||||||
Qt::CaseSensitivity sensitivity);
|
Qt::CaseSensitivity sensitivity);
|
||||||
static void setAutoSaveEnabled(bool enabled);
|
|
||||||
static bool autoSaveEnabled();
|
|
||||||
static void setAutoSaveInterval(int interval);
|
|
||||||
static int autoSaveInterval();
|
|
||||||
static void setAutoSaveAfterRefactoring(bool enabled);
|
|
||||||
static bool autoSaveAfterRefactoring();
|
|
||||||
static void setAutoSuspendEnabled(bool enabled);
|
|
||||||
static bool autoSuspendEnabled();
|
|
||||||
static void setAutoSuspendMinDocumentCount(int count);
|
|
||||||
static int autoSuspendMinDocumentCount();
|
|
||||||
static void setWarnBeforeOpeningBigFilesEnabled(bool enabled);
|
|
||||||
static bool warnBeforeOpeningBigFilesEnabled();
|
|
||||||
static void setBigFileSizeLimit(int limitInMB);
|
|
||||||
static int bigFileSizeLimit();
|
|
||||||
static void setMaxRecentFiles(int count);
|
|
||||||
static int maxRecentFiles();
|
|
||||||
|
|
||||||
static EditorWindow *createEditorWindow();
|
static EditorWindow *createEditorWindow();
|
||||||
static void splitNewWindow(Internal::EditorView *view);
|
static void splitNewWindow(Internal::EditorView *view);
|
||||||
@@ -132,6 +116,8 @@ public:
|
|||||||
static void setPlaceholderText(const QString &text);
|
static void setPlaceholderText(const QString &text);
|
||||||
static QString placeholderText();
|
static QString placeholderText();
|
||||||
|
|
||||||
|
static void updateAutoSave();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
static bool saveDocument(Core::IDocument *document);
|
static bool saveDocument(Core::IDocument *document);
|
||||||
static bool saveDocumentAs(Core::IDocument *document);
|
static bool saveDocumentAs(Core::IDocument *document);
|
||||||
@@ -191,7 +177,6 @@ private:
|
|||||||
static EditorArea *findEditorArea(const EditorView *view, int *areaIndex = nullptr);
|
static EditorArea *findEditorArea(const EditorView *view, int *areaIndex = nullptr);
|
||||||
static IEditor *pickUnusedEditor(Internal::EditorView **foundView = nullptr);
|
static IEditor *pickUnusedEditor(Internal::EditorView **foundView = nullptr);
|
||||||
static void addDocumentToRecentFiles(IDocument *document);
|
static void addDocumentToRecentFiles(IDocument *document);
|
||||||
static void updateAutoSave();
|
|
||||||
static void updateMakeWritableWarning();
|
static void updateMakeWritableWarning();
|
||||||
static void setupSaveActions(IDocument *document, QAction *saveAction,
|
static void setupSaveActions(IDocument *document, QAction *saveAction,
|
||||||
QAction *saveAsAction, QAction *revertToSavedAction);
|
QAction *saveAsAction, QAction *revertToSavedAction);
|
||||||
@@ -263,23 +248,6 @@ private:
|
|||||||
EditorManager::WindowTitleHandler m_sessionTitleHandler;
|
EditorManager::WindowTitleHandler m_sessionTitleHandler;
|
||||||
EditorManager::WindowTitleHandler m_titleVcsTopicHandler;
|
EditorManager::WindowTitleHandler m_titleVcsTopicHandler;
|
||||||
|
|
||||||
struct Settings
|
|
||||||
{
|
|
||||||
IDocument::ReloadSetting reloadSetting = IDocument::AlwaysAsk;
|
|
||||||
|
|
||||||
bool autoSaveEnabled = true;
|
|
||||||
int autoSaveInterval = 5;
|
|
||||||
|
|
||||||
bool autoSuspendEnabled = true;
|
|
||||||
int autoSuspendMinDocumentCount = 10;
|
|
||||||
|
|
||||||
bool autoSaveAfterRefactoring = true;
|
|
||||||
bool warnBeforeOpeningBigFilesEnabled = true;
|
|
||||||
int bigFileSizeLimitInMB = 5;
|
|
||||||
int maxRecentFiles = 8;
|
|
||||||
};
|
|
||||||
|
|
||||||
Settings m_settings;
|
|
||||||
QString m_placeholderText;
|
QString m_placeholderText;
|
||||||
QList<std::function<bool(IEditor *)>> m_closeEditorListeners;
|
QList<std::function<bool(IEditor *)>> m_closeEditorListeners;
|
||||||
};
|
};
|
||||||
|
@@ -103,7 +103,6 @@ namespace Internal {
|
|||||||
|
|
||||||
static const char settingsGroup[] = "MainWindow";
|
static const char settingsGroup[] = "MainWindow";
|
||||||
static const char colorKey[] = "Color";
|
static const char colorKey[] = "Color";
|
||||||
static const char askBeforeExitKey[] = "AskBeforeExit";
|
|
||||||
static const char windowGeometryKey[] = "WindowGeometry";
|
static const char windowGeometryKey[] = "WindowGeometry";
|
||||||
static const char windowStateKey[] = "WindowState";
|
static const char windowStateKey[] = "WindowState";
|
||||||
static const char modeSelectorLayoutKey[] = "ModeSelectorLayout";
|
static const char modeSelectorLayoutKey[] = "ModeSelectorLayout";
|
||||||
@@ -129,7 +128,6 @@ MainWindow::MainWindow()
|
|||||||
, m_jsExpander(JsExpander::createGlobalJsExpander())
|
, m_jsExpander(JsExpander::createGlobalJsExpander())
|
||||||
, m_vcsManager(new VcsManager)
|
, m_vcsManager(new VcsManager)
|
||||||
, m_modeStack(new FancyTabWidget(this))
|
, m_modeStack(new FancyTabWidget(this))
|
||||||
, m_systemSettings(new SystemSettings)
|
|
||||||
, m_shortcutSettings(new ShortcutSettings)
|
, m_shortcutSettings(new ShortcutSettings)
|
||||||
, m_toolSettings(new ToolSettings)
|
, m_toolSettings(new ToolSettings)
|
||||||
, m_mimeTypeSettings(new MimeTypeSettings)
|
, m_mimeTypeSettings(new MimeTypeSettings)
|
||||||
@@ -232,16 +230,6 @@ void MainWindow::setSidebarVisible(bool visible, Side side)
|
|||||||
navigationWidget(side)->setShown(visible);
|
navigationWidget(side)->setShown(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::askConfirmationBeforeExit() const
|
|
||||||
{
|
|
||||||
return m_askConfirmationBeforeExit;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setAskConfirmationBeforeExit(bool ask)
|
|
||||||
{
|
|
||||||
m_askConfirmationBeforeExit = ask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setOverrideColor(const QColor &color)
|
void MainWindow::setOverrideColor(const QColor &color)
|
||||||
{
|
{
|
||||||
m_overrideColor = color;
|
m_overrideColor = color;
|
||||||
@@ -275,8 +263,6 @@ MainWindow::~MainWindow()
|
|||||||
m_messageManager = nullptr;
|
m_messageManager = nullptr;
|
||||||
delete m_shortcutSettings;
|
delete m_shortcutSettings;
|
||||||
m_shortcutSettings = nullptr;
|
m_shortcutSettings = nullptr;
|
||||||
delete m_systemSettings;
|
|
||||||
m_systemSettings = nullptr;
|
|
||||||
delete m_toolSettings;
|
delete m_toolSettings;
|
||||||
m_toolSettings = nullptr;
|
m_toolSettings = nullptr;
|
||||||
delete m_mimeTypeSettings;
|
delete m_mimeTypeSettings;
|
||||||
@@ -376,7 +362,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_askConfirmationBeforeExit
|
if (systemSettings().askBeforeExit()
|
||||||
&& (QMessageBox::question(this,
|
&& (QMessageBox::question(this,
|
||||||
Tr::tr("Exit %1?").arg(QGuiApplication::applicationDisplayName()),
|
Tr::tr("Exit %1?").arg(QGuiApplication::applicationDisplayName()),
|
||||||
Tr::tr("Exit %1?").arg(QGuiApplication::applicationDisplayName()),
|
Tr::tr("Exit %1?").arg(QGuiApplication::applicationDisplayName()),
|
||||||
@@ -1181,8 +1167,6 @@ void MainWindow::readSettings()
|
|||||||
QColor(StyleHelper::DEFAULT_BASE_COLOR)).value<QColor>());
|
QColor(StyleHelper::DEFAULT_BASE_COLOR)).value<QColor>());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_askConfirmationBeforeExit = settings->value(askBeforeExitKey, askBeforeExitDefault).toBool();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
ModeManager::Style modeStyle =
|
ModeManager::Style modeStyle =
|
||||||
ModeManager::Style(settings->value(modeSelectorLayoutKey, int(ModeManager::Style::IconsAndText)).toInt());
|
ModeManager::Style(settings->value(modeSelectorLayoutKey, int(ModeManager::Style::IconsAndText)).toInt());
|
||||||
@@ -1216,10 +1200,6 @@ void MainWindow::saveSettings()
|
|||||||
StyleHelper::requestedBaseColor(),
|
StyleHelper::requestedBaseColor(),
|
||||||
QColor(StyleHelper::DEFAULT_BASE_COLOR));
|
QColor(StyleHelper::DEFAULT_BASE_COLOR));
|
||||||
|
|
||||||
settings->setValueWithDefault(askBeforeExitKey,
|
|
||||||
m_askConfirmationBeforeExit,
|
|
||||||
askBeforeExitDefault);
|
|
||||||
|
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
DocumentManager::saveSettings();
|
DocumentManager::saveSettings();
|
||||||
|
@@ -50,7 +50,6 @@ class MimeTypeSettings;
|
|||||||
class VersionDialog;
|
class VersionDialog;
|
||||||
class WindowSupport;
|
class WindowSupport;
|
||||||
class SystemEditor;
|
class SystemEditor;
|
||||||
class SystemSettings;
|
|
||||||
|
|
||||||
class MainWindow : public Utils::AppMainWindow
|
class MainWindow : public Utils::AppMainWindow
|
||||||
{
|
{
|
||||||
@@ -81,9 +80,6 @@ public:
|
|||||||
void updateAdditionalContexts(const Context &remove, const Context &add,
|
void updateAdditionalContexts(const Context &remove, const Context &add,
|
||||||
ICore::ContextPriority priority);
|
ICore::ContextPriority priority);
|
||||||
|
|
||||||
bool askConfirmationBeforeExit() const;
|
|
||||||
void setAskConfirmationBeforeExit(bool ask);
|
|
||||||
|
|
||||||
void setOverrideColor(const QColor &color);
|
void setOverrideColor(const QColor &color);
|
||||||
|
|
||||||
QStringList additionalAboutInformation() const;
|
QStringList additionalAboutInformation() const;
|
||||||
@@ -160,7 +156,6 @@ private:
|
|||||||
|
|
||||||
std::unordered_map<QWidget *, IContext *> m_contextWidgets;
|
std::unordered_map<QWidget *, IContext *> m_contextWidgets;
|
||||||
|
|
||||||
SystemSettings *m_systemSettings = nullptr;
|
|
||||||
ShortcutSettings *m_shortcutSettings = nullptr;
|
ShortcutSettings *m_shortcutSettings = nullptr;
|
||||||
ToolSettings *m_toolSettings = nullptr;
|
ToolSettings *m_toolSettings = nullptr;
|
||||||
MimeTypeSettings *m_mimeTypeSettings = nullptr;
|
MimeTypeSettings *m_mimeTypeSettings = nullptr;
|
||||||
@@ -186,7 +181,6 @@ private:
|
|||||||
|
|
||||||
QToolButton *m_toggleLeftSideBarButton = nullptr;
|
QToolButton *m_toggleLeftSideBarButton = nullptr;
|
||||||
QToolButton *m_toggleRightSideBarButton = nullptr;
|
QToolButton *m_toggleRightSideBarButton = nullptr;
|
||||||
bool m_askConfirmationBeforeExit = false;
|
|
||||||
QColor m_overrideColor;
|
QColor m_overrideColor;
|
||||||
QList<std::function<bool()>> m_preCloseListeners;
|
QList<std::function<bool()>> m_preCloseListeners;
|
||||||
};
|
};
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
#include "coreplugintr.h"
|
#include "coreplugintr.h"
|
||||||
#include "editormanager/editormanager_p.h"
|
#include "editormanager/editormanager_p.h"
|
||||||
#include "dialogs/restartdialog.h"
|
#include "dialogs/restartdialog.h"
|
||||||
|
#include "dialogs/ioptionspage.h"
|
||||||
#include "fileutils.h"
|
#include "fileutils.h"
|
||||||
#include "icore.h"
|
#include "icore.h"
|
||||||
#include "iversioncontrol.h"
|
#include "iversioncontrol.h"
|
||||||
@@ -40,13 +41,9 @@
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
#ifdef ENABLE_CRASHPAD
|
#ifdef ENABLE_CRASHPAD
|
||||||
const char crashReportingEnabledKey[] = "CrashReportingEnabled";
|
|
||||||
const char showCrashButtonKey[] = "ShowCrashButton";
|
|
||||||
|
|
||||||
// TODO: move to somewhere in Utils
|
// TODO: move to somewhere in Utils
|
||||||
static QString formatSize(qint64 size)
|
static QString formatSize(qint64 size)
|
||||||
{
|
{
|
||||||
@@ -63,55 +60,128 @@ static QString formatSize(qint64 size)
|
|||||||
}
|
}
|
||||||
#endif // ENABLE_CRASHPAD
|
#endif // ENABLE_CRASHPAD
|
||||||
|
|
||||||
|
SystemSettings &systemSettings()
|
||||||
|
{
|
||||||
|
static SystemSettings theSettings;
|
||||||
|
return theSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemSettings::SystemSettings()
|
||||||
|
{
|
||||||
|
setAutoApply(false);
|
||||||
|
|
||||||
|
autoSaveModifiedFiles.setSettingsKey("EditorManager/AutoSaveEnabled");
|
||||||
|
autoSaveModifiedFiles.setDefaultValue(true);
|
||||||
|
autoSaveModifiedFiles.setLabelText(Tr::tr("Auto-save modified files"));
|
||||||
|
autoSaveModifiedFiles.setLabelPlacement(
|
||||||
|
BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
||||||
|
autoSaveModifiedFiles.setToolTip(
|
||||||
|
Tr::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(QGuiApplication::applicationDisplayName()));
|
||||||
|
|
||||||
|
autoSaveInterval.setSettingsKey("EditorManager/AutoSaveInterval");
|
||||||
|
autoSaveInterval.setSuffix(Tr::tr("min"));
|
||||||
|
autoSaveInterval.setRange(1, 1000000);
|
||||||
|
autoSaveInterval.setDefaultValue(5);
|
||||||
|
autoSaveInterval.setEnabler(&autoSaveModifiedFiles);
|
||||||
|
autoSaveInterval.setLabelText(Tr::tr("Interval:"));
|
||||||
|
|
||||||
|
autoSaveAfterRefactoring.setSettingsKey("EditorManager/AutoSaveAfterRefactoring");
|
||||||
|
autoSaveAfterRefactoring.setDefaultValue(true);
|
||||||
|
autoSaveAfterRefactoring.setLabelPlacement(
|
||||||
|
BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
||||||
|
autoSaveAfterRefactoring.setLabelText(Tr::tr("Auto-save files after refactoring"));
|
||||||
|
autoSaveAfterRefactoring.setToolTip(
|
||||||
|
Tr::tr("Automatically saves all open files affected by a refactoring operation,\n"
|
||||||
|
"provided they were unmodified before the refactoring."));
|
||||||
|
|
||||||
|
autoSuspendEnabled.setSettingsKey("EditorManager/AutoSuspendEnabled");
|
||||||
|
autoSuspendEnabled.setDefaultValue(true);
|
||||||
|
autoSuspendEnabled.setLabelText(Tr::tr("Auto-suspend unmodified files"));
|
||||||
|
autoSuspendEnabled.setLabelPlacement(
|
||||||
|
BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
||||||
|
autoSuspendEnabled.setToolTip(
|
||||||
|
Tr::tr("Automatically free resources of old documents that are not visible and not "
|
||||||
|
"modified. They stay visible in the list of open documents."));
|
||||||
|
|
||||||
|
autoSuspendMinDocumentCount.setSettingsKey("EditorManager/AutoSuspendMinDocuments");
|
||||||
|
autoSuspendMinDocumentCount.setRange(1, 500);
|
||||||
|
autoSuspendMinDocumentCount.setDefaultValue(30);
|
||||||
|
autoSuspendMinDocumentCount.setEnabler(&autoSuspendEnabled);
|
||||||
|
autoSuspendMinDocumentCount.setLabelText(Tr::tr("Files to keep open:"));
|
||||||
|
autoSuspendMinDocumentCount.setToolTip(
|
||||||
|
Tr::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."));
|
||||||
|
|
||||||
|
warnBeforeOpeningBigFiles.setSettingsKey("EditorManager/WarnBeforeOpeningBigTextFiles");
|
||||||
|
warnBeforeOpeningBigFiles.setDefaultValue(true);
|
||||||
|
warnBeforeOpeningBigFiles.setLabelPlacement(
|
||||||
|
BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
||||||
|
warnBeforeOpeningBigFiles.setLabelText(Tr::tr("Warn before opening text files greater than"));
|
||||||
|
|
||||||
|
bigFileSizeLimitInMB.setSettingsKey("EditorManager/BigTextFileSizeLimitInMB");
|
||||||
|
bigFileSizeLimitInMB.setSuffix(Tr::tr("MB"));
|
||||||
|
bigFileSizeLimitInMB.setRange(1, 500);
|
||||||
|
bigFileSizeLimitInMB.setDefaultValue(5);
|
||||||
|
bigFileSizeLimitInMB.setEnabler(&warnBeforeOpeningBigFiles);
|
||||||
|
|
||||||
|
maxRecentFiles.setSettingsKey("EditorManager/MaxRecentFiles");
|
||||||
|
maxRecentFiles.setRange(1, 99);
|
||||||
|
maxRecentFiles.setDefaultValue(8);
|
||||||
|
|
||||||
|
reloadSetting.setSettingsKey("EditorManager/ReloadBehavior");
|
||||||
|
reloadSetting.setDisplayStyle(SelectionAspect::DisplayStyle::ComboBox);
|
||||||
|
reloadSetting.addOption(Tr::tr("Always Ask"));
|
||||||
|
reloadSetting.addOption(Tr::tr("Reload All Unchanged Editors"));
|
||||||
|
reloadSetting.addOption(Tr::tr("Ignore Modifications"));
|
||||||
|
reloadSetting.setDefaultValue(IDocument::AlwaysAsk);
|
||||||
|
reloadSetting.setLabelText(Tr::tr("When files are externally modified:"));
|
||||||
|
|
||||||
|
askBeforeExit.setSettingsKey("AskBeforeExit");
|
||||||
|
askBeforeExit.setLabelText(Tr::tr("Ask for confirmation before exiting"));
|
||||||
|
askBeforeExit.setLabelPlacement(BoolAspect::LabelPlacement::AtCheckBoxWithoutDummyLabel);
|
||||||
|
|
||||||
|
#ifdef ENABLE_CRASHPAD
|
||||||
|
enableCrashReporting.setSettingsKey("CrashReportingEnabled");
|
||||||
|
enableCrashReporting.setLabelText(tr("Enable crash reporting"));
|
||||||
|
enableCrashReporting.setToolTip(
|
||||||
|
Tr::tr("Allow crashes to be automatically reported. Collected reports are "
|
||||||
|
"used for the sole purpose of fixing bugs."));
|
||||||
|
|
||||||
|
showCrashButton.setSettingsKey("ShowCrashButton");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const auto updateAutoSave = [] { EditorManagerPrivate::updateAutoSave(); };
|
||||||
|
connect(&autoSaveModifiedFiles, &BaseAspect::changed, this, updateAutoSave);
|
||||||
|
connect(&autoSaveInterval, &BaseAspect::changed, this, updateAutoSave);
|
||||||
|
|
||||||
|
readSettings();
|
||||||
|
}
|
||||||
|
|
||||||
class SystemSettingsWidget : public IOptionsPageWidget
|
class SystemSettingsWidget : public IOptionsPageWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SystemSettingsWidget()
|
SystemSettingsWidget()
|
||||||
: m_fileSystemCaseSensitivityChooser(new QComboBox)
|
: m_fileSystemCaseSensitivityChooser(new QComboBox)
|
||||||
, m_autoSuspendMinDocumentCount(new QSpinBox)
|
|
||||||
, m_externalFileBrowserEdit(new QLineEdit)
|
, m_externalFileBrowserEdit(new QLineEdit)
|
||||||
, m_autoSuspendCheckBox(new QCheckBox(Tr::tr("Auto-suspend unmodified files")))
|
|
||||||
, m_maxRecentFilesSpinBox(new QSpinBox)
|
|
||||||
, m_enableCrashReportingCheckBox(new QCheckBox(Tr::tr("Enable crash reporting")))
|
|
||||||
, m_warnBeforeOpeningBigFiles(
|
|
||||||
new QCheckBox(Tr::tr("Warn before opening text files greater than")))
|
|
||||||
, m_bigFilesLimitSpinBox(new QSpinBox)
|
|
||||||
, m_terminalComboBox(new QComboBox)
|
, m_terminalComboBox(new QComboBox)
|
||||||
, m_terminalOpenArgs(new QLineEdit)
|
, m_terminalOpenArgs(new QLineEdit)
|
||||||
, m_terminalExecuteArgs(new QLineEdit)
|
, m_terminalExecuteArgs(new QLineEdit)
|
||||||
, m_patchChooser(new Utils::PathChooser)
|
, m_patchChooser(new Utils::PathChooser)
|
||||||
, m_environmentChangesLabel(new Utils::ElidingLabel)
|
, m_environmentChangesLabel(new Utils::ElidingLabel)
|
||||||
, m_askBeforeExitCheckBox(new QCheckBox(Tr::tr("Ask for confirmation before exiting")))
|
|
||||||
, m_reloadBehavior(new QComboBox)
|
|
||||||
, m_autoSaveCheckBox(new QCheckBox(Tr::tr("Auto-save modified files")))
|
|
||||||
, m_clearCrashReportsButton(new QPushButton(Tr::tr("Clear Local Crash Reports")))
|
, m_clearCrashReportsButton(new QPushButton(Tr::tr("Clear Local Crash Reports")))
|
||||||
, m_crashReportsSizeText(new QLabel)
|
, m_crashReportsSizeText(new QLabel)
|
||||||
, m_autoSaveInterval(new QSpinBox)
|
|
||||||
, m_autoSaveRefactoringCheckBox(new QCheckBox(Tr::tr("Auto-save files after refactoring")))
|
|
||||||
|
|
||||||
{
|
{
|
||||||
m_autoSuspendCheckBox->setToolTip(
|
SystemSettings &s = systemSettings();
|
||||||
Tr::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::tr("Allow crashes to be automatically reported. Collected reports are "
|
|
||||||
"used for the sole purpose of fixing bugs."));
|
|
||||||
m_bigFilesLimitSpinBox->setSuffix(Tr::tr("MB"));
|
|
||||||
m_bigFilesLimitSpinBox->setMinimum(1);
|
|
||||||
m_bigFilesLimitSpinBox->setMaximum(500);
|
|
||||||
m_bigFilesLimitSpinBox->setValue(5);
|
|
||||||
m_terminalExecuteArgs->setToolTip(
|
m_terminalExecuteArgs->setToolTip(
|
||||||
Tr::tr("Command line arguments used for \"Run in terminal\"."));
|
Tr::tr("Command line arguments used for \"Run in terminal\"."));
|
||||||
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
sizePolicy.setHorizontalStretch(5);
|
sizePolicy.setHorizontalStretch(5);
|
||||||
m_environmentChangesLabel->setSizePolicy(sizePolicy);
|
m_environmentChangesLabel->setSizePolicy(sizePolicy);
|
||||||
m_reloadBehavior->addItem(Tr::tr("Always Ask"));
|
|
||||||
m_reloadBehavior->addItem(Tr::tr("Reload All Unchanged Editors"));
|
|
||||||
m_reloadBehavior->addItem(Tr::tr("Ignore Modifications"));
|
|
||||||
m_autoSaveInterval->setSuffix(Tr::tr("min"));
|
|
||||||
QSizePolicy termSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
QSizePolicy termSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||||
termSizePolicy.setHorizontalStretch(3);
|
termSizePolicy.setHorizontalStretch(3);
|
||||||
m_terminalComboBox->setSizePolicy(termSizePolicy);
|
m_terminalComboBox->setSizePolicy(termSizePolicy);
|
||||||
@@ -119,15 +189,10 @@ public:
|
|||||||
m_terminalComboBox->setEditable(true);
|
m_terminalComboBox->setEditable(true);
|
||||||
m_terminalOpenArgs->setToolTip(
|
m_terminalOpenArgs->setToolTip(
|
||||||
Tr::tr("Command line arguments used for \"%1\".").arg(FileUtils::msgTerminalHereAction()));
|
Tr::tr("Command line arguments used for \"%1\".").arg(FileUtils::msgTerminalHereAction()));
|
||||||
m_autoSaveInterval->setMinimum(1);
|
|
||||||
|
|
||||||
auto fileSystemCaseSensitivityLabel = new QLabel(Tr::tr("File system case sensitivity:"));
|
auto fileSystemCaseSensitivityLabel = new QLabel(Tr::tr("File system case sensitivity:"));
|
||||||
fileSystemCaseSensitivityLabel->setToolTip(
|
fileSystemCaseSensitivityLabel->setToolTip(
|
||||||
Tr::tr("Influences how file names are matched to decide if they are the same."));
|
Tr::tr("Influences how file names are matched to decide if they are the same."));
|
||||||
auto autoSuspendLabel = new QLabel(Tr::tr("Files to keep open:"));
|
|
||||||
autoSuspendLabel->setToolTip(
|
|
||||||
Tr::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::tr("Reset"));
|
auto resetFileBrowserButton = new QPushButton(Tr::tr("Reset"));
|
||||||
resetFileBrowserButton->setToolTip(Tr::tr("Reset to default."));
|
resetFileBrowserButton->setToolTip(Tr::tr("Reset to default."));
|
||||||
auto helpExternalFileBrowserButton = new QToolButton;
|
auto helpExternalFileBrowserButton = new QToolButton;
|
||||||
@@ -164,21 +229,16 @@ public:
|
|||||||
form.addRow({fileSystemCaseSensitivityLabel,
|
form.addRow({fileSystemCaseSensitivityLabel,
|
||||||
Span(2, Row{m_fileSystemCaseSensitivityChooser, st})});
|
Span(2, Row{m_fileSystemCaseSensitivityChooser, st})});
|
||||||
}
|
}
|
||||||
form.addRow(
|
form.addRow({s.reloadSetting, st});
|
||||||
{Tr::tr("When files are externally modified:"), Span(2, Row{m_reloadBehavior, st})});
|
form.addRow({s.autoSaveModifiedFiles, Span(2, Row{s.autoSaveInterval, st})});
|
||||||
form.addRow(
|
form.addRow({Span(3, s.autoSaveAfterRefactoring)});
|
||||||
{m_autoSaveCheckBox, Span(2, Row{Tr::tr("Interval:"), m_autoSaveInterval, st})});
|
form.addRow({s.autoSuspendEnabled, Span(2, Row{s.autoSuspendMinDocumentCount, st})});
|
||||||
form.addRow({Span(3, m_autoSaveRefactoringCheckBox)});
|
form.addRow({s.warnBeforeOpeningBigFiles, Span(2, Row{s.bigFileSizeLimitInMB, st})});
|
||||||
form.addRow({m_autoSuspendCheckBox,
|
form.addRow({Tr::tr("Maximum number of entries in \"Recent Files\":"),
|
||||||
Span(2, Row{autoSuspendLabel, m_autoSuspendMinDocumentCount, st})});
|
Span(2, Row{s.maxRecentFiles, st})});
|
||||||
form.addRow({Span(3, Row{m_warnBeforeOpeningBigFiles, m_bigFilesLimitSpinBox, st})});
|
form.addRow({s.askBeforeExit});
|
||||||
form.addRow({Span(3,
|
|
||||||
Row{Tr::tr("Maximum number of entries in \"Recent Files\":"),
|
|
||||||
m_maxRecentFilesSpinBox,
|
|
||||||
st})});
|
|
||||||
form.addRow({m_askBeforeExitCheckBox});
|
|
||||||
#ifdef ENABLE_CRASHPAD
|
#ifdef ENABLE_CRASHPAD
|
||||||
form.addRow({Span(3, Row{m_enableCrashReportingCheckBox, helpCrashReportingButton, st})});
|
form.addRow({Span(3, Row{s.enableCrashReporting, helpCrashReportingButton, st})});
|
||||||
form.addRow({Span(3, Row{m_clearCrashReportsButton, m_crashReportsSizeText, st})});
|
form.addRow({Span(3, Row{m_clearCrashReportsButton, m_crashReportsSizeText, st})});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -189,7 +249,6 @@ public:
|
|||||||
}
|
}
|
||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
m_reloadBehavior->setCurrentIndex(EditorManager::reloadSetting());
|
|
||||||
if (HostOsInfo::isAnyUnixHost()) {
|
if (HostOsInfo::isAnyUnixHost()) {
|
||||||
const QVector<TerminalCommand> availableTerminals
|
const QVector<TerminalCommand> availableTerminals
|
||||||
= TerminalCommand::availableTerminalEmulators();
|
= TerminalCommand::availableTerminalEmulators();
|
||||||
@@ -211,28 +270,9 @@ public:
|
|||||||
m_patchChooser->setExpectedKind(PathChooser::ExistingCommand);
|
m_patchChooser->setExpectedKind(PathChooser::ExistingCommand);
|
||||||
m_patchChooser->setHistoryCompleter(QLatin1String("General.PatchCommand.History"));
|
m_patchChooser->setHistoryCompleter(QLatin1String("General.PatchCommand.History"));
|
||||||
m_patchChooser->setFilePath(PatchTool::patchCommand());
|
m_patchChooser->setFilePath(PatchTool::patchCommand());
|
||||||
m_autoSaveCheckBox->setChecked(EditorManagerPrivate::autoSaveEnabled());
|
|
||||||
m_autoSaveCheckBox->setToolTip(Tr::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(QGuiApplication::applicationDisplayName()));
|
|
||||||
m_autoSaveRefactoringCheckBox->setChecked(EditorManager::autoSaveAfterRefactoring());
|
|
||||||
m_autoSaveRefactoringCheckBox->setToolTip(
|
|
||||||
Tr::tr("Automatically saves all open files "
|
|
||||||
"affected by a refactoring operation,\nprovided 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());
|
|
||||||
#ifdef ENABLE_CRASHPAD
|
#ifdef ENABLE_CRASHPAD
|
||||||
if (ICore::settings()->value(showCrashButtonKey).toBool()) {
|
if (s.showCrashButton()) {
|
||||||
auto crashButton = new QPushButton("CRASH!!!");
|
auto crashButton = new QPushButton("CRASH!!!");
|
||||||
crashButton->show();
|
crashButton->show();
|
||||||
connect(crashButton, &QPushButton::clicked, [] {
|
connect(crashButton, &QPushButton::clicked, [] {
|
||||||
@@ -241,12 +281,10 @@ public:
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
m_enableCrashReportingCheckBox->setChecked(
|
|
||||||
ICore::settings()->value(crashReportingEnabledKey).toBool());
|
|
||||||
connect(helpCrashReportingButton, &QAbstractButton::clicked, this, [this] {
|
connect(helpCrashReportingButton, &QAbstractButton::clicked, this, [this] {
|
||||||
showHelpDialog(Tr::tr("Crash Reporting"), CorePlugin::msgCrashpadInformation());
|
showHelpDialog(Tr::tr("Crash Reporting"), CorePlugin::msgCrashpadInformation());
|
||||||
});
|
});
|
||||||
connect(m_enableCrashReportingCheckBox, &QCheckBox::stateChanged, this, [this] {
|
connect(&s.enableCrashReporting, &BaseAspect::changed, this, [this] {
|
||||||
const QString restartText = Tr::tr("The change will take effect after restart.");
|
const QString restartText = Tr::tr("The change will take effect after restart.");
|
||||||
Core::RestartDialog restartDialog(Core::ICore::dialogParent(), restartText);
|
Core::RestartDialog restartDialog(Core::ICore::dialogParent(), restartText);
|
||||||
restartDialog.exec();
|
restartDialog.exec();
|
||||||
@@ -263,10 +301,6 @@ public:
|
|||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_askBeforeExitCheckBox->setChecked(
|
|
||||||
static_cast<Core::Internal::MainWindow *>(ICore::mainWindow())
|
|
||||||
->askConfirmationBeforeExit());
|
|
||||||
|
|
||||||
if (HostOsInfo::isAnyUnixHost()) {
|
if (HostOsInfo::isAnyUnixHost()) {
|
||||||
connect(resetTerminalButton,
|
connect(resetTerminalButton,
|
||||||
&QAbstractButton::clicked,
|
&QAbstractButton::clicked,
|
||||||
@@ -342,33 +376,24 @@ private:
|
|||||||
void showHelpDialog(const QString &title, const QString &helpText);
|
void showHelpDialog(const QString &title, const QString &helpText);
|
||||||
|
|
||||||
QComboBox *m_fileSystemCaseSensitivityChooser;
|
QComboBox *m_fileSystemCaseSensitivityChooser;
|
||||||
QSpinBox *m_autoSuspendMinDocumentCount;
|
|
||||||
QLineEdit *m_externalFileBrowserEdit;
|
QLineEdit *m_externalFileBrowserEdit;
|
||||||
QCheckBox *m_autoSuspendCheckBox;
|
|
||||||
QSpinBox *m_maxRecentFilesSpinBox;
|
|
||||||
QCheckBox *m_enableCrashReportingCheckBox;
|
|
||||||
QCheckBox *m_warnBeforeOpeningBigFiles;
|
|
||||||
QSpinBox *m_bigFilesLimitSpinBox;
|
|
||||||
QComboBox *m_terminalComboBox;
|
QComboBox *m_terminalComboBox;
|
||||||
QLineEdit *m_terminalOpenArgs;
|
QLineEdit *m_terminalOpenArgs;
|
||||||
QLineEdit *m_terminalExecuteArgs;
|
QLineEdit *m_terminalExecuteArgs;
|
||||||
Utils::PathChooser *m_patchChooser;
|
Utils::PathChooser *m_patchChooser;
|
||||||
Utils::ElidingLabel *m_environmentChangesLabel;
|
Utils::ElidingLabel *m_environmentChangesLabel;
|
||||||
QCheckBox *m_askBeforeExitCheckBox;
|
|
||||||
QComboBox *m_reloadBehavior;
|
|
||||||
QCheckBox *m_autoSaveCheckBox;
|
|
||||||
QPushButton *m_clearCrashReportsButton;
|
QPushButton *m_clearCrashReportsButton;
|
||||||
QLabel *m_crashReportsSizeText;
|
QLabel *m_crashReportsSizeText;
|
||||||
QSpinBox *m_autoSaveInterval;
|
|
||||||
QCheckBox *m_autoSaveRefactoringCheckBox;
|
|
||||||
QPointer<QMessageBox> m_dialog;
|
QPointer<QMessageBox> m_dialog;
|
||||||
EnvironmentItems m_environmentChanges;
|
EnvironmentItems m_environmentChanges;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SystemSettingsWidget::apply()
|
void SystemSettingsWidget::apply()
|
||||||
{
|
{
|
||||||
|
systemSettings().apply();
|
||||||
|
systemSettings().writeSettings();
|
||||||
|
|
||||||
QtcSettings *settings = ICore::settings();
|
QtcSettings *settings = ICore::settings();
|
||||||
EditorManager::setReloadSetting(IDocument::ReloadSetting(m_reloadBehavior->currentIndex()));
|
|
||||||
if (HostOsInfo::isAnyUnixHost()) {
|
if (HostOsInfo::isAnyUnixHost()) {
|
||||||
TerminalCommand::setTerminalEmulator({
|
TerminalCommand::setTerminalEmulator({
|
||||||
FilePath::fromUserInput(m_terminalComboBox->lineEdit()->text()),
|
FilePath::fromUserInput(m_terminalComboBox->lineEdit()->text()),
|
||||||
@@ -380,22 +405,6 @@ void SystemSettingsWidget::apply()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PatchTool::setPatchCommand(m_patchChooser->filePath());
|
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());
|
|
||||||
EditorManagerPrivate::setWarnBeforeOpeningBigFilesEnabled(
|
|
||||||
m_warnBeforeOpeningBigFiles->isChecked());
|
|
||||||
EditorManagerPrivate::setBigFileSizeLimit(m_bigFilesLimitSpinBox->value());
|
|
||||||
EditorManagerPrivate::setMaxRecentFiles(m_maxRecentFilesSpinBox->value());
|
|
||||||
#ifdef ENABLE_CRASHPAD
|
|
||||||
ICore::settings()->setValue(crashReportingEnabledKey,
|
|
||||||
m_enableCrashReportingCheckBox->isChecked());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static_cast<Core::Internal::MainWindow *>(ICore::mainWindow())
|
|
||||||
->setAskConfirmationBeforeExit(m_askBeforeExitCheckBox->isChecked());
|
|
||||||
|
|
||||||
if (HostOsInfo::isMacHost()) {
|
if (HostOsInfo::isMacHost()) {
|
||||||
const Qt::CaseSensitivity sensitivity = EditorManagerPrivate::readFileSystemSensitivity(
|
const Qt::CaseSensitivity sensitivity = EditorManagerPrivate::readFileSystemSensitivity(
|
||||||
@@ -487,13 +496,20 @@ void SystemSettingsWidget::showHelpForFileBrowser()
|
|||||||
showHelpDialog(Tr::tr("Variables"), UnixUtils::fileBrowserHelpText());
|
showHelpDialog(Tr::tr("Variables"), UnixUtils::fileBrowserHelpText());
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemSettings::SystemSettings()
|
// SystemSettingsPage
|
||||||
{
|
|
||||||
setId(Constants::SETTINGS_ID_SYSTEM);
|
|
||||||
setDisplayName(Tr::tr("System"));
|
|
||||||
setCategory(Constants::SETTINGS_CATEGORY_CORE);
|
|
||||||
setWidgetCreator([] { return new SystemSettingsWidget; });
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
class SystemSettingsPage final : public IOptionsPage
|
||||||
} // namespace Core
|
{
|
||||||
|
public:
|
||||||
|
SystemSettingsPage()
|
||||||
|
{
|
||||||
|
setId(Constants::SETTINGS_ID_SYSTEM);
|
||||||
|
setDisplayName(Tr::tr("System"));
|
||||||
|
setCategory(Constants::SETTINGS_CATEGORY_CORE);
|
||||||
|
setWidgetCreator([] { return new SystemSettingsWidget; });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const SystemSettingsPage settingsPage;
|
||||||
|
|
||||||
|
} // Core::Internal
|
||||||
|
@@ -3,16 +3,38 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <utils/aspects.h>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class SystemSettings final : public IOptionsPage
|
class SystemSettings final : public Utils::AspectContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SystemSettings();
|
SystemSettings();
|
||||||
|
|
||||||
|
Utils::BoolAspect autoSaveModifiedFiles{this};
|
||||||
|
Utils::IntegerAspect autoSaveInterval{this};
|
||||||
|
|
||||||
|
Utils::BoolAspect autoSaveAfterRefactoring{this};
|
||||||
|
|
||||||
|
Utils::BoolAspect autoSuspendEnabled{this};
|
||||||
|
Utils::IntegerAspect autoSuspendMinDocumentCount{this};
|
||||||
|
|
||||||
|
Utils::BoolAspect warnBeforeOpeningBigFiles{this};
|
||||||
|
Utils::IntegerAspect bigFileSizeLimitInMB{this};
|
||||||
|
|
||||||
|
Utils::IntegerAspect maxRecentFiles{this};
|
||||||
|
|
||||||
|
Utils::SelectionAspect reloadSetting{this};
|
||||||
|
|
||||||
|
#ifdef ENABLE_CRASHPAD
|
||||||
|
Utils::BoolAspect enableCrashReporting{this};
|
||||||
|
Utils::BoolAspect showCrashButton{this};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Utils::BoolAspect askBeforeExit{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
SystemSettings &systemSettings();
|
||||||
} // namespace Core
|
|
||||||
|
} // Core::Internal
|
||||||
|
Reference in New Issue
Block a user