1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-28 14:53:58 +00:00

Merge branch 'editor_string_settings' into 'master'

Use settings values to declare string settings (#6876)

See merge request OpenMW/openmw!3695
This commit is contained in:
jvoisin 2023-12-28 14:51:09 +00:00
commit c9d4ca5320
4 changed files with 9 additions and 10 deletions

View File

@ -440,13 +440,12 @@ void CSMPrefs::State::declare()
declareShortcut("script-editor-uncomment", "Uncomment Selection", QKeySequence()); declareShortcut("script-editor-uncomment", "Uncomment Selection", QKeySequence());
declareCategory("Models"); declareCategory("Models");
declareString("baseanim", "base animations", "meshes/base_anim.nif") declareString(mValues->mModels.mBaseanim, "base animations").setTooltip("3rd person base model with textkeys-data");
.setTooltip("3rd person base model with textkeys-data"); declareString(mValues->mModels.mBaseanimkna, "base animations, kna")
declareString("baseanimkna", "base animations, kna", "meshes/base_animkna.nif")
.setTooltip("3rd person beast race base model with textkeys-data"); .setTooltip("3rd person beast race base model with textkeys-data");
declareString("baseanimfemale", "base animations, female", "meshes/base_anim_female.nif") declareString(mValues->mModels.mBaseanimfemale, "base animations, female")
.setTooltip("3rd person female base model with textkeys-data"); .setTooltip("3rd person female base model with textkeys-data");
declareString("wolfskin", "base animations, wolf", "meshes/wolf/skin.nif").setTooltip("3rd person werewolf skin"); declareString(mValues->mModels.mWolfskin, "base animations, wolf").setTooltip("3rd person werewolf skin");
} }
void CSMPrefs::State::declareCategory(const std::string& key) void CSMPrefs::State::declareCategory(const std::string& key)
@ -547,13 +546,13 @@ CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut(
} }
CSMPrefs::StringSetting& CSMPrefs::State::declareString( CSMPrefs::StringSetting& CSMPrefs::State::declareString(
const std::string& key, const QString& label, const std::string& default_) Settings::SettingValue<std::string>& value, const QString& label)
{ {
if (mCurrentCategory == mCategories.end()) if (mCurrentCategory == mCategories.end())
throw std::logic_error("no category for setting"); throw std::logic_error("no category for setting");
CSMPrefs::StringSetting* setting CSMPrefs::StringSetting* setting
= new CSMPrefs::StringSetting(&mCurrentCategory->second, &mMutex, key, label, *mIndex); = new CSMPrefs::StringSetting(&mCurrentCategory->second, &mMutex, value.mName, label, *mIndex);
mCurrentCategory->second.addSetting(setting); mCurrentCategory->second.addSetting(setting);

View File

@ -75,7 +75,7 @@ namespace CSMPrefs
ShortcutSetting& declareShortcut(const std::string& key, const QString& label, const QKeySequence& default_); ShortcutSetting& declareShortcut(const std::string& key, const QString& label, const QKeySequence& default_);
StringSetting& declareString(const std::string& key, const QString& label, const std::string& default_); StringSetting& declareString(Settings::SettingValue<std::string>& value, const QString& label);
ModifierSetting& declareModifier(Settings::SettingValue<std::string>& value, const QString& label); ModifierSetting& declareModifier(Settings::SettingValue<std::string>& value, const QString& label);

View File

@ -12,7 +12,7 @@
#include "state.hpp" #include "state.hpp"
CSMPrefs::StringSetting::StringSetting( CSMPrefs::StringSetting::StringSetting(
Category* parent, QMutex* mutex, const std::string& key, const QString& label, Settings::Index& index) Category* parent, QMutex* mutex, std::string_view key, const QString& label, Settings::Index& index)
: TypedSetting(parent, mutex, key, label, index) : TypedSetting(parent, mutex, key, label, index)
, mWidget(nullptr) , mWidget(nullptr)
{ {

View File

@ -24,7 +24,7 @@ namespace CSMPrefs
public: public:
explicit StringSetting( explicit StringSetting(
Category* parent, QMutex* mutex, const std::string& key, const QString& label, Settings::Index& index); Category* parent, QMutex* mutex, std::string_view key, const QString& label, Settings::Index& index);
StringSetting& setTooltip(const std::string& tooltip); StringSetting& setTooltip(const std::string& tooltip);