diff --git a/src/app/main.cpp b/src/app/main.cpp index b4ac0dfee9f..cccb492d242 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -661,7 +661,7 @@ int main(int argc, char **argv) QTranslator translator; QTranslator qtTranslator; QStringList uiLanguages = QLocale::system().uiLanguages(); - QString overrideLanguage = settings->value(QLatin1String("General/OverrideLanguage")).toString(); + QString overrideLanguage = settings->value("General/OverrideLanguage").toString(); if (!overrideLanguage.isEmpty()) uiLanguages.prepend(overrideLanguage); if (!options.uiLanguage.isEmpty()) diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index c0395115441..503eecadeeb 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -1018,12 +1018,12 @@ void PluginManagerPrivate::writeSettings() void PluginManagerPrivate::readSettings() { if (globalSettings) { - defaultDisabledPlugins = globalSettings->value(QLatin1String(C_IGNORED_PLUGINS)).toStringList(); - defaultEnabledPlugins = globalSettings->value(QLatin1String(C_FORCEENABLED_PLUGINS)).toStringList(); + defaultDisabledPlugins = globalSettings->value(C_IGNORED_PLUGINS).toStringList(); + defaultEnabledPlugins = globalSettings->value(C_FORCEENABLED_PLUGINS).toStringList(); } if (settings) { - disabledPlugins = settings->value(QLatin1String(C_IGNORED_PLUGINS)).toStringList(); - forceEnabledPlugins = settings->value(QLatin1String(C_FORCEENABLED_PLUGINS)).toStringList(); + disabledPlugins = settings->value(C_IGNORED_PLUGINS).toStringList(); + forceEnabledPlugins = settings->value(C_FORCEENABLED_PLUGINS).toStringList(); } } diff --git a/src/libs/utils/historycompleter.cpp b/src/libs/utils/historycompleter.cpp index 7f299af1372..8eff3fdad82 100644 --- a/src/libs/utils/historycompleter.cpp +++ b/src/libs/utils/historycompleter.cpp @@ -207,10 +207,10 @@ QString HistoryCompleter::historyItem() const return d->list.at(0); } -bool HistoryCompleter::historyExistsFor(const QString &historyKey) +bool HistoryCompleter::historyExistsFor(const Key &historyKey) { QTC_ASSERT(theSettings, return false); - const QString fullKey = QLatin1String("CompleterHistory/") + historyKey; + const Key fullKey = "CompleterHistory/" + historyKey; return theSettings->value(fullKey).isValid(); } diff --git a/src/libs/utils/historycompleter.h b/src/libs/utils/historycompleter.h index b0842549fef..4afb3f420ca 100644 --- a/src/libs/utils/historycompleter.h +++ b/src/libs/utils/historycompleter.h @@ -23,7 +23,7 @@ public: bool removeHistoryItem(int index); QString historyItem() const; bool hasHistory() const { return historySize() > 0; } - static bool historyExistsFor(const QString &historyKey); + static bool historyExistsFor(const Key &historyKey); void clearHistory(); void addEntry(const QString &str); diff --git a/src/libs/utils/qtcsettings.h b/src/libs/utils/qtcsettings.h index 05d44ef2ffd..ba0550c31af 100644 --- a/src/libs/utils/qtcsettings.h +++ b/src/libs/utils/qtcsettings.h @@ -16,50 +16,45 @@ class QTCREATOR_UTILS_EXPORT QtcSettings : public QSettings public: using QSettings::QSettings; + QVariant value(const Key &key) const { return QSettings::value(stringFromKey(key)); } + QVariant value(const Key &key, const QVariant &def) const { return QSettings::value(stringFromKey(key), def); } + void setValue(const Key &key, const QVariant &value) { QSettings::setValue(stringFromKey(key), value); } + void remove(const Key &key) { QSettings::remove(stringFromKey(key)); } + bool contains(const Key &key) const { return QSettings::contains(stringFromKey(key)); } + template - void setValueWithDefault(const Key &key, const T &val, const T &defaultValue); - template - void setValueWithDefault(const Key &key, const T &val); + void setValueWithDefault(const Key &key, const T &val, const T &defaultValue) + { + setValueWithDefault(this, key, val, defaultValue); + } template static void setValueWithDefault(QSettings *settings, const Key &key, const T &val, - const T &defaultValue); + const T &defaultValue) + { + if (val == defaultValue) + settings->remove(stringFromKey(key)); + else + settings->setValue(stringFromKey(key), QVariant::fromValue(val)); + } + + template - static void setValueWithDefault(QSettings *settings, const Key &key, const T &val); + void setValueWithDefault(const Key &key, const T &val) + { + setValueWithDefault(this, key, val); + } + + template + static void setValueWithDefault(QSettings *settings, const Key &key, const T &val) + { + if (val == T()) + settings->remove(stringFromKey(key)); + else + settings->setValue(stringFromKey(key), QVariant::fromValue(val)); + } }; -template -void QtcSettings::setValueWithDefault(const Key &key, const T &val, const T &defaultValue) -{ - setValueWithDefault(this, key, val, defaultValue); -} - -template -void QtcSettings::setValueWithDefault(const Key &key, const T &val) -{ - setValueWithDefault(this, key, val); -} - -template -void QtcSettings::setValueWithDefault(QSettings *settings, - const Key &key, - const T &val, - const T &defaultValue) -{ - if (val == defaultValue) - settings->remove(key); - else - settings->setValue(key, QVariant::fromValue(val)); -} - -template -void QtcSettings::setValueWithDefault(QSettings *settings, const Key &key, const T &val) -{ - if (val == T()) - settings->remove(key); - else - settings->setValue(key, QVariant::fromValue(val)); -} } // namespace Utils diff --git a/src/libs/utils/store.cpp b/src/libs/utils/store.cpp index a2cc60c5d2f..96425d8f467 100644 --- a/src/libs/utils/store.cpp +++ b/src/libs/utils/store.cpp @@ -116,4 +116,9 @@ bool isStore(const QVariant &value) return typeId == QMetaType::QVariantMap || typeId == qMetaTypeId(); } +Key numberedKey(const Key &key, int number) +{ + return key + Key::number(number); +} + } // Utils diff --git a/src/libs/utils/store.h b/src/libs/utils/store.h index cfebee71cc6..85f677151fa 100644 --- a/src/libs/utils/store.h +++ b/src/libs/utils/store.h @@ -29,6 +29,8 @@ QTCREATOR_UTILS_EXPORT QVariantMap mapFromStore(const Store &store); QTCREATOR_UTILS_EXPORT bool isStore(const QVariant &value); +QTCREATOR_UTILS_EXPORT Key numberedKey(const Key &key, int number); + } // Utils #ifdef QTC_USE_STORE diff --git a/src/plugins/clangformat/clangformatsettings.cpp b/src/plugins/clangformat/clangformatsettings.cpp index 1c76d14df6b..f6be8e922ab 100644 --- a/src/plugins/clangformat/clangformatsettings.cpp +++ b/src/plugins/clangformat/clangformatsettings.cpp @@ -6,8 +6,11 @@ #include +using namespace Utils; + namespace ClangFormat { -static const char FORMAT_CODE_INSTEAD_OF_INDENT_ID[] = "ClangFormat.FormatCodeInsteadOfIndent"; + +const char FORMAT_CODE_INSTEAD_OF_INDENT_ID[] = "ClangFormat.FormatCodeInsteadOfIndent"; ClangFormatSettings &ClangFormatSettings::instance() { @@ -17,43 +20,37 @@ ClangFormatSettings &ClangFormatSettings::instance() ClangFormatSettings::ClangFormatSettings() { - QSettings *settings = Core::ICore::settings(); + QtcSettings *settings = Core::ICore::settings(); settings->beginGroup(QLatin1String(Constants::SETTINGS_ID)); - m_overrideDefaultFile = settings->value(QLatin1String(Constants::OVERRIDE_FILE_ID), false) - .toBool(); - m_formatWhileTyping = settings->value(QLatin1String(Constants::FORMAT_WHILE_TYPING_ID), false) - .toBool(); - m_formatOnSave = settings->value(QLatin1String(Constants::FORMAT_CODE_ON_SAVE_ID), false) - .toBool(); - m_fileSizeThreshold - = settings->value(QLatin1String(Constants::FILE_SIZE_THREDSHOLD), 1024).toInt(); + m_overrideDefaultFile = settings->value(Constants::OVERRIDE_FILE_ID, false).toBool(); + m_formatWhileTyping = settings->value(Constants::FORMAT_WHILE_TYPING_ID, false).toBool(); + m_formatOnSave = settings->value(Constants::FORMAT_CODE_ON_SAVE_ID, false).toBool(); + m_fileSizeThreshold = settings->value(Constants::FILE_SIZE_THREDSHOLD, 1024).toInt(); // Convert old settings to new ones. New settings were added to QtC 8.0 - bool isOldFormattingOn - = settings->value(QLatin1String(FORMAT_CODE_INSTEAD_OF_INDENT_ID), false).toBool(); - Core::ICore::settings()->remove(QLatin1String(FORMAT_CODE_INSTEAD_OF_INDENT_ID)); + bool isOldFormattingOn = settings->value(FORMAT_CODE_INSTEAD_OF_INDENT_ID, false).toBool(); + Core::ICore::settings()->remove(FORMAT_CODE_INSTEAD_OF_INDENT_ID); if (isOldFormattingOn) { - settings->setValue(QLatin1String(Constants::MODE_ID), + settings->setValue(Constants::MODE_ID, static_cast(ClangFormatSettings::Mode::Formatting)); m_mode = ClangFormatSettings::Mode::Formatting; } else m_mode = static_cast( - settings->value(QLatin1String(Constants::MODE_ID), ClangFormatSettings::Mode::Indenting) - .toInt()); + settings->value(Constants::MODE_ID, ClangFormatSettings::Mode::Indenting).toInt()); settings->endGroup(); } void ClangFormatSettings::write() const { - QSettings *settings = Core::ICore::settings(); + QtcSettings *settings = Core::ICore::settings(); settings->beginGroup(QLatin1String(Constants::SETTINGS_ID)); - settings->setValue(QLatin1String(Constants::OVERRIDE_FILE_ID), m_overrideDefaultFile); - settings->setValue(QLatin1String(Constants::FORMAT_WHILE_TYPING_ID), m_formatWhileTyping); - settings->setValue(QLatin1String(Constants::FORMAT_CODE_ON_SAVE_ID), m_formatOnSave); - settings->setValue(QLatin1String(Constants::MODE_ID), static_cast(m_mode)); - settings->setValue(QLatin1String(Constants::FILE_SIZE_THREDSHOLD), m_fileSizeThreshold); + settings->setValue(Constants::OVERRIDE_FILE_ID, m_overrideDefaultFile); + settings->setValue(Constants::FORMAT_WHILE_TYPING_ID, m_formatWhileTyping); + settings->setValue(Constants::FORMAT_CODE_ON_SAVE_ID, m_formatOnSave); + settings->setValue(Constants::MODE_ID, static_cast(m_mode)); + settings->setValue(Constants::FILE_SIZE_THREDSHOLD, m_fileSizeThreshold); settings->endGroup(); } diff --git a/src/plugins/classview/classviewnavigationwidgetfactory.cpp b/src/plugins/classview/classviewnavigationwidgetfactory.cpp index 7347bcd806e..91612317be5 100644 --- a/src/plugins/classview/classviewnavigationwidgetfactory.cpp +++ b/src/plugins/classview/classviewnavigationwidgetfactory.cpp @@ -9,7 +9,7 @@ #include #include -#include +using namespace Utils; namespace ClassView { namespace Internal { @@ -42,32 +42,30 @@ Core::NavigationView NavigationWidgetFactory::createWidget() /*! Returns a settings prefix for \a position. */ -static QString settingsPrefix(int position) +static Key settingsPrefix(int position) { - return QString::fromLatin1("ClassView.Treewidget.%1.FlatMode").arg(position); + return numberedKey("ClassView.Treewidget.", position) + ".FlatMode"; } //! Flat mode settings -void NavigationWidgetFactory::saveSettings(Utils::QtcSettings *settings, - int position, - QWidget *widget) +void NavigationWidgetFactory::saveSettings(QtcSettings *settings, int position, QWidget *widget) { auto pw = qobject_cast(widget); QTC_ASSERT(pw, return); // .beginGroup is not used - to prevent simultaneous access - QString settingsGroup = settingsPrefix(position); + Key settingsGroup = settingsPrefix(position); settings->setValue(settingsGroup, pw->flatMode()); } -void NavigationWidgetFactory::restoreSettings(Utils::QtcSettings *settings, int position, QWidget *widget) +void NavigationWidgetFactory::restoreSettings(QtcSettings *settings, int position, QWidget *widget) { auto pw = qobject_cast(widget); QTC_ASSERT(pw, return); // .beginGroup is not used - to prevent simultaneous access - QString settingsGroup = settingsPrefix(position); + Key settingsGroup = settingsPrefix(position); pw->setFlatMode(settings->value(settingsGroup, false).toBool()); } diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp index 54e58dc217a..f17cc76d9ae 100644 --- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp +++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp @@ -490,8 +490,8 @@ void ActionManagerPrivate::readUserSettings(Id id, Command *cmd) void ActionManagerPrivate::saveSettings(Command *cmd) { - const QString id = cmd->id().toString(); - const QString settingsKey = QLatin1String(kKeyboardSettingsKeyV2) + '/' + id; + const Key id = cmd->id().toKey(); + const Key settingsKey = kKeyboardSettingsKeyV2 + '/' + id; const QList keys = cmd->keySequences(); const QList defaultKeys = cmd->defaultKeySequences(); if (keys != defaultKeys) { diff --git a/src/plugins/coreplugin/dialogs/newdialogwidget.cpp b/src/plugins/coreplugin/dialogs/newdialogwidget.cpp index 545ca9c4169..ca616c8b65c 100644 --- a/src/plugins/coreplugin/dialogs/newdialogwidget.cpp +++ b/src/plugins/coreplugin/dialogs/newdialogwidget.cpp @@ -327,8 +327,8 @@ void NewDialogWidget::showDialog() { QModelIndex idx; - QString lastPlatform = ICore::settings()->value(QLatin1String(LAST_PLATFORM_KEY)).toString(); - QString lastCategory = ICore::settings()->value(QLatin1String(LAST_CATEGORY_KEY)).toString(); + QString lastPlatform = ICore::settings()->value(LAST_PLATFORM_KEY).toString(); + QString lastCategory = ICore::settings()->value(LAST_CATEGORY_KEY).toString(); if (!lastPlatform.isEmpty()) { int index = m_comboBox->findData(lastPlatform); diff --git a/src/plugins/coreplugin/foldernavigationwidget.cpp b/src/plugins/coreplugin/foldernavigationwidget.cpp index 562c2a8155b..6cee44c5917 100644 --- a/src/plugins/coreplugin/foldernavigationwidget.cpp +++ b/src/plugins/coreplugin/foldernavigationwidget.cpp @@ -861,7 +861,7 @@ void FolderNavigationWidgetFactory::restoreSettings(QtcSettings *settings, int p { auto fnw = qobject_cast(widget); QTC_ASSERT(fnw, return); - const QString base = kSettingsBase + QString::number(position); + const Key base = kSettingsBase + Key::number(position); fnw->setHiddenFilesFilter(settings->value(base + kHiddenFilesKey, kHiddenFilesDefault).toBool()); fnw->setAutoSynchronization(settings->value(base + kSyncKey, kAutoSyncDefault).toBool()); fnw->setShowBreadCrumbs( diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp index 13f853e7592..4cc865de8ea 100644 --- a/src/plugins/coreplugin/generalsettings.cpp +++ b/src/plugins/coreplugin/generalsettings.cpp @@ -263,7 +263,7 @@ QString GeneralSettingsWidget::language() void GeneralSettingsWidget::setLanguage(const QString &locale) { QtcSettings *settings = ICore::settings(); - if (settings->value(QLatin1String("General/OverrideLanguage")).toString() != locale) { + if (settings->value("General/OverrideLanguage").toString() != locale) { RestartDialog dialog(ICore::dialogParent(), Tr::tr("The language change will take effect after restart.")); dialog.exec(); diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 42c5244cd57..f155365bd7e 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1477,12 +1477,12 @@ void DebuggerPluginPrivate::parseCommandLineArguments() QTimer::singleShot(0, this, &DebuggerPluginPrivate::runScheduled); } -static void setConfigValue(const QString &name, const QVariant &value) +static void setConfigValue(const Key &name, const QVariant &value) { ICore::settings()->setValue("DebugMode/" + name, value); } -static QVariant configValue(const QString &name) +static QVariant configValue(const Key &name) { return ICore::settings()->value("DebugMode/" + name); } @@ -1658,7 +1658,7 @@ void DebuggerPluginPrivate::reloadDebuggingHelpers() void DebuggerPluginPrivate::startRemoteCdbSession() { - const QString connectionKey = "CdbRemoteConnection"; + const Key connectionKey = "CdbRemoteConnection"; Kit *kit = findUniversalCdbKit(); QTC_ASSERT(kit, return); diff --git a/src/plugins/designer/settingsmanager.cpp b/src/plugins/designer/settingsmanager.cpp index f533d401072..1cef5f4b074 100644 --- a/src/plugins/designer/settingsmanager.cpp +++ b/src/plugins/designer/settingsmanager.cpp @@ -4,12 +4,20 @@ #include "settingsmanager.h" #include + #include -#include -#include +using namespace Utils; -using namespace Designer::Internal; +namespace Designer::Internal { + +static Key addPrefix(const QString &name) +{ + Key result = keyFromString(name); + if (Core::ICore::settings()->group().isEmpty()) + result.prepend("Designer"); + return result; +} void SettingsManager::beginGroup(const QString &prefix) { @@ -41,10 +49,4 @@ void SettingsManager::remove(const QString &key) Core::ICore::settings()->remove(addPrefix(key)); } -QString SettingsManager::addPrefix(const QString &name) const -{ - QString result = name; - if (Core::ICore::settings()->group().isEmpty()) - result.prepend("Designer"); - return result; -} +} // Designer::Internal diff --git a/src/plugins/designer/settingsmanager.h b/src/plugins/designer/settingsmanager.h index 633e58d117d..06ce37a98cb 100644 --- a/src/plugins/designer/settingsmanager.h +++ b/src/plugins/designer/settingsmanager.h @@ -21,9 +21,6 @@ public: void setValue(const QString &key, const QVariant &value) override; QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const override; void remove(const QString &key) override; - -private: - QString addPrefix(const QString &name) const; }; } // namespace Internal diff --git a/src/plugins/help/helpmanager.cpp b/src/plugins/help/helpmanager.cpp index 3c053662d54..f971f825689 100644 --- a/src/plugins/help/helpmanager.cpp +++ b/src/plugins/help/helpmanager.cpp @@ -29,13 +29,14 @@ #include using namespace Core; - -static const char kUserDocumentationKey[] = "Help/UserDocumentation"; -static const char kUpdateDocumentationTask[] = "UpdateDocumentationTask"; +using namespace Utils; namespace Help { namespace Internal { +const char kUserDocumentationKey[] = "Help/UserDocumentation"; +const char kUpdateDocumentationTask[] = "UpdateDocumentationTask"; + struct HelpManagerPrivate { HelpManagerPrivate() = default; @@ -357,8 +358,8 @@ HelpManagerPrivate::~HelpManagerPrivate() const QStringList HelpManagerPrivate::documentationFromInstaller() { - QSettings *installSettings = ICore::settings(); - const QStringList documentationPaths = installSettings->value(QLatin1String("Help/InstalledDocumentation")) + QtcSettings *installSettings = ICore::settings(); + const QStringList documentationPaths = installSettings->value("Help/InstalledDocumentation") .toStringList(); QStringList documentationFiles; for (const QString &path : documentationPaths) { @@ -377,8 +378,7 @@ const QStringList HelpManagerPrivate::documentationFromInstaller() void HelpManagerPrivate::readSettings() { - m_userRegisteredFiles = Utils::toSet(ICore::settings()->value(QLatin1String(kUserDocumentationKey)) - .toStringList()); + m_userRegisteredFiles = Utils::toSet(ICore::settings()->value(kUserDocumentationKey).toStringList()); } void HelpManagerPrivate::writeSettings() diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 0b3ad2f011c..346b2858d22 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -249,7 +249,7 @@ HelpPluginPrivate::HelpPluginPrivate() Core::HelpManager::HelpModeAlways); }); - const QString qdsStandaloneEntry = "QML/Designer/StandAloneMode"; //entry from designer settings + const Key qdsStandaloneEntry = "QML/Designer/StandAloneMode"; //entry from designer settings const bool isDesigner = Core::ICore::settings()->value(qdsStandaloneEntry, false).toBool(); action = new QAction(Tr::tr("Report Bug..."), this); diff --git a/src/plugins/projectexplorer/devicesupport/devicesettingspage.cpp b/src/plugins/projectexplorer/devicesupport/devicesettingspage.cpp index 4e40255b468..9398294912b 100644 --- a/src/plugins/projectexplorer/devicesupport/devicesettingspage.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicesettingspage.cpp @@ -221,8 +221,7 @@ DeviceSettingsWidget::DeviceSettingsWidget() addButton->setEnabled(hasDeviceFactories); - int lastIndex = ICore::settings() - ->value(QLatin1String(LastDeviceIndexKey), 0).toInt(); + int lastIndex = ICore::settings()->value(LastDeviceIndexKey, 0).toInt(); if (lastIndex == -1) lastIndex = 0; if (lastIndex < m_configurationComboBox->count()) diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp index e3a522a3e40..52f3b2bc59a 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp @@ -76,6 +76,11 @@ static void warnAboutUnsupportedKeys(const QVariantMap &map, const QString &name } } +static Key fullSettingsKey(const QString &fieldKey) +{ + return "Wizards/" + keyFromString(fieldKey); +} + // -------------------------------------------------------------------- // Helper: @@ -1413,9 +1418,4 @@ JsonFieldPage::Field *JsonFieldPage::createFieldData(const QString &type) return nullptr; } -QString JsonFieldPage::fullSettingsKey(const QString &fieldKey) -{ - return "Wizards/" + fieldKey; -} - } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h index 69ba2a50fe5..578d16c711e 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h @@ -126,7 +126,6 @@ private: static QHash m_factories; static Field *createFieldData(const QString &type); - static QString fullSettingsKey(const QString &fieldKey); QFormLayout *m_formLayout; QLabel *m_errorLabel; diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 8a8c835e21d..06df7b90d4b 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -2216,7 +2216,7 @@ void ProjectExplorerPluginPrivate::savePersistentSettings() } QtcSettings *s = ICore::settings(); - s->remove(QLatin1String("ProjectExplorer/RecentProjects/Files")); + s->remove("ProjectExplorer/RecentProjects/Files"); QStringList fileNames; QStringList displayNames; diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index c59761cd169..c3b86ce4206 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -661,7 +661,7 @@ void ProjectTreeWidgetFactory::restoreSettings(QtcSettings *settings, int positi { auto ptw = qobject_cast(widget); Q_ASSERT(ptw); - const QString baseKey = kBaseKey + QString::number(position); + const Key baseKey = kBaseKey + Key::number(position); ptw->setProjectFilter( settings->value(baseKey + kProjectFilterKey, kProjectFilterDefault).toBool()); ptw->setGeneratedFilesFilter( diff --git a/src/plugins/projectexplorer/toolchainmanager.cpp b/src/plugins/projectexplorer/toolchainmanager.cpp index d7f20d6f0f5..a0ae2d1cbe9 100644 --- a/src/plugins/projectexplorer/toolchainmanager.cpp +++ b/src/plugins/projectexplorer/toolchainmanager.cpp @@ -62,7 +62,7 @@ using namespace Internal; const char DETECT_X64_AS_X32_KEY[] = "ProjectExplorer/Toolchains/DetectX64AsX32"; -static QString badToolchainsKey() { return {"BadToolChains"}; } +static Key badToolchainsKey() { return "BadToolChains"; } // -------------------------------------------------------------------------- // ToolChainManager diff --git a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp index 2e1a6baf9bc..fbfa7cee520 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp @@ -29,6 +29,7 @@ using namespace ProjectExplorer; using namespace QtSupport; +using namespace Utils; namespace QmakeProjectManager { namespace Internal { @@ -88,9 +89,9 @@ QString QtWizard::templateDir() bool QtWizard::lowerCaseFiles() { - QString lowerCaseSettingsKey = QLatin1String(CppEditor::Constants::CPPEDITOR_SETTINGSGROUP); - lowerCaseSettingsKey += QLatin1Char('/'); - lowerCaseSettingsKey += QLatin1String(CppEditor::Constants::LOWERCASE_CPPFILES_KEY); + Key lowerCaseSettingsKey = CppEditor::Constants::CPPEDITOR_SETTINGSGROUP; + lowerCaseSettingsKey += '/'; + lowerCaseSettingsKey += CppEditor::Constants::LOWERCASE_CPPFILES_KEY; const bool lowerCaseDefault = CppEditor::Constants::LOWERCASE_CPPFILES_DEFAULT; return Core::ICore::settings()->value(lowerCaseSettingsKey, QVariant(lowerCaseDefault)).toBool(); } diff --git a/src/plugins/qmldesignerbase/studio/studiosettingspage.cpp b/src/plugins/qmldesignerbase/studio/studiosettingspage.cpp index d94efbd666b..d88c4cf409b 100644 --- a/src/plugins/qmldesignerbase/studio/studiosettingspage.cpp +++ b/src/plugins/qmldesignerbase/studio/studiosettingspage.cpp @@ -178,15 +178,15 @@ void StudioSettingsPage::apply() QSettings *s = Core::ICore::settings(); const QString value = m_pathChooserExamples->filePath().toString(); - if (s->value(Paths::exampleDownloadPath.toString(), false).toString() != value) { - s->setValue(Paths::exampleDownloadPath.toString(), value); + if (s->value(Paths::exampleDownloadPath, false).toString() != value) { + s->setValue(Paths::exampleDownloadPath, value); emit examplesDownloadPathChanged(value); } const QString bundlesPath = m_pathChooserBundles->filePath().toString(); - if (s->value(Paths::bundlesDownloadPath.toString()).toString() != bundlesPath) { - s->setValue(Paths::bundlesDownloadPath.toString(), bundlesPath); + if (s->value(Paths::bundlesDownloadPath).toString() != bundlesPath) { + s->setValue(Paths::bundlesDownloadPath, bundlesPath); emit bundlesDownloadPathChanged(bundlesPath); const QString restartText = tr("Changing bundle path will take effect after restart."); diff --git a/src/plugins/qmldesignerbase/utils/designerpaths.cpp b/src/plugins/qmldesignerbase/utils/designerpaths.cpp index 53b4b7ea37e..da4ce8ce082 100644 --- a/src/plugins/qmldesignerbase/utils/designerpaths.cpp +++ b/src/plugins/qmldesignerbase/utils/designerpaths.cpp @@ -30,15 +30,13 @@ Utils::FilePath defaultBundlesPath() QString examplesPathSetting() { - return Core::ICore::settings() - ->value(exampleDownloadPath.toString(), defaultExamplesPath().toString()) + return Core::ICore::settings()->value(exampleDownloadPath, defaultExamplesPath().toString()) .toString(); } QString bundlesPathSetting() { - return Core::ICore::settings() - ->value(bundlesDownloadPath.toString(), defaultBundlesPath().toString()) + return Core::ICore::settings()->value(bundlesDownloadPath, defaultBundlesPath().toString()) .toString(); } diff --git a/src/plugins/qmldesignerbase/utils/designerpaths.h b/src/plugins/qmldesignerbase/utils/designerpaths.h index df53997457f..b038343b25e 100644 --- a/src/plugins/qmldesignerbase/utils/designerpaths.h +++ b/src/plugins/qmldesignerbase/utils/designerpaths.h @@ -9,8 +9,8 @@ namespace QmlDesigner::Paths { -inline constexpr QStringView exampleDownloadPath = u"StudioConfig/ExamplesDownloadPath"; -inline constexpr QStringView bundlesDownloadPath = u"StudioConfig/BundlesDownloadPath"; +constexpr char exampleDownloadPath[] = "StudioConfig/ExamplesDownloadPath"; +constexpr char bundlesDownloadPath[] = "StudioConfig/BundlesDownloadPath"; QMLDESIGNERBASE_EXPORT Utils::FilePath defaultExamplesPath(); QMLDESIGNERBASE_EXPORT Utils::FilePath defaultBundlesPath(); diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 0def03b90b6..bb2f9e0fa00 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -49,13 +49,13 @@ Q_GLOBAL_STATIC_WITH_ARGS(QVersionNumber, minQtVersionForCategories, (6, 5, 1)); void ExampleSetModel::writeCurrentIdToSettings(int currentIndex) const { - QSettings *settings = Core::ICore::settings(); - settings->setValue(QLatin1String(kSelectedExampleSetKey), getId(currentIndex)); + QtcSettings *settings = Core::ICore::settings(); + settings->setValue(kSelectedExampleSetKey, getId(currentIndex)); } int ExampleSetModel::readCurrentIndexFromSettings() const { - QVariant id = Core::ICore::settings()->value(QLatin1String(kSelectedExampleSetKey)); + QVariant id = Core::ICore::settings()->value(kSelectedExampleSetKey); for (int i=0; i < rowCount(); i++) { if (id == getId(i)) return i; diff --git a/src/plugins/scxmleditor/common/colorpicker.cpp b/src/plugins/scxmleditor/common/colorpicker.cpp index 88f4d6d22a7..a367ebbd7d0 100644 --- a/src/plugins/scxmleditor/common/colorpicker.cpp +++ b/src/plugins/scxmleditor/common/colorpicker.cpp @@ -12,7 +12,9 @@ #include #include -using namespace ScxmlEditor::Common; +using namespace Utils; + +namespace ScxmlEditor::Common { const char C_SETTINGS_COLORPICKER_LASTUSEDCOLORS[] = "ScxmlEditor/ColorPickerLastUsedColors_%1"; constexpr int C_BUTTON_COLUMNS_COUNT = 5; @@ -55,15 +57,15 @@ ColorPicker::ColorPicker(const QString &key, QWidget *parent) }.attachTo(this); const QStringList lastColors = Core::ICore::settings()->value( - QString::fromLatin1(C_SETTINGS_COLORPICKER_LASTUSEDCOLORS).arg(m_key), QStringList()).toStringList(); + C_SETTINGS_COLORPICKER_LASTUSEDCOLORS + keyFromString(m_key), QStringList()).toStringList(); for (int i = lastColors.count(); i--;) setLastUsedColor(lastColors[i]); } ColorPicker::~ColorPicker() { - Core::ICore::settings()->setValue(QString::fromLatin1(C_SETTINGS_COLORPICKER_LASTUSEDCOLORS).arg(m_key), - m_lastUsedColorNames); + Core::ICore::settings()->setValue( + C_SETTINGS_COLORPICKER_LASTUSEDCOLORS + keyFromString(m_key), m_lastUsedColorNames); } void ColorPicker::setLastUsedColor(const QString &colorName) @@ -99,3 +101,5 @@ QToolButton *ColorPicker::createButton(const QColor &color) return button; } + +} // ScxmlEditor::Common diff --git a/src/plugins/scxmleditor/common/colorpicker.h b/src/plugins/scxmleditor/common/colorpicker.h index 1576e8a9116..73399068904 100644 --- a/src/plugins/scxmleditor/common/colorpicker.h +++ b/src/plugins/scxmleditor/common/colorpicker.h @@ -10,9 +10,7 @@ class QHBoxLayout; class QToolButton; QT_END_NAMESPACE -namespace ScxmlEditor { - -namespace Common { +namespace ScxmlEditor::Common { class ColorPicker : public QFrame { @@ -37,5 +35,4 @@ private: QHBoxLayout *m_lastUsedColorContainer; }; -} // namespace Common -} // namespace ScxmlEditor +} // namespace ScxmlEditor::Common diff --git a/src/plugins/studiowelcome/examplecheckout.cpp b/src/plugins/studiowelcome/examplecheckout.cpp index 52ad72ce8a8..7b13c59fa88 100644 --- a/src/plugins/studiowelcome/examplecheckout.cpp +++ b/src/plugins/studiowelcome/examplecheckout.cpp @@ -57,7 +57,7 @@ void DataModelDownloader::usageStatisticsDownloadExample(const QString &name) bool DataModelDownloader::downloadEnabled() const { - const QString lastQDSVersionEntry = "QML/Designer/EnableWelcomePageDownload"; + const Key lastQDSVersionEntry = "QML/Designer/EnableWelcomePageDownload"; return Core::ICore::settings()->value(lastQDSVersionEntry, false).toBool(); } diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.cpp b/src/plugins/studiowelcome/studiowelcomeplugin.cpp index a794a2c3fc3..927ad2f3c35 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.cpp +++ b/src/plugins/studiowelcome/studiowelcomeplugin.cpp @@ -516,7 +516,7 @@ void StudioWelcomePlugin::initialize() static bool forceDownLoad() { - const QString lastQDSVersionEntry = "QML/Designer/ForceWelcomePageDownload"; + const Key lastQDSVersionEntry = "QML/Designer/ForceWelcomePageDownload"; return Core::ICore::settings()->value(lastQDSVersionEntry, false).toBool(); } diff --git a/src/plugins/texteditor/findinfiles.cpp b/src/plugins/texteditor/findinfiles.cpp index 8156c10b18c..d780d1b1fbd 100644 --- a/src/plugins/texteditor/findinfiles.cpp +++ b/src/plugins/texteditor/findinfiles.cpp @@ -143,10 +143,10 @@ QWidget *FindInFiles::createConfigWidget() [this] { setSearchDir(m_directory->filePath()); }); connect(this, &BaseFileFind::searchDirChanged, m_directory, &PathChooser::setFilePath); m_directory->setHistoryCompleter(HistoryKey, /*restoreLastItemFromHistory=*/ true); - if (!HistoryCompleter::historyExistsFor(QLatin1String(HistoryKey))) { + if (!HistoryCompleter::historyExistsFor(HistoryKey)) { auto completer = static_cast(m_directory->lineEdit()->completer()); const QStringList legacyHistory = ICore::settings()->value( - QLatin1String("Find/FindInFiles/directories")).toStringList(); + "Find/FindInFiles/directories").toStringList(); for (const QString &dir: legacyHistory) completer->addEntry(dir); } diff --git a/src/shared/help/bookmarkmanager.cpp b/src/shared/help/bookmarkmanager.cpp index 72bd5db3214..2f287f2d310 100644 --- a/src/shared/help/bookmarkmanager.cpp +++ b/src/shared/help/bookmarkmanager.cpp @@ -600,7 +600,7 @@ void BookmarkManager::saveBookmarks() QDataStream stream(&bookmarks, QIODevice::WriteOnly); readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0); - Core::ICore::settings()->setValue(QLatin1String(kBookmarksKey), bookmarks); + Core::ICore::settings()->setValue(kBookmarksKey, bookmarks); } QStringList BookmarkManager::bookmarkFolders() const