forked from qt-creator/qt-creator
TextEditor: Access some settings more directly
Change-Id: Idc65001efde36de011db3ca528af761d2b8344e8 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -5,15 +5,12 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
static const char mouseHidingKey[] = "MouseHiding";
|
static const char mouseHidingKey[] = "MouseHiding";
|
||||||
static const char mouseNavigationKey[] = "MouseNavigation";
|
static const char mouseNavigationKey[] = "MouseNavigation";
|
||||||
static const char scrollWheelZoomingKey[] = "ScrollWheelZooming";
|
static const char scrollWheelZoomingKey[] = "ScrollWheelZooming";
|
||||||
static const char constrainTooltips[] = "ConstrainTooltips";
|
static const char constrainTooltips[] = "ConstrainTooltips";
|
||||||
static const char camelCaseNavigationKey[] = "CamelCaseNavigation";
|
static const char camelCaseNavigationKey[] = "CamelCaseNavigation";
|
||||||
static const char keyboardTooltips[] = "KeyboardTooltips";
|
static const char keyboardTooltips[] = "KeyboardTooltips";
|
||||||
static const char groupPostfix[] = "BehaviorSettings";
|
|
||||||
static const char smartSelectionChanging[] = "SmartSelectionChanging";
|
static const char smartSelectionChanging[] = "SmartSelectionChanging";
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -31,17 +28,6 @@ BehaviorSettings::BehaviorSettings() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorSettings::toSettings(const Key &category) const
|
|
||||||
{
|
|
||||||
Utils::storeToSettings(category + groupPostfix, Core::ICore::settings(), toMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BehaviorSettings::fromSettings(const Key &category)
|
|
||||||
{
|
|
||||||
*this = BehaviorSettings();
|
|
||||||
fromMap(Utils::storeFromSettings(category + groupPostfix, Core::ICore::settings()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Store BehaviorSettings::toMap() const
|
Store BehaviorSettings::toMap() const
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
@@ -18,9 +18,6 @@ class TEXTEDITOR_EXPORT BehaviorSettings
|
|||||||
public:
|
public:
|
||||||
BehaviorSettings();
|
BehaviorSettings();
|
||||||
|
|
||||||
void toSettings(const Utils::Key &category) const;
|
|
||||||
void fromSettings(const Utils::Key &category);
|
|
||||||
|
|
||||||
Utils::Store toMap() const;
|
Utils::Store toMap() const;
|
||||||
void fromMap(const Utils::Store &map);
|
void fromMap(const Utils::Store &map);
|
||||||
|
|
||||||
|
@@ -28,15 +28,18 @@
|
|||||||
#include <qmljseditor/qmljseditorconstants.h>
|
#include <qmljseditor/qmljseditorconstants.h>
|
||||||
#include <qmljstools/qmljstoolsconstants.h>
|
#include <qmljstools/qmljstoolsconstants.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QPointer>
|
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
|
const char behaviorGroup[] = "textBehaviorSettings";
|
||||||
|
const char storageGroup[] = "textStorageSettings";
|
||||||
|
const char typingGroup[] = "textTypingSettings";
|
||||||
|
const char extraEncodingGroup[] = "textEditorManager";
|
||||||
|
|
||||||
class BehaviorSettingsPagePrivate : public QObject
|
class BehaviorSettingsPagePrivate : public QObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -65,11 +68,12 @@ BehaviorSettingsPagePrivate::BehaviorSettingsPagePrivate()
|
|||||||
m_defaultCodeStylePool = new CodeStylePool(nullptr, this); // Any language
|
m_defaultCodeStylePool = new CodeStylePool(nullptr, this); // Any language
|
||||||
m_defaultCodeStylePool->addCodeStyle(m_codeStyle);
|
m_defaultCodeStylePool->addCodeStyle(m_codeStyle);
|
||||||
|
|
||||||
|
QtcSettings *s = Core::ICore::settings();
|
||||||
m_codeStyle->fromSettings(m_settingsPrefix);
|
m_codeStyle->fromSettings(m_settingsPrefix);
|
||||||
m_typingSettings.fromSettings(m_settingsPrefix);
|
m_typingSettings.fromMap(storeFromSettings(typingGroup, s));
|
||||||
m_storageSettings.fromSettings(m_settingsPrefix);
|
m_storageSettings.fromMap(storeFromSettings(storageGroup, s));
|
||||||
m_behaviorSettings.fromSettings(m_settingsPrefix);
|
m_behaviorSettings.fromMap(storeFromSettings(behaviorGroup, s));
|
||||||
m_extraEncodingSettings.fromSettings(m_settingsPrefix);
|
m_extraEncodingSettings.fromMap(storeFromSettings(extraEncodingGroup, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
class BehaviorSettingsWidgetImpl : public Core::IOptionsPageWidget
|
class BehaviorSettingsWidgetImpl : public Core::IOptionsPageWidget
|
||||||
@@ -143,6 +147,8 @@ void BehaviorSettingsWidgetImpl::apply()
|
|||||||
if (!d->m_behaviorWidget) // page was never shown
|
if (!d->m_behaviorWidget) // page was never shown
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QtcSettings *s = Core::ICore::settings();
|
||||||
|
|
||||||
TypingSettings newTypingSettings;
|
TypingSettings newTypingSettings;
|
||||||
StorageSettings newStorageSettings;
|
StorageSettings newStorageSettings;
|
||||||
BehaviorSettings newBehaviorSettings;
|
BehaviorSettings newBehaviorSettings;
|
||||||
@@ -165,36 +171,35 @@ void BehaviorSettingsWidgetImpl::apply()
|
|||||||
|
|
||||||
if (newTypingSettings != d->m_typingSettings) {
|
if (newTypingSettings != d->m_typingSettings) {
|
||||||
d->m_typingSettings = newTypingSettings;
|
d->m_typingSettings = newTypingSettings;
|
||||||
d->m_typingSettings.toSettings(d->m_settingsPrefix);
|
storeToSettings(typingGroup, s, d->m_typingSettings.toMap());
|
||||||
|
|
||||||
emit TextEditorSettings::instance()->typingSettingsChanged(newTypingSettings);
|
emit TextEditorSettings::instance()->typingSettingsChanged(newTypingSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newStorageSettings != d->m_storageSettings) {
|
if (newStorageSettings != d->m_storageSettings) {
|
||||||
d->m_storageSettings = newStorageSettings;
|
d->m_storageSettings = newStorageSettings;
|
||||||
d->m_storageSettings.toSettings(d->m_settingsPrefix);
|
storeToSettings(storageGroup, s, d->m_storageSettings.toMap());
|
||||||
|
|
||||||
emit TextEditorSettings::instance()->storageSettingsChanged(newStorageSettings);
|
emit TextEditorSettings::instance()->storageSettingsChanged(newStorageSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newBehaviorSettings != d->m_behaviorSettings) {
|
if (newBehaviorSettings != d->m_behaviorSettings) {
|
||||||
d->m_behaviorSettings = newBehaviorSettings;
|
d->m_behaviorSettings = newBehaviorSettings;
|
||||||
d->m_behaviorSettings.toSettings(d->m_settingsPrefix);
|
storeToSettings(behaviorGroup, s, d->m_behaviorSettings.toMap());
|
||||||
|
|
||||||
emit TextEditorSettings::instance()->behaviorSettingsChanged(newBehaviorSettings);
|
emit TextEditorSettings::instance()->behaviorSettingsChanged(newBehaviorSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newExtraEncodingSettings != d->m_extraEncodingSettings) {
|
if (newExtraEncodingSettings != d->m_extraEncodingSettings) {
|
||||||
d->m_extraEncodingSettings = newExtraEncodingSettings;
|
d->m_extraEncodingSettings = newExtraEncodingSettings;
|
||||||
d->m_extraEncodingSettings.toSettings(d->m_settingsPrefix);
|
storeToSettings(extraEncodingGroup, s, d->m_extraEncodingSettings.toMap());
|
||||||
|
|
||||||
emit TextEditorSettings::instance()->extraEncodingSettingsChanged(newExtraEncodingSettings);
|
emit TextEditorSettings::instance()->extraEncodingSettingsChanged(newExtraEncodingSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSettings *s = Core::ICore::settings();
|
s->setValue(Core::Constants::SETTINGS_DEFAULTTEXTENCODING,
|
||||||
s->setValue(QLatin1String(Core::Constants::SETTINGS_DEFAULTTEXTENCODING),
|
|
||||||
d->m_behaviorWidget->assignedCodecName());
|
d->m_behaviorWidget->assignedCodecName());
|
||||||
s->setValue(QLatin1String(Core::Constants::SETTINGS_DEFAULT_LINE_TERMINATOR),
|
s->setValue(Core::Constants::SETTINGS_DEFAULT_LINE_TERMINATOR,
|
||||||
d->m_behaviorWidget->assignedLineEnding());
|
d->m_behaviorWidget->assignedLineEnding());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,10 +5,7 @@
|
|||||||
|
|
||||||
#include "texteditortr.h"
|
#include "texteditortr.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
|
|
||||||
// Keep this for compatibility reasons.
|
// Keep this for compatibility reasons.
|
||||||
static const char kGroupPostfix[] = "EditorManager";
|
|
||||||
static const char kUtf8BomBehaviorKey[] = "Utf8BomBehavior";
|
static const char kUtf8BomBehaviorKey[] = "Utf8BomBehavior";
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -20,21 +17,6 @@ ExtraEncodingSettings::ExtraEncodingSettings() : m_utf8BomSetting(OnlyKeep)
|
|||||||
|
|
||||||
ExtraEncodingSettings::~ExtraEncodingSettings() = default;
|
ExtraEncodingSettings::~ExtraEncodingSettings() = default;
|
||||||
|
|
||||||
void ExtraEncodingSettings::toSettings(const Key &category) const
|
|
||||||
{
|
|
||||||
Q_UNUSED(category)
|
|
||||||
|
|
||||||
Utils::storeToSettings(kGroupPostfix, Core::ICore::settings(), toMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtraEncodingSettings::fromSettings(const Key &category)
|
|
||||||
{
|
|
||||||
Q_UNUSED(category)
|
|
||||||
|
|
||||||
*this = ExtraEncodingSettings();
|
|
||||||
fromMap(Utils::storeFromSettings(kGroupPostfix, Core::ICore::settings()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Store ExtraEncodingSettings::toMap() const
|
Store ExtraEncodingSettings::toMap() const
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
@@ -15,9 +15,6 @@ public:
|
|||||||
ExtraEncodingSettings();
|
ExtraEncodingSettings();
|
||||||
~ExtraEncodingSettings();
|
~ExtraEncodingSettings();
|
||||||
|
|
||||||
void toSettings(const Utils::Key &category) const;
|
|
||||||
void fromSettings(const Utils::Key &category);
|
|
||||||
|
|
||||||
Utils::Store toMap() const;
|
Utils::Store toMap() const;
|
||||||
void fromMap(const Utils::Store &map);
|
void fromMap(const Utils::Store &map);
|
||||||
|
|
||||||
|
@@ -19,7 +19,6 @@ static const char addFinalNewLineKey[] = "addFinalNewLine";
|
|||||||
static const char cleanIndentationKey[] = "cleanIndentation";
|
static const char cleanIndentationKey[] = "cleanIndentation";
|
||||||
static const char skipTrailingWhitespaceKey[] = "skipTrailingWhitespace";
|
static const char skipTrailingWhitespaceKey[] = "skipTrailingWhitespace";
|
||||||
static const char ignoreFileTypesKey[] = "ignoreFileTypes";
|
static const char ignoreFileTypesKey[] = "ignoreFileTypes";
|
||||||
static const char groupPostfix[] = "StorageSettings";
|
|
||||||
static const char defaultTrailingWhitespaceBlacklist[] = "*.md, *.MD, Makefile";
|
static const char defaultTrailingWhitespaceBlacklist[] = "*.md, *.MD, Makefile";
|
||||||
|
|
||||||
StorageSettings::StorageSettings()
|
StorageSettings::StorageSettings()
|
||||||
@@ -32,17 +31,6 @@ StorageSettings::StorageSettings()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorageSettings::toSettings(const Key &category) const
|
|
||||||
{
|
|
||||||
Utils::storeToSettings(category + groupPostfix, Core::ICore::settings(), toMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
void StorageSettings::fromSettings(const Key &category)
|
|
||||||
{
|
|
||||||
*this = StorageSettings();
|
|
||||||
fromMap(Utils::storeFromSettings(category + groupPostfix, Core::ICore::settings()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Store StorageSettings::toMap() const
|
Store StorageSettings::toMap() const
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
@@ -14,9 +14,6 @@ class TEXTEDITOR_EXPORT StorageSettings
|
|||||||
public:
|
public:
|
||||||
StorageSettings();
|
StorageSettings();
|
||||||
|
|
||||||
void toSettings(const Utils::Key &category) const;
|
|
||||||
void fromSettings(const Utils::Key &category);
|
|
||||||
|
|
||||||
Utils::Store toMap() const;
|
Utils::Store toMap() const;
|
||||||
void fromMap(const Utils::Store &map);
|
void fromMap(const Utils::Store &map);
|
||||||
|
|
||||||
|
@@ -12,7 +12,6 @@ static const char spacesForTabsKey[] = "SpacesForTabs";
|
|||||||
static const char autoSpacesForTabsKey[] = "AutoSpacesForTabs";
|
static const char autoSpacesForTabsKey[] = "AutoSpacesForTabs";
|
||||||
static const char tabSizeKey[] = "TabSize";
|
static const char tabSizeKey[] = "TabSize";
|
||||||
static const char indentSizeKey[] = "IndentSize";
|
static const char indentSizeKey[] = "IndentSize";
|
||||||
static const char groupPostfix[] = "TabSettings";
|
|
||||||
static const char paddingModeKey[] = "PaddingMode";
|
static const char paddingModeKey[] = "PaddingMode";
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -28,18 +27,6 @@ TabSettings::TabSettings(TabSettings::TabPolicy tabPolicy,
|
|||||||
, m_indentSize(indentSize)
|
, m_indentSize(indentSize)
|
||||||
, m_continuationAlignBehavior(continuationAlignBehavior)
|
, m_continuationAlignBehavior(continuationAlignBehavior)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabSettings::toSettings(const Key &category, QtcSettings *s) const
|
|
||||||
{
|
|
||||||
Utils::storeToSettings(category + groupPostfix, s, toMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
void TabSettings::fromSettings(const Key &category, QtcSettings *s)
|
|
||||||
{
|
|
||||||
*this = TabSettings(); // Assign defaults
|
|
||||||
fromMap(Utils::storeFromSettings(category + groupPostfix, s));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Store TabSettings::toMap() const
|
Store TabSettings::toMap() const
|
||||||
|
@@ -35,9 +35,6 @@ public:
|
|||||||
TabSettings(TabPolicy tabPolicy, int tabSize,
|
TabSettings(TabPolicy tabPolicy, int tabSize,
|
||||||
int indentSize, ContinuationAlignBehavior continuationAlignBehavior);
|
int indentSize, ContinuationAlignBehavior continuationAlignBehavior);
|
||||||
|
|
||||||
void toSettings(const Utils::Key &category, Utils::QtcSettings *s) const;
|
|
||||||
void fromSettings(const Utils::Key &category, Utils::QtcSettings *s);
|
|
||||||
|
|
||||||
Utils::Store toMap() const;
|
Utils::Store toMap() const;
|
||||||
void fromMap(const Utils::Store &map);
|
void fromMap(const Utils::Store &map);
|
||||||
|
|
||||||
|
@@ -12,7 +12,6 @@ static const char autoIndentKey[] = "AutoIndent";
|
|||||||
static const char tabKeyBehaviorKey[] = "TabKeyBehavior";
|
static const char tabKeyBehaviorKey[] = "TabKeyBehavior";
|
||||||
static const char smartBackspaceBehaviorKey[] = "SmartBackspaceBehavior";
|
static const char smartBackspaceBehaviorKey[] = "SmartBackspaceBehavior";
|
||||||
static const char preferSingleLineCommentsKey[] = "PreferSingleLineComments";
|
static const char preferSingleLineCommentsKey[] = "PreferSingleLineComments";
|
||||||
static const char groupPostfix[] = "TypingSettings";
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -26,17 +25,6 @@ TypingSettings::TypingSettings():
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypingSettings::toSettings(const Key &category) const
|
|
||||||
{
|
|
||||||
Utils::storeToSettings(category + groupPostfix, Core::ICore::settings(), toMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
void TypingSettings::fromSettings(const Key &category)
|
|
||||||
{
|
|
||||||
*this = TypingSettings(); // Assign defaults
|
|
||||||
fromMap(Utils::storeFromSettings(category + groupPostfix, Core::ICore::settings()));
|
|
||||||
}
|
|
||||||
|
|
||||||
Store TypingSettings::toMap() const
|
Store TypingSettings::toMap() const
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
@@ -35,9 +35,6 @@ public:
|
|||||||
|
|
||||||
bool tabShouldIndent(const QTextDocument *document, const QTextCursor &cursor, int *suggestedPosition) const;
|
bool tabShouldIndent(const QTextDocument *document, const QTextCursor &cursor, int *suggestedPosition) const;
|
||||||
|
|
||||||
void toSettings(const Utils::Key &category) const;
|
|
||||||
void fromSettings(const Utils::Key &category);
|
|
||||||
|
|
||||||
Utils::Store toMap() const;
|
Utils::Store toMap() const;
|
||||||
void fromMap(const Utils::Store &map);
|
void fromMap(const Utils::Store &map);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user