diff --git a/src/plugins/texteditor/behaviorsettings.cpp b/src/plugins/texteditor/behaviorsettings.cpp index 955b7d6709d..391e3a60e84 100644 --- a/src/plugins/texteditor/behaviorsettings.cpp +++ b/src/plugins/texteditor/behaviorsettings.cpp @@ -5,15 +5,12 @@ #include -#include - static const char mouseHidingKey[] = "MouseHiding"; static const char mouseNavigationKey[] = "MouseNavigation"; static const char scrollWheelZoomingKey[] = "ScrollWheelZooming"; static const char constrainTooltips[] = "ConstrainTooltips"; static const char camelCaseNavigationKey[] = "CamelCaseNavigation"; static const char keyboardTooltips[] = "KeyboardTooltips"; -static const char groupPostfix[] = "BehaviorSettings"; static const char smartSelectionChanging[] = "SmartSelectionChanging"; 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 { return { diff --git a/src/plugins/texteditor/behaviorsettings.h b/src/plugins/texteditor/behaviorsettings.h index e33fe5a2573..57f88f1b2c7 100644 --- a/src/plugins/texteditor/behaviorsettings.h +++ b/src/plugins/texteditor/behaviorsettings.h @@ -18,9 +18,6 @@ class TEXTEDITOR_EXPORT BehaviorSettings public: BehaviorSettings(); - void toSettings(const Utils::Key &category) const; - void fromSettings(const Utils::Key &category); - Utils::Store toMap() const; void fromMap(const Utils::Store &map); diff --git a/src/plugins/texteditor/behaviorsettingspage.cpp b/src/plugins/texteditor/behaviorsettingspage.cpp index 705f8ba8d20..4b1fad44bcb 100644 --- a/src/plugins/texteditor/behaviorsettingspage.cpp +++ b/src/plugins/texteditor/behaviorsettingspage.cpp @@ -28,15 +28,18 @@ #include #include -#include #include -#include #include using namespace Utils; namespace TextEditor { +const char behaviorGroup[] = "textBehaviorSettings"; +const char storageGroup[] = "textStorageSettings"; +const char typingGroup[] = "textTypingSettings"; +const char extraEncodingGroup[] = "textEditorManager"; + class BehaviorSettingsPagePrivate : public QObject { public: @@ -65,11 +68,12 @@ BehaviorSettingsPagePrivate::BehaviorSettingsPagePrivate() m_defaultCodeStylePool = new CodeStylePool(nullptr, this); // Any language m_defaultCodeStylePool->addCodeStyle(m_codeStyle); + QtcSettings *s = Core::ICore::settings(); m_codeStyle->fromSettings(m_settingsPrefix); - m_typingSettings.fromSettings(m_settingsPrefix); - m_storageSettings.fromSettings(m_settingsPrefix); - m_behaviorSettings.fromSettings(m_settingsPrefix); - m_extraEncodingSettings.fromSettings(m_settingsPrefix); + m_typingSettings.fromMap(storeFromSettings(typingGroup, s)); + m_storageSettings.fromMap(storeFromSettings(storageGroup, s)); + m_behaviorSettings.fromMap(storeFromSettings(behaviorGroup, s)); + m_extraEncodingSettings.fromMap(storeFromSettings(extraEncodingGroup, s)); } class BehaviorSettingsWidgetImpl : public Core::IOptionsPageWidget @@ -143,6 +147,8 @@ void BehaviorSettingsWidgetImpl::apply() if (!d->m_behaviorWidget) // page was never shown return; + QtcSettings *s = Core::ICore::settings(); + TypingSettings newTypingSettings; StorageSettings newStorageSettings; BehaviorSettings newBehaviorSettings; @@ -165,36 +171,35 @@ void BehaviorSettingsWidgetImpl::apply() if (newTypingSettings != d->m_typingSettings) { d->m_typingSettings = newTypingSettings; - d->m_typingSettings.toSettings(d->m_settingsPrefix); + storeToSettings(typingGroup, s, d->m_typingSettings.toMap()); emit TextEditorSettings::instance()->typingSettingsChanged(newTypingSettings); } if (newStorageSettings != d->m_storageSettings) { d->m_storageSettings = newStorageSettings; - d->m_storageSettings.toSettings(d->m_settingsPrefix); + storeToSettings(storageGroup, s, d->m_storageSettings.toMap()); emit TextEditorSettings::instance()->storageSettingsChanged(newStorageSettings); } if (newBehaviorSettings != d->m_behaviorSettings) { d->m_behaviorSettings = newBehaviorSettings; - d->m_behaviorSettings.toSettings(d->m_settingsPrefix); + storeToSettings(behaviorGroup, s, d->m_behaviorSettings.toMap()); emit TextEditorSettings::instance()->behaviorSettingsChanged(newBehaviorSettings); } if (newExtraEncodingSettings != d->m_extraEncodingSettings) { d->m_extraEncodingSettings = newExtraEncodingSettings; - d->m_extraEncodingSettings.toSettings(d->m_settingsPrefix); + storeToSettings(extraEncodingGroup, s, d->m_extraEncodingSettings.toMap()); emit TextEditorSettings::instance()->extraEncodingSettingsChanged(newExtraEncodingSettings); } - QSettings *s = Core::ICore::settings(); - s->setValue(QLatin1String(Core::Constants::SETTINGS_DEFAULTTEXTENCODING), + s->setValue(Core::Constants::SETTINGS_DEFAULTTEXTENCODING, 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()); } diff --git a/src/plugins/texteditor/extraencodingsettings.cpp b/src/plugins/texteditor/extraencodingsettings.cpp index e95e37b7e2e..dab2869423b 100644 --- a/src/plugins/texteditor/extraencodingsettings.cpp +++ b/src/plugins/texteditor/extraencodingsettings.cpp @@ -5,10 +5,7 @@ #include "texteditortr.h" -#include - // Keep this for compatibility reasons. -static const char kGroupPostfix[] = "EditorManager"; static const char kUtf8BomBehaviorKey[] = "Utf8BomBehavior"; using namespace Utils; @@ -20,21 +17,6 @@ ExtraEncodingSettings::ExtraEncodingSettings() : m_utf8BomSetting(OnlyKeep) 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 { return { diff --git a/src/plugins/texteditor/extraencodingsettings.h b/src/plugins/texteditor/extraencodingsettings.h index 6dcff332e4e..4d54dc2d7fc 100644 --- a/src/plugins/texteditor/extraencodingsettings.h +++ b/src/plugins/texteditor/extraencodingsettings.h @@ -15,9 +15,6 @@ public: ExtraEncodingSettings(); ~ExtraEncodingSettings(); - void toSettings(const Utils::Key &category) const; - void fromSettings(const Utils::Key &category); - Utils::Store toMap() const; void fromMap(const Utils::Store &map); diff --git a/src/plugins/texteditor/storagesettings.cpp b/src/plugins/texteditor/storagesettings.cpp index c0ee52bae12..b84011855c8 100644 --- a/src/plugins/texteditor/storagesettings.cpp +++ b/src/plugins/texteditor/storagesettings.cpp @@ -19,7 +19,6 @@ static const char addFinalNewLineKey[] = "addFinalNewLine"; static const char cleanIndentationKey[] = "cleanIndentation"; static const char skipTrailingWhitespaceKey[] = "skipTrailingWhitespace"; static const char ignoreFileTypesKey[] = "ignoreFileTypes"; -static const char groupPostfix[] = "StorageSettings"; static const char defaultTrailingWhitespaceBlacklist[] = "*.md, *.MD, Makefile"; 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 { return { diff --git a/src/plugins/texteditor/storagesettings.h b/src/plugins/texteditor/storagesettings.h index bf3ac1ba32a..757ad246a25 100644 --- a/src/plugins/texteditor/storagesettings.h +++ b/src/plugins/texteditor/storagesettings.h @@ -14,9 +14,6 @@ class TEXTEDITOR_EXPORT StorageSettings public: StorageSettings(); - void toSettings(const Utils::Key &category) const; - void fromSettings(const Utils::Key &category); - Utils::Store toMap() const; void fromMap(const Utils::Store &map); diff --git a/src/plugins/texteditor/tabsettings.cpp b/src/plugins/texteditor/tabsettings.cpp index a723c4ab4b1..c6c0558636f 100644 --- a/src/plugins/texteditor/tabsettings.cpp +++ b/src/plugins/texteditor/tabsettings.cpp @@ -12,7 +12,6 @@ static const char spacesForTabsKey[] = "SpacesForTabs"; static const char autoSpacesForTabsKey[] = "AutoSpacesForTabs"; static const char tabSizeKey[] = "TabSize"; static const char indentSizeKey[] = "IndentSize"; -static const char groupPostfix[] = "TabSettings"; static const char paddingModeKey[] = "PaddingMode"; using namespace Utils; @@ -28,18 +27,6 @@ TabSettings::TabSettings(TabSettings::TabPolicy tabPolicy, , m_indentSize(indentSize) , 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 diff --git a/src/plugins/texteditor/tabsettings.h b/src/plugins/texteditor/tabsettings.h index 73e895112ca..9a446738d0c 100644 --- a/src/plugins/texteditor/tabsettings.h +++ b/src/plugins/texteditor/tabsettings.h @@ -35,9 +35,6 @@ public: TabSettings(TabPolicy tabPolicy, int tabSize, 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; void fromMap(const Utils::Store &map); diff --git a/src/plugins/texteditor/typingsettings.cpp b/src/plugins/texteditor/typingsettings.cpp index e80a1fc4d8b..731f922a9dd 100644 --- a/src/plugins/texteditor/typingsettings.cpp +++ b/src/plugins/texteditor/typingsettings.cpp @@ -12,7 +12,6 @@ static const char autoIndentKey[] = "AutoIndent"; static const char tabKeyBehaviorKey[] = "TabKeyBehavior"; static const char smartBackspaceBehaviorKey[] = "SmartBackspaceBehavior"; static const char preferSingleLineCommentsKey[] = "PreferSingleLineComments"; -static const char groupPostfix[] = "TypingSettings"; 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 { return { diff --git a/src/plugins/texteditor/typingsettings.h b/src/plugins/texteditor/typingsettings.h index 63b1e6bea18..03d48610f39 100644 --- a/src/plugins/texteditor/typingsettings.h +++ b/src/plugins/texteditor/typingsettings.h @@ -35,9 +35,6 @@ public: 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; void fromMap(const Utils::Store &map);