forked from qt-creator/qt-creator
Utils: Use Key more widely in QtcSettings
And adapt user code. Change-Id: I6efe4ebe6823de4cc862f304a57e041b02c40eac Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -661,7 +661,7 @@ int main(int argc, char **argv)
|
|||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
QTranslator qtTranslator;
|
QTranslator qtTranslator;
|
||||||
QStringList uiLanguages = QLocale::system().uiLanguages();
|
QStringList uiLanguages = QLocale::system().uiLanguages();
|
||||||
QString overrideLanguage = settings->value(QLatin1String("General/OverrideLanguage")).toString();
|
QString overrideLanguage = settings->value("General/OverrideLanguage").toString();
|
||||||
if (!overrideLanguage.isEmpty())
|
if (!overrideLanguage.isEmpty())
|
||||||
uiLanguages.prepend(overrideLanguage);
|
uiLanguages.prepend(overrideLanguage);
|
||||||
if (!options.uiLanguage.isEmpty())
|
if (!options.uiLanguage.isEmpty())
|
||||||
|
@@ -1018,12 +1018,12 @@ void PluginManagerPrivate::writeSettings()
|
|||||||
void PluginManagerPrivate::readSettings()
|
void PluginManagerPrivate::readSettings()
|
||||||
{
|
{
|
||||||
if (globalSettings) {
|
if (globalSettings) {
|
||||||
defaultDisabledPlugins = globalSettings->value(QLatin1String(C_IGNORED_PLUGINS)).toStringList();
|
defaultDisabledPlugins = globalSettings->value(C_IGNORED_PLUGINS).toStringList();
|
||||||
defaultEnabledPlugins = globalSettings->value(QLatin1String(C_FORCEENABLED_PLUGINS)).toStringList();
|
defaultEnabledPlugins = globalSettings->value(C_FORCEENABLED_PLUGINS).toStringList();
|
||||||
}
|
}
|
||||||
if (settings) {
|
if (settings) {
|
||||||
disabledPlugins = settings->value(QLatin1String(C_IGNORED_PLUGINS)).toStringList();
|
disabledPlugins = settings->value(C_IGNORED_PLUGINS).toStringList();
|
||||||
forceEnabledPlugins = settings->value(QLatin1String(C_FORCEENABLED_PLUGINS)).toStringList();
|
forceEnabledPlugins = settings->value(C_FORCEENABLED_PLUGINS).toStringList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -207,10 +207,10 @@ QString HistoryCompleter::historyItem() const
|
|||||||
return d->list.at(0);
|
return d->list.at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryCompleter::historyExistsFor(const QString &historyKey)
|
bool HistoryCompleter::historyExistsFor(const Key &historyKey)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(theSettings, return false);
|
QTC_ASSERT(theSettings, return false);
|
||||||
const QString fullKey = QLatin1String("CompleterHistory/") + historyKey;
|
const Key fullKey = "CompleterHistory/" + historyKey;
|
||||||
return theSettings->value(fullKey).isValid();
|
return theSettings->value(fullKey).isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ public:
|
|||||||
bool removeHistoryItem(int index);
|
bool removeHistoryItem(int index);
|
||||||
QString historyItem() const;
|
QString historyItem() const;
|
||||||
bool hasHistory() const { return historySize() > 0; }
|
bool hasHistory() const { return historySize() > 0; }
|
||||||
static bool historyExistsFor(const QString &historyKey);
|
static bool historyExistsFor(const Key &historyKey);
|
||||||
void clearHistory();
|
void clearHistory();
|
||||||
void addEntry(const QString &str);
|
void addEntry(const QString &str);
|
||||||
|
|
||||||
|
@@ -16,50 +16,45 @@ class QTCREATOR_UTILS_EXPORT QtcSettings : public QSettings
|
|||||||
public:
|
public:
|
||||||
using QSettings::QSettings;
|
using QSettings::QSettings;
|
||||||
|
|
||||||
template<typename T>
|
QVariant value(const Key &key) const { return QSettings::value(stringFromKey(key)); }
|
||||||
void setValueWithDefault(const Key &key, const T &val, const T &defaultValue);
|
QVariant value(const Key &key, const QVariant &def) const { return QSettings::value(stringFromKey(key), def); }
|
||||||
template<typename T>
|
void setValue(const Key &key, const QVariant &value) { QSettings::setValue(stringFromKey(key), value); }
|
||||||
void setValueWithDefault(const Key &key, const T &val);
|
void remove(const Key &key) { QSettings::remove(stringFromKey(key)); }
|
||||||
|
bool contains(const Key &key) const { return QSettings::contains(stringFromKey(key)); }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void setValueWithDefault(QSettings *settings,
|
void setValueWithDefault(const Key &key, const T &val, const T &defaultValue)
|
||||||
const Key &key,
|
|
||||||
const T &val,
|
|
||||||
const T &defaultValue);
|
|
||||||
template<typename T>
|
|
||||||
static void setValueWithDefault(QSettings *settings, const Key &key, const T &val);
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void QtcSettings::setValueWithDefault(const Key &key, const T &val, const T &defaultValue)
|
|
||||||
{
|
{
|
||||||
setValueWithDefault(this, key, val, defaultValue);
|
setValueWithDefault(this, key, val, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void QtcSettings::setValueWithDefault(const Key &key, const T &val)
|
static void setValueWithDefault(QSettings *settings,
|
||||||
{
|
|
||||||
setValueWithDefault(this, key, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
void QtcSettings::setValueWithDefault(QSettings *settings,
|
|
||||||
const Key &key,
|
const Key &key,
|
||||||
const T &val,
|
const T &val,
|
||||||
const T &defaultValue)
|
const T &defaultValue)
|
||||||
{
|
{
|
||||||
if (val == defaultValue)
|
if (val == defaultValue)
|
||||||
settings->remove(key);
|
settings->remove(stringFromKey(key));
|
||||||
else
|
else
|
||||||
settings->setValue(key, QVariant::fromValue(val));
|
settings->setValue(stringFromKey(key), QVariant::fromValue(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void setValueWithDefault(const Key &key, const T &val)
|
||||||
|
{
|
||||||
|
setValueWithDefault(this, key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void QtcSettings::setValueWithDefault(QSettings *settings, const Key &key, const T &val)
|
static void setValueWithDefault(QSettings *settings, const Key &key, const T &val)
|
||||||
{
|
{
|
||||||
if (val == T())
|
if (val == T())
|
||||||
settings->remove(key);
|
settings->remove(stringFromKey(key));
|
||||||
else
|
else
|
||||||
settings->setValue(key, QVariant::fromValue(val));
|
settings->setValue(stringFromKey(key), QVariant::fromValue(val));
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
@@ -116,4 +116,9 @@ bool isStore(const QVariant &value)
|
|||||||
return typeId == QMetaType::QVariantMap || typeId == qMetaTypeId<Store>();
|
return typeId == QMetaType::QVariantMap || typeId == qMetaTypeId<Store>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Key numberedKey(const Key &key, int number)
|
||||||
|
{
|
||||||
|
return key + Key::number(number);
|
||||||
|
}
|
||||||
|
|
||||||
} // Utils
|
} // Utils
|
||||||
|
@@ -29,6 +29,8 @@ QTCREATOR_UTILS_EXPORT QVariantMap mapFromStore(const Store &store);
|
|||||||
|
|
||||||
QTCREATOR_UTILS_EXPORT bool isStore(const QVariant &value);
|
QTCREATOR_UTILS_EXPORT bool isStore(const QVariant &value);
|
||||||
|
|
||||||
|
QTCREATOR_UTILS_EXPORT Key numberedKey(const Key &key, int number);
|
||||||
|
|
||||||
} // Utils
|
} // Utils
|
||||||
|
|
||||||
#ifdef QTC_USE_STORE
|
#ifdef QTC_USE_STORE
|
||||||
|
@@ -6,8 +6,11 @@
|
|||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ClangFormat {
|
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()
|
ClangFormatSettings &ClangFormatSettings::instance()
|
||||||
{
|
{
|
||||||
@@ -17,43 +20,37 @@ ClangFormatSettings &ClangFormatSettings::instance()
|
|||||||
|
|
||||||
ClangFormatSettings::ClangFormatSettings()
|
ClangFormatSettings::ClangFormatSettings()
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::settings();
|
QtcSettings *settings = Core::ICore::settings();
|
||||||
settings->beginGroup(QLatin1String(Constants::SETTINGS_ID));
|
settings->beginGroup(QLatin1String(Constants::SETTINGS_ID));
|
||||||
m_overrideDefaultFile = settings->value(QLatin1String(Constants::OVERRIDE_FILE_ID), false)
|
m_overrideDefaultFile = settings->value(Constants::OVERRIDE_FILE_ID, false).toBool();
|
||||||
.toBool();
|
m_formatWhileTyping = settings->value(Constants::FORMAT_WHILE_TYPING_ID, false).toBool();
|
||||||
m_formatWhileTyping = settings->value(QLatin1String(Constants::FORMAT_WHILE_TYPING_ID), false)
|
m_formatOnSave = settings->value(Constants::FORMAT_CODE_ON_SAVE_ID, false).toBool();
|
||||||
.toBool();
|
m_fileSizeThreshold = settings->value(Constants::FILE_SIZE_THREDSHOLD, 1024).toInt();
|
||||||
m_formatOnSave = settings->value(QLatin1String(Constants::FORMAT_CODE_ON_SAVE_ID), false)
|
|
||||||
.toBool();
|
|
||||||
m_fileSizeThreshold
|
|
||||||
= settings->value(QLatin1String(Constants::FILE_SIZE_THREDSHOLD), 1024).toInt();
|
|
||||||
|
|
||||||
// Convert old settings to new ones. New settings were added to QtC 8.0
|
// Convert old settings to new ones. New settings were added to QtC 8.0
|
||||||
bool isOldFormattingOn
|
bool isOldFormattingOn = settings->value(FORMAT_CODE_INSTEAD_OF_INDENT_ID, false).toBool();
|
||||||
= settings->value(QLatin1String(FORMAT_CODE_INSTEAD_OF_INDENT_ID), false).toBool();
|
Core::ICore::settings()->remove(FORMAT_CODE_INSTEAD_OF_INDENT_ID);
|
||||||
Core::ICore::settings()->remove(QLatin1String(FORMAT_CODE_INSTEAD_OF_INDENT_ID));
|
|
||||||
|
|
||||||
if (isOldFormattingOn) {
|
if (isOldFormattingOn) {
|
||||||
settings->setValue(QLatin1String(Constants::MODE_ID),
|
settings->setValue(Constants::MODE_ID,
|
||||||
static_cast<int>(ClangFormatSettings::Mode::Formatting));
|
static_cast<int>(ClangFormatSettings::Mode::Formatting));
|
||||||
m_mode = ClangFormatSettings::Mode::Formatting;
|
m_mode = ClangFormatSettings::Mode::Formatting;
|
||||||
} else
|
} else
|
||||||
m_mode = static_cast<ClangFormatSettings::Mode>(
|
m_mode = static_cast<ClangFormatSettings::Mode>(
|
||||||
settings->value(QLatin1String(Constants::MODE_ID), ClangFormatSettings::Mode::Indenting)
|
settings->value(Constants::MODE_ID, ClangFormatSettings::Mode::Indenting).toInt());
|
||||||
.toInt());
|
|
||||||
|
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangFormatSettings::write() const
|
void ClangFormatSettings::write() const
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::settings();
|
QtcSettings *settings = Core::ICore::settings();
|
||||||
settings->beginGroup(QLatin1String(Constants::SETTINGS_ID));
|
settings->beginGroup(QLatin1String(Constants::SETTINGS_ID));
|
||||||
settings->setValue(QLatin1String(Constants::OVERRIDE_FILE_ID), m_overrideDefaultFile);
|
settings->setValue(Constants::OVERRIDE_FILE_ID, m_overrideDefaultFile);
|
||||||
settings->setValue(QLatin1String(Constants::FORMAT_WHILE_TYPING_ID), m_formatWhileTyping);
|
settings->setValue(Constants::FORMAT_WHILE_TYPING_ID, m_formatWhileTyping);
|
||||||
settings->setValue(QLatin1String(Constants::FORMAT_CODE_ON_SAVE_ID), m_formatOnSave);
|
settings->setValue(Constants::FORMAT_CODE_ON_SAVE_ID, m_formatOnSave);
|
||||||
settings->setValue(QLatin1String(Constants::MODE_ID), static_cast<int>(m_mode));
|
settings->setValue(Constants::MODE_ID, static_cast<int>(m_mode));
|
||||||
settings->setValue(QLatin1String(Constants::FILE_SIZE_THREDSHOLD), m_fileSizeThreshold);
|
settings->setValue(Constants::FILE_SIZE_THREDSHOLD, m_fileSizeThreshold);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcsettings.h>
|
#include <utils/qtcsettings.h>
|
||||||
|
|
||||||
#include <QSettings>
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ClassView {
|
namespace ClassView {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -42,32 +42,30 @@ Core::NavigationView NavigationWidgetFactory::createWidget()
|
|||||||
/*!
|
/*!
|
||||||
Returns a settings prefix for \a position.
|
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
|
//! Flat mode settings
|
||||||
|
|
||||||
void NavigationWidgetFactory::saveSettings(Utils::QtcSettings *settings,
|
void NavigationWidgetFactory::saveSettings(QtcSettings *settings, int position, QWidget *widget)
|
||||||
int position,
|
|
||||||
QWidget *widget)
|
|
||||||
{
|
{
|
||||||
auto pw = qobject_cast<NavigationWidget *>(widget);
|
auto pw = qobject_cast<NavigationWidget *>(widget);
|
||||||
QTC_ASSERT(pw, return);
|
QTC_ASSERT(pw, return);
|
||||||
|
|
||||||
// .beginGroup is not used - to prevent simultaneous access
|
// .beginGroup is not used - to prevent simultaneous access
|
||||||
QString settingsGroup = settingsPrefix(position);
|
Key settingsGroup = settingsPrefix(position);
|
||||||
settings->setValue(settingsGroup, pw->flatMode());
|
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<NavigationWidget *>(widget);
|
auto pw = qobject_cast<NavigationWidget *>(widget);
|
||||||
QTC_ASSERT(pw, return);
|
QTC_ASSERT(pw, return);
|
||||||
|
|
||||||
// .beginGroup is not used - to prevent simultaneous access
|
// .beginGroup is not used - to prevent simultaneous access
|
||||||
QString settingsGroup = settingsPrefix(position);
|
Key settingsGroup = settingsPrefix(position);
|
||||||
pw->setFlatMode(settings->value(settingsGroup, false).toBool());
|
pw->setFlatMode(settings->value(settingsGroup, false).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -490,8 +490,8 @@ void ActionManagerPrivate::readUserSettings(Id id, Command *cmd)
|
|||||||
|
|
||||||
void ActionManagerPrivate::saveSettings(Command *cmd)
|
void ActionManagerPrivate::saveSettings(Command *cmd)
|
||||||
{
|
{
|
||||||
const QString id = cmd->id().toString();
|
const Key id = cmd->id().toKey();
|
||||||
const QString settingsKey = QLatin1String(kKeyboardSettingsKeyV2) + '/' + id;
|
const Key settingsKey = kKeyboardSettingsKeyV2 + '/' + id;
|
||||||
const QList<QKeySequence> keys = cmd->keySequences();
|
const QList<QKeySequence> keys = cmd->keySequences();
|
||||||
const QList<QKeySequence> defaultKeys = cmd->defaultKeySequences();
|
const QList<QKeySequence> defaultKeys = cmd->defaultKeySequences();
|
||||||
if (keys != defaultKeys) {
|
if (keys != defaultKeys) {
|
||||||
|
@@ -327,8 +327,8 @@ void NewDialogWidget::showDialog()
|
|||||||
{
|
{
|
||||||
QModelIndex idx;
|
QModelIndex idx;
|
||||||
|
|
||||||
QString lastPlatform = ICore::settings()->value(QLatin1String(LAST_PLATFORM_KEY)).toString();
|
QString lastPlatform = ICore::settings()->value(LAST_PLATFORM_KEY).toString();
|
||||||
QString lastCategory = ICore::settings()->value(QLatin1String(LAST_CATEGORY_KEY)).toString();
|
QString lastCategory = ICore::settings()->value(LAST_CATEGORY_KEY).toString();
|
||||||
|
|
||||||
if (!lastPlatform.isEmpty()) {
|
if (!lastPlatform.isEmpty()) {
|
||||||
int index = m_comboBox->findData(lastPlatform);
|
int index = m_comboBox->findData(lastPlatform);
|
||||||
|
@@ -861,7 +861,7 @@ void FolderNavigationWidgetFactory::restoreSettings(QtcSettings *settings, int p
|
|||||||
{
|
{
|
||||||
auto fnw = qobject_cast<FolderNavigationWidget *>(widget);
|
auto fnw = qobject_cast<FolderNavigationWidget *>(widget);
|
||||||
QTC_ASSERT(fnw, return);
|
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->setHiddenFilesFilter(settings->value(base + kHiddenFilesKey, kHiddenFilesDefault).toBool());
|
||||||
fnw->setAutoSynchronization(settings->value(base + kSyncKey, kAutoSyncDefault).toBool());
|
fnw->setAutoSynchronization(settings->value(base + kSyncKey, kAutoSyncDefault).toBool());
|
||||||
fnw->setShowBreadCrumbs(
|
fnw->setShowBreadCrumbs(
|
||||||
|
@@ -263,7 +263,7 @@ QString GeneralSettingsWidget::language()
|
|||||||
void GeneralSettingsWidget::setLanguage(const QString &locale)
|
void GeneralSettingsWidget::setLanguage(const QString &locale)
|
||||||
{
|
{
|
||||||
QtcSettings *settings = ICore::settings();
|
QtcSettings *settings = ICore::settings();
|
||||||
if (settings->value(QLatin1String("General/OverrideLanguage")).toString() != locale) {
|
if (settings->value("General/OverrideLanguage").toString() != locale) {
|
||||||
RestartDialog dialog(ICore::dialogParent(),
|
RestartDialog dialog(ICore::dialogParent(),
|
||||||
Tr::tr("The language change will take effect after restart."));
|
Tr::tr("The language change will take effect after restart."));
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
|
@@ -1477,12 +1477,12 @@ void DebuggerPluginPrivate::parseCommandLineArguments()
|
|||||||
QTimer::singleShot(0, this, &DebuggerPluginPrivate::runScheduled);
|
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);
|
ICore::settings()->setValue("DebugMode/" + name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QVariant configValue(const QString &name)
|
static QVariant configValue(const Key &name)
|
||||||
{
|
{
|
||||||
return ICore::settings()->value("DebugMode/" + name);
|
return ICore::settings()->value("DebugMode/" + name);
|
||||||
}
|
}
|
||||||
@@ -1658,7 +1658,7 @@ void DebuggerPluginPrivate::reloadDebuggingHelpers()
|
|||||||
|
|
||||||
void DebuggerPluginPrivate::startRemoteCdbSession()
|
void DebuggerPluginPrivate::startRemoteCdbSession()
|
||||||
{
|
{
|
||||||
const QString connectionKey = "CdbRemoteConnection";
|
const Key connectionKey = "CdbRemoteConnection";
|
||||||
Kit *kit = findUniversalCdbKit();
|
Kit *kit = findUniversalCdbKit();
|
||||||
QTC_ASSERT(kit, return);
|
QTC_ASSERT(kit, return);
|
||||||
|
|
||||||
|
@@ -4,12 +4,20 @@
|
|||||||
#include "settingsmanager.h"
|
#include "settingsmanager.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QSettings>
|
using namespace Utils;
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
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)
|
void SettingsManager::beginGroup(const QString &prefix)
|
||||||
{
|
{
|
||||||
@@ -41,10 +49,4 @@ void SettingsManager::remove(const QString &key)
|
|||||||
Core::ICore::settings()->remove(addPrefix(key));
|
Core::ICore::settings()->remove(addPrefix(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SettingsManager::addPrefix(const QString &name) const
|
} // Designer::Internal
|
||||||
{
|
|
||||||
QString result = name;
|
|
||||||
if (Core::ICore::settings()->group().isEmpty())
|
|
||||||
result.prepend("Designer");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
@@ -21,9 +21,6 @@ public:
|
|||||||
void setValue(const QString &key, const QVariant &value) override;
|
void setValue(const QString &key, const QVariant &value) override;
|
||||||
QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const override;
|
QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const override;
|
||||||
void remove(const QString &key) override;
|
void remove(const QString &key) override;
|
||||||
|
|
||||||
private:
|
|
||||||
QString addPrefix(const QString &name) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -29,13 +29,14 @@
|
|||||||
#include <QtHelp/QHelpLink>
|
#include <QtHelp/QHelpLink>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
using namespace Utils;
|
||||||
static const char kUserDocumentationKey[] = "Help/UserDocumentation";
|
|
||||||
static const char kUpdateDocumentationTask[] = "UpdateDocumentationTask";
|
|
||||||
|
|
||||||
namespace Help {
|
namespace Help {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
const char kUserDocumentationKey[] = "Help/UserDocumentation";
|
||||||
|
const char kUpdateDocumentationTask[] = "UpdateDocumentationTask";
|
||||||
|
|
||||||
struct HelpManagerPrivate
|
struct HelpManagerPrivate
|
||||||
{
|
{
|
||||||
HelpManagerPrivate() = default;
|
HelpManagerPrivate() = default;
|
||||||
@@ -357,8 +358,8 @@ HelpManagerPrivate::~HelpManagerPrivate()
|
|||||||
|
|
||||||
const QStringList HelpManagerPrivate::documentationFromInstaller()
|
const QStringList HelpManagerPrivate::documentationFromInstaller()
|
||||||
{
|
{
|
||||||
QSettings *installSettings = ICore::settings();
|
QtcSettings *installSettings = ICore::settings();
|
||||||
const QStringList documentationPaths = installSettings->value(QLatin1String("Help/InstalledDocumentation"))
|
const QStringList documentationPaths = installSettings->value("Help/InstalledDocumentation")
|
||||||
.toStringList();
|
.toStringList();
|
||||||
QStringList documentationFiles;
|
QStringList documentationFiles;
|
||||||
for (const QString &path : documentationPaths) {
|
for (const QString &path : documentationPaths) {
|
||||||
@@ -377,8 +378,7 @@ const QStringList HelpManagerPrivate::documentationFromInstaller()
|
|||||||
|
|
||||||
void HelpManagerPrivate::readSettings()
|
void HelpManagerPrivate::readSettings()
|
||||||
{
|
{
|
||||||
m_userRegisteredFiles = Utils::toSet(ICore::settings()->value(QLatin1String(kUserDocumentationKey))
|
m_userRegisteredFiles = Utils::toSet(ICore::settings()->value(kUserDocumentationKey).toStringList());
|
||||||
.toStringList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpManagerPrivate::writeSettings()
|
void HelpManagerPrivate::writeSettings()
|
||||||
|
@@ -249,7 +249,7 @@ HelpPluginPrivate::HelpPluginPrivate()
|
|||||||
Core::HelpManager::HelpModeAlways);
|
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();
|
const bool isDesigner = Core::ICore::settings()->value(qdsStandaloneEntry, false).toBool();
|
||||||
|
|
||||||
action = new QAction(Tr::tr("Report Bug..."), this);
|
action = new QAction(Tr::tr("Report Bug..."), this);
|
||||||
|
@@ -221,8 +221,7 @@ DeviceSettingsWidget::DeviceSettingsWidget()
|
|||||||
|
|
||||||
addButton->setEnabled(hasDeviceFactories);
|
addButton->setEnabled(hasDeviceFactories);
|
||||||
|
|
||||||
int lastIndex = ICore::settings()
|
int lastIndex = ICore::settings()->value(LastDeviceIndexKey, 0).toInt();
|
||||||
->value(QLatin1String(LastDeviceIndexKey), 0).toInt();
|
|
||||||
if (lastIndex == -1)
|
if (lastIndex == -1)
|
||||||
lastIndex = 0;
|
lastIndex = 0;
|
||||||
if (lastIndex < m_configurationComboBox->count())
|
if (lastIndex < m_configurationComboBox->count())
|
||||||
|
@@ -76,6 +76,11 @@ static void warnAboutUnsupportedKeys(const QVariantMap &map, const QString &name
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Key fullSettingsKey(const QString &fieldKey)
|
||||||
|
{
|
||||||
|
return "Wizards/" + keyFromString(fieldKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// Helper:
|
// Helper:
|
||||||
@@ -1413,9 +1418,4 @@ JsonFieldPage::Field *JsonFieldPage::createFieldData(const QString &type)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString JsonFieldPage::fullSettingsKey(const QString &fieldKey)
|
|
||||||
{
|
|
||||||
return "Wizards/" + fieldKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ProjectExplorer
|
} // namespace ProjectExplorer
|
||||||
|
@@ -126,7 +126,6 @@ private:
|
|||||||
static QHash<QString, FieldFactory> m_factories;
|
static QHash<QString, FieldFactory> m_factories;
|
||||||
|
|
||||||
static Field *createFieldData(const QString &type);
|
static Field *createFieldData(const QString &type);
|
||||||
static QString fullSettingsKey(const QString &fieldKey);
|
|
||||||
|
|
||||||
QFormLayout *m_formLayout;
|
QFormLayout *m_formLayout;
|
||||||
QLabel *m_errorLabel;
|
QLabel *m_errorLabel;
|
||||||
|
@@ -2216,7 +2216,7 @@ void ProjectExplorerPluginPrivate::savePersistentSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QtcSettings *s = ICore::settings();
|
QtcSettings *s = ICore::settings();
|
||||||
s->remove(QLatin1String("ProjectExplorer/RecentProjects/Files"));
|
s->remove("ProjectExplorer/RecentProjects/Files");
|
||||||
|
|
||||||
QStringList fileNames;
|
QStringList fileNames;
|
||||||
QStringList displayNames;
|
QStringList displayNames;
|
||||||
|
@@ -661,7 +661,7 @@ void ProjectTreeWidgetFactory::restoreSettings(QtcSettings *settings, int positi
|
|||||||
{
|
{
|
||||||
auto ptw = qobject_cast<ProjectTreeWidget *>(widget);
|
auto ptw = qobject_cast<ProjectTreeWidget *>(widget);
|
||||||
Q_ASSERT(ptw);
|
Q_ASSERT(ptw);
|
||||||
const QString baseKey = kBaseKey + QString::number(position);
|
const Key baseKey = kBaseKey + Key::number(position);
|
||||||
ptw->setProjectFilter(
|
ptw->setProjectFilter(
|
||||||
settings->value(baseKey + kProjectFilterKey, kProjectFilterDefault).toBool());
|
settings->value(baseKey + kProjectFilterKey, kProjectFilterDefault).toBool());
|
||||||
ptw->setGeneratedFilesFilter(
|
ptw->setGeneratedFilesFilter(
|
||||||
|
@@ -62,7 +62,7 @@ using namespace Internal;
|
|||||||
|
|
||||||
const char DETECT_X64_AS_X32_KEY[] = "ProjectExplorer/Toolchains/DetectX64AsX32";
|
const char DETECT_X64_AS_X32_KEY[] = "ProjectExplorer/Toolchains/DetectX64AsX32";
|
||||||
|
|
||||||
static QString badToolchainsKey() { return {"BadToolChains"}; }
|
static Key badToolchainsKey() { return "BadToolChains"; }
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// ToolChainManager
|
// ToolChainManager
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace QtSupport;
|
using namespace QtSupport;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace QmakeProjectManager {
|
namespace QmakeProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -88,9 +89,9 @@ QString QtWizard::templateDir()
|
|||||||
|
|
||||||
bool QtWizard::lowerCaseFiles()
|
bool QtWizard::lowerCaseFiles()
|
||||||
{
|
{
|
||||||
QString lowerCaseSettingsKey = QLatin1String(CppEditor::Constants::CPPEDITOR_SETTINGSGROUP);
|
Key lowerCaseSettingsKey = CppEditor::Constants::CPPEDITOR_SETTINGSGROUP;
|
||||||
lowerCaseSettingsKey += QLatin1Char('/');
|
lowerCaseSettingsKey += '/';
|
||||||
lowerCaseSettingsKey += QLatin1String(CppEditor::Constants::LOWERCASE_CPPFILES_KEY);
|
lowerCaseSettingsKey += CppEditor::Constants::LOWERCASE_CPPFILES_KEY;
|
||||||
const bool lowerCaseDefault = CppEditor::Constants::LOWERCASE_CPPFILES_DEFAULT;
|
const bool lowerCaseDefault = CppEditor::Constants::LOWERCASE_CPPFILES_DEFAULT;
|
||||||
return Core::ICore::settings()->value(lowerCaseSettingsKey, QVariant(lowerCaseDefault)).toBool();
|
return Core::ICore::settings()->value(lowerCaseSettingsKey, QVariant(lowerCaseDefault)).toBool();
|
||||||
}
|
}
|
||||||
|
@@ -178,15 +178,15 @@ void StudioSettingsPage::apply()
|
|||||||
QSettings *s = Core::ICore::settings();
|
QSettings *s = Core::ICore::settings();
|
||||||
const QString value = m_pathChooserExamples->filePath().toString();
|
const QString value = m_pathChooserExamples->filePath().toString();
|
||||||
|
|
||||||
if (s->value(Paths::exampleDownloadPath.toString(), false).toString() != value) {
|
if (s->value(Paths::exampleDownloadPath, false).toString() != value) {
|
||||||
s->setValue(Paths::exampleDownloadPath.toString(), value);
|
s->setValue(Paths::exampleDownloadPath, value);
|
||||||
emit examplesDownloadPathChanged(value);
|
emit examplesDownloadPathChanged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString bundlesPath = m_pathChooserBundles->filePath().toString();
|
const QString bundlesPath = m_pathChooserBundles->filePath().toString();
|
||||||
|
|
||||||
if (s->value(Paths::bundlesDownloadPath.toString()).toString() != bundlesPath) {
|
if (s->value(Paths::bundlesDownloadPath).toString() != bundlesPath) {
|
||||||
s->setValue(Paths::bundlesDownloadPath.toString(), bundlesPath);
|
s->setValue(Paths::bundlesDownloadPath, bundlesPath);
|
||||||
emit bundlesDownloadPathChanged(bundlesPath);
|
emit bundlesDownloadPathChanged(bundlesPath);
|
||||||
|
|
||||||
const QString restartText = tr("Changing bundle path will take effect after restart.");
|
const QString restartText = tr("Changing bundle path will take effect after restart.");
|
||||||
|
@@ -30,15 +30,13 @@ Utils::FilePath defaultBundlesPath()
|
|||||||
|
|
||||||
QString examplesPathSetting()
|
QString examplesPathSetting()
|
||||||
{
|
{
|
||||||
return Core::ICore::settings()
|
return Core::ICore::settings()->value(exampleDownloadPath, defaultExamplesPath().toString())
|
||||||
->value(exampleDownloadPath.toString(), defaultExamplesPath().toString())
|
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString bundlesPathSetting()
|
QString bundlesPathSetting()
|
||||||
{
|
{
|
||||||
return Core::ICore::settings()
|
return Core::ICore::settings()->value(bundlesDownloadPath, defaultBundlesPath().toString())
|
||||||
->value(bundlesDownloadPath.toString(), defaultBundlesPath().toString())
|
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
namespace QmlDesigner::Paths {
|
namespace QmlDesigner::Paths {
|
||||||
|
|
||||||
inline constexpr QStringView exampleDownloadPath = u"StudioConfig/ExamplesDownloadPath";
|
constexpr char exampleDownloadPath[] = "StudioConfig/ExamplesDownloadPath";
|
||||||
inline constexpr QStringView bundlesDownloadPath = u"StudioConfig/BundlesDownloadPath";
|
constexpr char bundlesDownloadPath[] = "StudioConfig/BundlesDownloadPath";
|
||||||
|
|
||||||
QMLDESIGNERBASE_EXPORT Utils::FilePath defaultExamplesPath();
|
QMLDESIGNERBASE_EXPORT Utils::FilePath defaultExamplesPath();
|
||||||
QMLDESIGNERBASE_EXPORT Utils::FilePath defaultBundlesPath();
|
QMLDESIGNERBASE_EXPORT Utils::FilePath defaultBundlesPath();
|
||||||
|
@@ -49,13 +49,13 @@ Q_GLOBAL_STATIC_WITH_ARGS(QVersionNumber, minQtVersionForCategories, (6, 5, 1));
|
|||||||
|
|
||||||
void ExampleSetModel::writeCurrentIdToSettings(int currentIndex) const
|
void ExampleSetModel::writeCurrentIdToSettings(int currentIndex) const
|
||||||
{
|
{
|
||||||
QSettings *settings = Core::ICore::settings();
|
QtcSettings *settings = Core::ICore::settings();
|
||||||
settings->setValue(QLatin1String(kSelectedExampleSetKey), getId(currentIndex));
|
settings->setValue(kSelectedExampleSetKey, getId(currentIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
int ExampleSetModel::readCurrentIndexFromSettings() const
|
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++) {
|
for (int i=0; i < rowCount(); i++) {
|
||||||
if (id == getId(i))
|
if (id == getId(i))
|
||||||
return i;
|
return i;
|
||||||
|
@@ -12,7 +12,9 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
using namespace ScxmlEditor::Common;
|
using namespace Utils;
|
||||||
|
|
||||||
|
namespace ScxmlEditor::Common {
|
||||||
|
|
||||||
const char C_SETTINGS_COLORPICKER_LASTUSEDCOLORS[] = "ScxmlEditor/ColorPickerLastUsedColors_%1";
|
const char C_SETTINGS_COLORPICKER_LASTUSEDCOLORS[] = "ScxmlEditor/ColorPickerLastUsedColors_%1";
|
||||||
constexpr int C_BUTTON_COLUMNS_COUNT = 5;
|
constexpr int C_BUTTON_COLUMNS_COUNT = 5;
|
||||||
@@ -55,15 +57,15 @@ ColorPicker::ColorPicker(const QString &key, QWidget *parent)
|
|||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
const QStringList lastColors = Core::ICore::settings()->value(
|
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--;)
|
for (int i = lastColors.count(); i--;)
|
||||||
setLastUsedColor(lastColors[i]);
|
setLastUsedColor(lastColors[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorPicker::~ColorPicker()
|
ColorPicker::~ColorPicker()
|
||||||
{
|
{
|
||||||
Core::ICore::settings()->setValue(QString::fromLatin1(C_SETTINGS_COLORPICKER_LASTUSEDCOLORS).arg(m_key),
|
Core::ICore::settings()->setValue(
|
||||||
m_lastUsedColorNames);
|
C_SETTINGS_COLORPICKER_LASTUSEDCOLORS + keyFromString(m_key), m_lastUsedColorNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorPicker::setLastUsedColor(const QString &colorName)
|
void ColorPicker::setLastUsedColor(const QString &colorName)
|
||||||
@@ -99,3 +101,5 @@ QToolButton *ColorPicker::createButton(const QColor &color)
|
|||||||
|
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // ScxmlEditor::Common
|
||||||
|
@@ -10,9 +10,7 @@ class QHBoxLayout;
|
|||||||
class QToolButton;
|
class QToolButton;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ScxmlEditor {
|
namespace ScxmlEditor::Common {
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
class ColorPicker : public QFrame
|
class ColorPicker : public QFrame
|
||||||
{
|
{
|
||||||
@@ -37,5 +35,4 @@ private:
|
|||||||
QHBoxLayout *m_lastUsedColorContainer;
|
QHBoxLayout *m_lastUsedColorContainer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Common
|
} // namespace ScxmlEditor::Common
|
||||||
} // namespace ScxmlEditor
|
|
||||||
|
@@ -57,7 +57,7 @@ void DataModelDownloader::usageStatisticsDownloadExample(const QString &name)
|
|||||||
|
|
||||||
bool DataModelDownloader::downloadEnabled() const
|
bool DataModelDownloader::downloadEnabled() const
|
||||||
{
|
{
|
||||||
const QString lastQDSVersionEntry = "QML/Designer/EnableWelcomePageDownload";
|
const Key lastQDSVersionEntry = "QML/Designer/EnableWelcomePageDownload";
|
||||||
return Core::ICore::settings()->value(lastQDSVersionEntry, false).toBool();
|
return Core::ICore::settings()->value(lastQDSVersionEntry, false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -516,7 +516,7 @@ void StudioWelcomePlugin::initialize()
|
|||||||
|
|
||||||
static bool forceDownLoad()
|
static bool forceDownLoad()
|
||||||
{
|
{
|
||||||
const QString lastQDSVersionEntry = "QML/Designer/ForceWelcomePageDownload";
|
const Key lastQDSVersionEntry = "QML/Designer/ForceWelcomePageDownload";
|
||||||
return Core::ICore::settings()->value(lastQDSVersionEntry, false).toBool();
|
return Core::ICore::settings()->value(lastQDSVersionEntry, false).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -143,10 +143,10 @@ QWidget *FindInFiles::createConfigWidget()
|
|||||||
[this] { setSearchDir(m_directory->filePath()); });
|
[this] { setSearchDir(m_directory->filePath()); });
|
||||||
connect(this, &BaseFileFind::searchDirChanged, m_directory, &PathChooser::setFilePath);
|
connect(this, &BaseFileFind::searchDirChanged, m_directory, &PathChooser::setFilePath);
|
||||||
m_directory->setHistoryCompleter(HistoryKey, /*restoreLastItemFromHistory=*/ true);
|
m_directory->setHistoryCompleter(HistoryKey, /*restoreLastItemFromHistory=*/ true);
|
||||||
if (!HistoryCompleter::historyExistsFor(QLatin1String(HistoryKey))) {
|
if (!HistoryCompleter::historyExistsFor(HistoryKey)) {
|
||||||
auto completer = static_cast<HistoryCompleter *>(m_directory->lineEdit()->completer());
|
auto completer = static_cast<HistoryCompleter *>(m_directory->lineEdit()->completer());
|
||||||
const QStringList legacyHistory = ICore::settings()->value(
|
const QStringList legacyHistory = ICore::settings()->value(
|
||||||
QLatin1String("Find/FindInFiles/directories")).toStringList();
|
"Find/FindInFiles/directories").toStringList();
|
||||||
for (const QString &dir: legacyHistory)
|
for (const QString &dir: legacyHistory)
|
||||||
completer->addEntry(dir);
|
completer->addEntry(dir);
|
||||||
}
|
}
|
||||||
|
@@ -600,7 +600,7 @@ void BookmarkManager::saveBookmarks()
|
|||||||
QDataStream stream(&bookmarks, QIODevice::WriteOnly);
|
QDataStream stream(&bookmarks, QIODevice::WriteOnly);
|
||||||
|
|
||||||
readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0);
|
readBookmarksRecursive(treeModel->invisibleRootItem(), stream, 0);
|
||||||
Core::ICore::settings()->setValue(QLatin1String(kBookmarksKey), bookmarks);
|
Core::ICore::settings()->setValue(kBookmarksKey, bookmarks);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList BookmarkManager::bookmarkFolders() const
|
QStringList BookmarkManager::bookmarkFolders() const
|
||||||
|
Reference in New Issue
Block a user