Merge branch 'settings_fix' into 'master'

Refactor usage of settings storage in the launcher and editor

See merge request OpenMW/openmw!2123
LTO-timing^2
psi29a 3 years ago
commit 0eb674ec84

@ -19,6 +19,7 @@
#include <components/config/gamesettings.hpp>
#include <components/config/launchersettings.hpp>
#include <components/settings/settings.hpp>
#include <components/bsa/compressedbsafile.hpp>
#include <components/navmeshtool/protocol.hpp>
#include <components/vfs/bsaarchive.hpp>

@ -423,14 +423,14 @@ bool Launcher::MainDialog::setupGameData()
bool Launcher::MainDialog::setupGraphicsSettings()
{
mEngineSettings.clear(); // Ensure to clear previous settings in case we had already loaded settings.
Settings::Manager::clear(); // Ensure to clear previous settings in case we had already loaded settings.
try
{
boost::program_options::variables_map variables;
boost::program_options::options_description desc;
mCfgMgr.addCommonOptions(desc);
mCfgMgr.readConfiguration(variables, desc, true);
mEngineSettings.load(mCfgMgr);
Settings::Manager::load(mCfgMgr);
return true;
}
catch (std::exception& e)
@ -513,7 +513,7 @@ bool Launcher::MainDialog::writeSettings()
// Graphics settings
const std::string settingsPath = (mCfgMgr.getUserConfigPath() / "settings.cfg").string();
try {
mEngineSettings.saveUser(settingsPath);
Settings::Manager::saveUser(settingsPath);
}
catch (std::exception& e) {
std::string msg = "<br><b>Error writing settings.cfg</b><br><br>" +

@ -10,7 +10,6 @@
#include <components/config/gamesettings.hpp>
#include <components/config/launchersettings.hpp>
#include <components/settings/settings.hpp>
#endif
#include "ui_mainwindow.h"
@ -95,7 +94,6 @@ namespace Launcher
Files::ConfigurationManager mCfgMgr;
Config::GameSettings mGameSettings;
Settings::Manager mEngineSettings;
Config::LauncherSettings mLauncherSettings;
};

@ -12,6 +12,7 @@
#include <components/fallback/validate.hpp>
#include <components/misc/rng.hpp>
#include <components/nifosg/nifloader.hpp>
#include <components/settings/settings.hpp>
#include "model/doc/document.hpp"
#include "model/world/data.hpp"
@ -109,6 +110,7 @@ boost::program_options::variables_map CS::Editor::readConfiguration()
boost::program_options::notify(variables);
mCfgMgr.readConfiguration(variables, desc, false);
Settings::Manager::load(mCfgMgr, true);
setupLogging(mCfgMgr.getLogPath().string(), "OpenMW-CS");
return variables;

@ -8,9 +8,9 @@
#include "category.hpp"
#include "state.hpp"
CSMPrefs::BoolSetting::BoolSetting (Category *parent, Settings::Manager *values,
CSMPrefs::BoolSetting::BoolSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label, bool default_)
: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(nullptr)
: Setting (parent, mutex, key, label), mDefault (default_), mWidget(nullptr)
{}
CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip (const std::string& tooltip)
@ -39,7 +39,7 @@ void CSMPrefs::BoolSetting::updateWidget()
{
if (mWidget)
{
mWidget->setCheckState(getValues().getBool(getKey(), getParent()->getKey())
mWidget->setCheckState(Settings::Manager::getBool(getKey(), getParent()->getKey())
? Qt::Checked
: Qt::Unchecked);
}
@ -49,7 +49,7 @@ void CSMPrefs::BoolSetting::valueChanged (int value)
{
{
QMutexLocker lock (getMutex());
getValues().setBool (getKey(), getParent()->getKey(), value);
Settings::Manager::setBool (getKey(), getParent()->getKey(), value);
}
getParent()->getState()->update (*this);

@ -17,7 +17,7 @@ namespace CSMPrefs
public:
BoolSetting (Category *parent, Settings::Manager *values,
BoolSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label, bool default_);
BoolSetting& setTooltip (const std::string& tooltip);

@ -11,9 +11,9 @@
#include "category.hpp"
#include "state.hpp"
CSMPrefs::ColourSetting::ColourSetting (Category *parent, Settings::Manager *values,
CSMPrefs::ColourSetting::ColourSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label, QColor default_)
: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(nullptr)
: Setting (parent, mutex, key, label), mDefault (default_), mWidget(nullptr)
{}
CSMPrefs::ColourSetting& CSMPrefs::ColourSetting::setTooltip (const std::string& tooltip)
@ -45,7 +45,7 @@ void CSMPrefs::ColourSetting::updateWidget()
if (mWidget)
{
mWidget->setColor(QString::fromStdString
(getValues().getString(getKey(), getParent()->getKey())));
(Settings::Manager::getString(getKey(), getParent()->getKey())));
}
}
@ -54,7 +54,7 @@ void CSMPrefs::ColourSetting::valueChanged()
CSVWidget::ColorEditor& widget = dynamic_cast<CSVWidget::ColorEditor&> (*sender());
{
QMutexLocker lock (getMutex());
getValues().setString (getKey(), getParent()->getKey(), widget.color().name().toUtf8().data());
Settings::Manager::setString (getKey(), getParent()->getKey(), widget.color().name().toUtf8().data());
}
getParent()->getState()->update (*this);

@ -22,7 +22,7 @@ namespace CSMPrefs
public:
ColourSetting (Category *parent, Settings::Manager *values,
ColourSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label,
QColor default_);

@ -12,9 +12,9 @@
#include "category.hpp"
#include "state.hpp"
CSMPrefs::DoubleSetting::DoubleSetting (Category *parent, Settings::Manager *values,
CSMPrefs::DoubleSetting::DoubleSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label, double default_)
: Setting (parent, values, mutex, key, label),
: Setting (parent, mutex, key, label),
mPrecision(2), mMin (0), mMax (std::numeric_limits<double>::max()),
mDefault (default_), mWidget(nullptr)
{}
@ -75,7 +75,7 @@ void CSMPrefs::DoubleSetting::updateWidget()
{
if (mWidget)
{
mWidget->setValue(getValues().getFloat(getKey(), getParent()->getKey()));
mWidget->setValue(Settings::Manager::getFloat(getKey(), getParent()->getKey()));
}
}
@ -83,7 +83,7 @@ void CSMPrefs::DoubleSetting::valueChanged (double value)
{
{
QMutexLocker lock (getMutex());
getValues().setFloat (getKey(), getParent()->getKey(), value);
Settings::Manager::setFloat (getKey(), getParent()->getKey(), value);
}
getParent()->getState()->update (*this);

@ -20,7 +20,7 @@ namespace CSMPrefs
public:
DoubleSetting (Category *parent, Settings::Manager *values,
DoubleSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label,
double default_);

@ -40,9 +40,9 @@ CSMPrefs::EnumValues& CSMPrefs::EnumValues::add (const std::string& value, const
}
CSMPrefs::EnumSetting::EnumSetting (Category *parent, Settings::Manager *values,
CSMPrefs::EnumSetting::EnumSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label, const EnumValue& default_)
: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(nullptr)
: Setting (parent, mutex, key, label), mDefault (default_), mWidget(nullptr)
{}
CSMPrefs::EnumSetting& CSMPrefs::EnumSetting::setTooltip (const std::string& tooltip)
@ -107,7 +107,7 @@ void CSMPrefs::EnumSetting::updateWidget()
if (mWidget)
{
int index = mWidget->findText(QString::fromStdString
(getValues().getString(getKey(), getParent()->getKey())));
(Settings::Manager::getString(getKey(), getParent()->getKey())));
mWidget->setCurrentIndex(index);
}
@ -117,7 +117,7 @@ void CSMPrefs::EnumSetting::valueChanged (int value)
{
{
QMutexLocker lock (getMutex());
getValues().setString (getKey(), getParent()->getKey(), mValues.mValues.at (value).mValue);
Settings::Manager::setString (getKey(), getParent()->getKey(), mValues.mValues.at (value).mValue);
}
getParent()->getState()->update (*this);

@ -41,7 +41,7 @@ namespace CSMPrefs
public:
EnumSetting (Category *parent, Settings::Manager *values,
EnumSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label,
const EnumValue& default_);

@ -12,9 +12,9 @@
#include "category.hpp"
#include "state.hpp"
CSMPrefs::IntSetting::IntSetting (Category *parent, Settings::Manager *values,
CSMPrefs::IntSetting::IntSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label, int default_)
: Setting (parent, values, mutex, key, label), mMin (0), mMax (std::numeric_limits<int>::max()),
: Setting (parent, mutex, key, label), mMin (0), mMax (std::numeric_limits<int>::max()),
mDefault (default_), mWidget(nullptr)
{}
@ -67,7 +67,7 @@ void CSMPrefs::IntSetting::updateWidget()
{
if (mWidget)
{
mWidget->setValue(getValues().getInt(getKey(), getParent()->getKey()));
mWidget->setValue(Settings::Manager::getInt(getKey(), getParent()->getKey()));
}
}
@ -75,7 +75,7 @@ void CSMPrefs::IntSetting::valueChanged (int value)
{
{
QMutexLocker lock (getMutex());
getValues().setInt (getKey(), getParent()->getKey(), value);
Settings::Manager::setInt (getKey(), getParent()->getKey(), value);
}
getParent()->getState()->update (*this);

@ -19,7 +19,7 @@ namespace CSMPrefs
public:
IntSetting (Category *parent, Settings::Manager *values,
IntSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label, int default_);
// defaults to [0, std::numeric_limits<int>::max()]

@ -7,14 +7,16 @@
#include <QPushButton>
#include <QWidget>
#include <components/settings/settings.hpp>
#include "state.hpp"
#include "shortcutmanager.hpp"
namespace CSMPrefs
{
ModifierSetting::ModifierSetting(Category* parent, Settings::Manager* values, QMutex* mutex, const std::string& key,
ModifierSetting::ModifierSetting(Category* parent, QMutex* mutex, const std::string& key,
const std::string& label)
: Setting(parent, values, mutex, key, label)
: Setting(parent, mutex, key, label)
, mButton(nullptr)
, mEditorActive(false)
{
@ -47,7 +49,7 @@ namespace CSMPrefs
{
if (mButton)
{
std::string shortcut = getValues().getString(getKey(), getParent()->getKey());
std::string shortcut = Settings::Manager::getString(getKey(), getParent()->getKey());
int modifier;
State::get().getShortcutManager().convertFromString(shortcut, modifier);
@ -135,7 +137,7 @@ namespace CSMPrefs
{
QMutexLocker lock(getMutex());
getValues().setString(getKey(), getParent()->getKey(), value);
Settings::Manager::setString(getKey(), getParent()->getKey(), value);
}
getParent()->getState()->update(*this);

@ -16,8 +16,7 @@ namespace CSMPrefs
public:
ModifierSetting(Category* parent, Settings::Manager* values, QMutex* mutex, const std::string& key,
const std::string& label);
ModifierSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label);
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;

@ -4,23 +4,19 @@
#include <QColor>
#include <QMutexLocker>
#include <components/settings/settings.hpp>
#include "category.hpp"
#include "state.hpp"
Settings::Manager& CSMPrefs::Setting::getValues()
{
return *mValues;
}
QMutex *CSMPrefs::Setting::getMutex()
{
return mMutex;
}
CSMPrefs::Setting::Setting (Category *parent, Settings::Manager *values, QMutex *mutex,
CSMPrefs::Setting::Setting (Category *parent, QMutex *mutex,
const std::string& key, const std::string& label)
: QObject (parent->getState()), mParent (parent), mValues (values), mMutex (mutex), mKey (key),
mLabel (label)
: QObject (parent->getState()), mParent (parent), mMutex (mutex), mKey (key), mLabel (label)
{}
CSMPrefs::Setting:: ~Setting() {}
@ -52,25 +48,25 @@ const std::string& CSMPrefs::Setting::getLabel() const
int CSMPrefs::Setting::toInt() const
{
QMutexLocker lock (mMutex);
return mValues->getInt (mKey, mParent->getKey());
return Settings::Manager::getInt (mKey, mParent->getKey());
}
double CSMPrefs::Setting::toDouble() const
{
QMutexLocker lock (mMutex);
return mValues->getFloat (mKey, mParent->getKey());
return Settings::Manager::getFloat (mKey, mParent->getKey());
}
std::string CSMPrefs::Setting::toString() const
{
QMutexLocker lock (mMutex);
return mValues->getString (mKey, mParent->getKey());
return Settings::Manager::getString (mKey, mParent->getKey());
}
bool CSMPrefs::Setting::isTrue() const
{
QMutexLocker lock (mMutex);
return mValues->getBool (mKey, mParent->getKey());
return Settings::Manager::getBool (mKey, mParent->getKey());
}
QColor CSMPrefs::Setting::toColor() const

@ -10,11 +10,6 @@ class QWidget;
class QColor;
class QMutex;
namespace Settings
{
class Manager;
}
namespace CSMPrefs
{
class Category;
@ -24,20 +19,17 @@ namespace CSMPrefs
Q_OBJECT
Category *mParent;
Settings::Manager *mValues;
QMutex *mMutex;
std::string mKey;
std::string mLabel;
protected:
Settings::Manager& getValues();
QMutex *getMutex();
public:
Setting (Category *parent, Settings::Manager *values, QMutex *mutex, const std::string& key, const std::string& label);
Setting (Category *parent, QMutex *mutex, const std::string& key, const std::string& label);
virtual ~Setting();

@ -8,14 +8,16 @@
#include <QWidget>
#include <QString>
#include <components/settings/settings.hpp>
#include "state.hpp"
#include "shortcutmanager.hpp"
namespace CSMPrefs
{
ShortcutSetting::ShortcutSetting(Category* parent, Settings::Manager* values, QMutex* mutex, const std::string& key,
ShortcutSetting::ShortcutSetting(Category* parent, QMutex* mutex, const std::string& key,
const std::string& label)
: Setting(parent, values, mutex, key, label)
: Setting(parent, mutex, key, label)
, mButton(nullptr)
, mEditorActive(false)
, mEditorPos(0)
@ -53,7 +55,7 @@ namespace CSMPrefs
{
if (mButton)
{
std::string shortcut = getValues().getString(getKey(), getParent()->getKey());
std::string shortcut = Settings::Manager::getString(getKey(), getParent()->getKey());
QKeySequence sequence;
State::get().getShortcutManager().convertFromString(shortcut, sequence);
@ -179,7 +181,7 @@ namespace CSMPrefs
{
QMutexLocker lock(getMutex());
getValues().setString(getKey(), getParent()->getKey(), value);
Settings::Manager::setString(getKey(), getParent()->getKey(), value);
}
getParent()->getState()->update(*this);

@ -16,7 +16,7 @@ namespace CSMPrefs
public:
ShortcutSetting(Category* parent, Settings::Manager* values, QMutex* mutex, const std::string& key,
ShortcutSetting(Category* parent, QMutex* mutex, const std::string& key,
const std::string& label);
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;

@ -5,6 +5,8 @@
#include <algorithm>
#include <sstream>
#include <components/settings/settings.hpp>
#include "intsetting.hpp"
#include "doublesetting.hpp"
#include "boolsetting.hpp"
@ -14,11 +16,6 @@
CSMPrefs::State *CSMPrefs::State::sThis = nullptr;
void CSMPrefs::State::load()
{
mSettings.load(mConfigurationManager, true);
}
void CSMPrefs::State::declare()
{
declareCategory ("Windows");
@ -448,10 +445,10 @@ CSMPrefs::IntSetting& CSMPrefs::State::declareInt (const std::string& key,
setDefault(key, std::to_string(default_));
default_ = mSettings.getInt (key, mCurrentCategory->second.getKey());
default_ = Settings::Manager::getInt (key, mCurrentCategory->second.getKey());
CSMPrefs::IntSetting *setting =
new CSMPrefs::IntSetting (&mCurrentCategory->second, &mSettings, &mMutex, key, label,
new CSMPrefs::IntSetting (&mCurrentCategory->second, &mMutex, key, label,
default_);
mCurrentCategory->second.addSetting (setting);
@ -469,10 +466,10 @@ CSMPrefs::DoubleSetting& CSMPrefs::State::declareDouble (const std::string& key,
stream << default_;
setDefault(key, stream.str());
default_ = mSettings.getFloat (key, mCurrentCategory->second.getKey());
default_ = Settings::Manager::getFloat (key, mCurrentCategory->second.getKey());
CSMPrefs::DoubleSetting *setting =
new CSMPrefs::DoubleSetting (&mCurrentCategory->second, &mSettings, &mMutex,
new CSMPrefs::DoubleSetting (&mCurrentCategory->second, &mMutex,
key, label, default_);
mCurrentCategory->second.addSetting (setting);
@ -488,10 +485,10 @@ CSMPrefs::BoolSetting& CSMPrefs::State::declareBool (const std::string& key,
setDefault (key, default_ ? "true" : "false");
default_ = mSettings.getBool (key, mCurrentCategory->second.getKey());
default_ = Settings::Manager::getBool (key, mCurrentCategory->second.getKey());
CSMPrefs::BoolSetting *setting =
new CSMPrefs::BoolSetting (&mCurrentCategory->second, &mSettings, &mMutex, key, label,
new CSMPrefs::BoolSetting (&mCurrentCategory->second, &mMutex, key, label,
default_);
mCurrentCategory->second.addSetting (setting);
@ -507,10 +504,10 @@ CSMPrefs::EnumSetting& CSMPrefs::State::declareEnum (const std::string& key,
setDefault (key, default_.mValue);
default_.mValue = mSettings.getString (key, mCurrentCategory->second.getKey());
default_.mValue = Settings::Manager::getString (key, mCurrentCategory->second.getKey());
CSMPrefs::EnumSetting *setting =
new CSMPrefs::EnumSetting (&mCurrentCategory->second, &mSettings, &mMutex, key, label,
new CSMPrefs::EnumSetting (&mCurrentCategory->second, &mMutex, key, label,
default_);
mCurrentCategory->second.addSetting (setting);
@ -526,10 +523,10 @@ CSMPrefs::ColourSetting& CSMPrefs::State::declareColour (const std::string& key,
setDefault (key, default_.name().toUtf8().data());
default_.setNamedColor (QString::fromUtf8 (mSettings.getString (key, mCurrentCategory->second.getKey()).c_str()));
default_.setNamedColor (QString::fromUtf8 (Settings::Manager::getString (key, mCurrentCategory->second.getKey()).c_str()));
CSMPrefs::ColourSetting *setting =
new CSMPrefs::ColourSetting (&mCurrentCategory->second, &mSettings, &mMutex, key, label,
new CSMPrefs::ColourSetting (&mCurrentCategory->second, &mMutex, key, label,
default_);
mCurrentCategory->second.addSetting (setting);
@ -549,10 +546,10 @@ CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut (const std::string&
// Setup with actual data
QKeySequence sequence;
getShortcutManager().convertFromString(mSettings.getString(key, mCurrentCategory->second.getKey()), sequence);
getShortcutManager().convertFromString(Settings::Manager::getString(key, mCurrentCategory->second.getKey()), sequence);
getShortcutManager().setSequence(key, sequence);
CSMPrefs::ShortcutSetting *setting = new CSMPrefs::ShortcutSetting (&mCurrentCategory->second, &mSettings, &mMutex,
CSMPrefs::ShortcutSetting *setting = new CSMPrefs::ShortcutSetting (&mCurrentCategory->second, &mMutex,
key, label);
mCurrentCategory->second.addSetting (setting);
@ -566,10 +563,10 @@ CSMPrefs::StringSetting& CSMPrefs::State::declareString (const std::string& key,
setDefault (key, default_);
default_ = mSettings.getString (key, mCurrentCategory->second.getKey());
default_ = Settings::Manager::getString (key, mCurrentCategory->second.getKey());
CSMPrefs::StringSetting *setting =
new CSMPrefs::StringSetting (&mCurrentCategory->second, &mSettings, &mMutex, key, label,
new CSMPrefs::StringSetting (&mCurrentCategory->second, &mMutex, key, label,
default_);
mCurrentCategory->second.addSetting (setting);
@ -589,10 +586,10 @@ CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(const std::string& k
// Setup with actual data
int modifier;
getShortcutManager().convertFromString(mSettings.getString(key, mCurrentCategory->second.getKey()), modifier);
getShortcutManager().convertFromString(Settings::Manager::getString(key, mCurrentCategory->second.getKey()), modifier);
getShortcutManager().setModifier(key, modifier);
CSMPrefs::ModifierSetting *setting = new CSMPrefs::ModifierSetting (&mCurrentCategory->second, &mSettings, &mMutex,
CSMPrefs::ModifierSetting *setting = new CSMPrefs::ModifierSetting (&mCurrentCategory->second, &mMutex,
key, label);
mCurrentCategory->second.addSetting (setting);
@ -605,7 +602,7 @@ void CSMPrefs::State::declareSeparator()
throw std::logic_error ("no category for setting");
CSMPrefs::Setting *setting =
new CSMPrefs::Setting (&mCurrentCategory->second, &mSettings, &mMutex, "", "");
new CSMPrefs::Setting (&mCurrentCategory->second, &mMutex, "", "");
mCurrentCategory->second.addSetting (setting);
}
@ -616,7 +613,7 @@ void CSMPrefs::State::declareSubcategory(const std::string& label)
throw std::logic_error ("no category for setting");
CSMPrefs::Setting *setting =
new CSMPrefs::Setting (&mCurrentCategory->second, &mSettings, &mMutex, "", label);
new CSMPrefs::Setting (&mCurrentCategory->second, &mMutex, "", label);
mCurrentCategory->second.addSetting (setting);
}
@ -626,10 +623,10 @@ void CSMPrefs::State::setDefault (const std::string& key, const std::string& def
Settings::CategorySetting fullKey (mCurrentCategory->second.getKey(), key);
Settings::CategorySettingValueMap::iterator iter =
mSettings.mDefaultSettings.find (fullKey);
Settings::Manager::mDefaultSettings.find (fullKey);
if (iter==mSettings.mDefaultSettings.end())
mSettings.mDefaultSettings.insert (std::make_pair (fullKey, default_));
if (iter==Settings::Manager::mDefaultSettings.end())
Settings::Manager::mDefaultSettings.insert (std::make_pair (fullKey, default_));
}
CSMPrefs::State::State (const Files::ConfigurationManager& configurationManager)
@ -641,7 +638,6 @@ CSMPrefs::State::State (const Files::ConfigurationManager& configurationManager)
sThis = this;
load();
declare();
}
@ -653,7 +649,7 @@ CSMPrefs::State::~State()
void CSMPrefs::State::save()
{
boost::filesystem::path user = mConfigurationManager.getUserConfigPath() / mConfigFile;
mSettings.saveUser (user.string());
Settings::Manager::saveUser (user.string());
}
CSMPrefs::State::Iterator CSMPrefs::State::begin()
@ -696,16 +692,16 @@ CSMPrefs::State& CSMPrefs::State::get()
void CSMPrefs::State::resetCategory(const std::string& category)
{
for (Settings::CategorySettingValueMap::iterator i = mSettings.mUserSettings.begin();
i != mSettings.mUserSettings.end(); ++i)
for (Settings::CategorySettingValueMap::iterator i = Settings::Manager::mUserSettings.begin();
i != Settings::Manager::mUserSettings.end(); ++i)
{
// if the category matches
if (i->first.first == category)
{
// mark the setting as changed
mSettings.mChangedSettings.insert(std::make_pair(i->first.first, i->first.second));
Settings::Manager::mChangedSettings.insert(std::make_pair(i->first.first, i->first.second));
// reset the value to the default
i->second = mSettings.mDefaultSettings[i->first];
i->second = Settings::Manager::mDefaultSettings[i->first];
}
}

@ -11,8 +11,6 @@
#include <components/files/configurationmanager.hpp>
#endif
#include <components/settings/settings.hpp>
#include "category.hpp"
#include "setting.hpp"
#include "enumsetting.hpp"
@ -51,7 +49,6 @@ namespace CSMPrefs
const std::string mDefaultConfigFile;
const Files::ConfigurationManager& mConfigurationManager;
ShortcutManager mShortcutManager;
Settings::Manager mSettings;
Collection mCategories;
Iterator mCurrentCategory;
QMutex mMutex;
@ -62,8 +59,6 @@ namespace CSMPrefs
private:
void load();
void declare();
void declareCategory (const std::string& key);

@ -9,9 +9,9 @@
#include "category.hpp"
#include "state.hpp"
CSMPrefs::StringSetting::StringSetting (Category *parent, Settings::Manager *values,
CSMPrefs::StringSetting::StringSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label, std::string default_)
: Setting (parent, values, mutex, key, label), mDefault (default_), mWidget(nullptr)
: Setting (parent, mutex, key, label), mDefault (default_), mWidget(nullptr)
{}
CSMPrefs::StringSetting& CSMPrefs::StringSetting::setTooltip (const std::string& tooltip)
@ -39,7 +39,7 @@ void CSMPrefs::StringSetting::updateWidget()
{
if (mWidget)
{
mWidget->setText(QString::fromStdString(getValues().getString(getKey(), getParent()->getKey())));
mWidget->setText(QString::fromStdString(Settings::Manager::getString(getKey(), getParent()->getKey())));
}
}
@ -47,7 +47,7 @@ void CSMPrefs::StringSetting::textChanged (const QString& text)
{
{
QMutexLocker lock (getMutex());
getValues().setString (getKey(), getParent()->getKey(), text.toStdString());
Settings::Manager::setString (getKey(), getParent()->getKey(), text.toStdString());
}
getParent()->getState()->update (*this);

@ -17,7 +17,7 @@ namespace CSMPrefs
public:
StringSetting (Category *parent, Settings::Manager *values,
StringSetting (Category *parent,
QMutex *mutex, const std::string& key, const std::string& label, std::string default_);
StringSetting& setTooltip (const std::string& tooltip);

Loading…
Cancel
Save