Merge branch 'editor_colour_settings' into 'master'

Use settings values to declare colour settings (#6876)

See merge request OpenMW/openmw!3747
This commit is contained in:
Evil Eye 2024-01-08 16:48:18 +00:00
commit 64673ea21f
4 changed files with 21 additions and 19 deletions

View file

@ -14,7 +14,7 @@
#include "state.hpp" #include "state.hpp"
CSMPrefs::ColourSetting::ColourSetting( CSMPrefs::ColourSetting::ColourSetting(
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

@ -6,6 +6,7 @@
#include <QColor> #include <QColor>
#include <string> #include <string>
#include <string_view>
#include <utility> #include <utility>
class QMutex; class QMutex;
@ -30,7 +31,7 @@ namespace CSMPrefs
public: public:
explicit ColourSetting( explicit ColourSetting(
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);
ColourSetting& setTooltip(const std::string& tooltip); ColourSetting& setTooltip(const std::string& tooltip);

View file

@ -126,14 +126,14 @@ void CSMPrefs::State::declare()
.setRange(0, 10000); .setRange(0, 10000);
declareInt(mValues->mScripts.mErrorHeight, "Initial height of the error panel").setRange(100, 10000); declareInt(mValues->mScripts.mErrorHeight, "Initial height of the error panel").setRange(100, 10000);
declareBool(mValues->mScripts.mHighlightOccurrences, "Highlight other occurrences of selected names"); declareBool(mValues->mScripts.mHighlightOccurrences, "Highlight other occurrences of selected names");
declareColour("colour-highlight", "Colour of highlighted occurrences", QColor("lightcyan")); declareColour(mValues->mScripts.mColourHighlight, "Colour of highlighted occurrences");
declareColour("colour-int", "Highlight Colour: Integer Literals", QColor("darkmagenta")); declareColour(mValues->mScripts.mColourInt, "Highlight Colour: Integer Literals");
declareColour("colour-float", "Highlight Colour: Float Literals", QColor("magenta")); declareColour(mValues->mScripts.mColourFloat, "Highlight Colour: Float Literals");
declareColour("colour-name", "Highlight Colour: Names", QColor("grey")); declareColour(mValues->mScripts.mColourName, "Highlight Colour: Names");
declareColour("colour-keyword", "Highlight Colour: Keywords", QColor("red")); declareColour(mValues->mScripts.mColourKeyword, "Highlight Colour: Keywords");
declareColour("colour-special", "Highlight Colour: Special Characters", QColor("darkorange")); declareColour(mValues->mScripts.mColourSpecial, "Highlight Colour: Special Characters");
declareColour("colour-comment", "Highlight Colour: Comments", QColor("green")); declareColour(mValues->mScripts.mColourComment, "Highlight Colour: Comments");
declareColour("colour-id", "Highlight Colour: IDs", QColor("blue")); declareColour(mValues->mScripts.mColourId, "Highlight Colour: IDs");
declareCategory("General Input"); declareCategory("General Input");
declareBool(mValues->mGeneralInput.mCycle, "Cyclic next/previous") declareBool(mValues->mGeneralInput.mCycle, "Cyclic next/previous")
@ -185,18 +185,18 @@ void CSMPrefs::State::declare()
.setRange(10, 10000); .setRange(10, 10000);
declareDouble(mValues->mRendering.mObjectMarkerAlpha, "Object Marker Transparency").setPrecision(2).setRange(0, 1); declareDouble(mValues->mRendering.mObjectMarkerAlpha, "Object Marker Transparency").setPrecision(2).setRange(0, 1);
declareBool(mValues->mRendering.mSceneUseGradient, "Use Gradient Background"); declareBool(mValues->mRendering.mSceneUseGradient, "Use Gradient Background");
declareColour("scene-day-background-colour", "Day Background Colour", QColor(110, 120, 128, 255)); declareColour(mValues->mRendering.mSceneDayBackgroundColour, "Day Background Colour");
declareColour("scene-day-gradient-colour", "Day Gradient Colour", QColor(47, 51, 51, 255)) declareColour(mValues->mRendering.mSceneDayGradientColour, "Day Gradient Colour")
.setTooltip( .setTooltip(
"Sets the gradient color to use in conjunction with the day background color. Ignored if " "Sets the gradient color to use in conjunction with the day background color. Ignored if "
"the gradient option is disabled."); "the gradient option is disabled.");
declareColour("scene-bright-background-colour", "Scene Bright Background Colour", QColor(79, 87, 92, 255)); declareColour(mValues->mRendering.mSceneBrightBackgroundColour, "Scene Bright Background Colour");
declareColour("scene-bright-gradient-colour", "Scene Bright Gradient Colour", QColor(47, 51, 51, 255)) declareColour(mValues->mRendering.mSceneBrightGradientColour, "Scene Bright Gradient Colour")
.setTooltip( .setTooltip(
"Sets the gradient color to use in conjunction with the bright background color. Ignored if " "Sets the gradient color to use in conjunction with the bright background color. Ignored if "
"the gradient option is disabled."); "the gradient option is disabled.");
declareColour("scene-night-background-colour", "Scene Night Background Colour", QColor(64, 77, 79, 255)); declareColour(mValues->mRendering.mSceneNightBackgroundColour, "Scene Night Background Colour");
declareColour("scene-night-gradient-colour", "Scene Night Gradient Colour", QColor(47, 51, 51, 255)) declareColour(mValues->mRendering.mSceneNightGradientColour, "Scene Night Gradient Colour")
.setTooltip( .setTooltip(
"Sets the gradient color to use in conjunction with the night background color. Ignored if " "Sets the gradient color to use in conjunction with the night background color. Ignored if "
"the gradient option is disabled."); "the gradient option is disabled.");
@ -477,13 +477,14 @@ CSMPrefs::EnumSetting& CSMPrefs::State::declareEnum(EnumSettingValue& value, con
return *setting; return *setting;
} }
CSMPrefs::ColourSetting& CSMPrefs::State::declareColour(const std::string& key, const QString& label, QColor default_) CSMPrefs::ColourSetting& CSMPrefs::State::declareColour(
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::ColourSetting* setting CSMPrefs::ColourSetting* setting
= new CSMPrefs::ColourSetting(&mCurrentCategory->second, &mMutex, key, label, *mIndex); = new CSMPrefs::ColourSetting(&mCurrentCategory->second, &mMutex, value.mName, label, *mIndex);
mCurrentCategory->second.addSetting(setting); mCurrentCategory->second.addSetting(setting);

View file

@ -72,7 +72,7 @@ namespace CSMPrefs
EnumSetting& declareEnum(EnumSettingValue& value, const QString& label); EnumSetting& declareEnum(EnumSettingValue& value, const QString& label);
ColourSetting& declareColour(const std::string& key, const QString& label, QColor default_); ColourSetting& declareColour(Settings::SettingValue<std::string>& value, const QString& label);
ShortcutSetting& declareShortcut(const std::string& key, const QString& label, const QKeySequence& default_); ShortcutSetting& declareShortcut(const std::string& key, const QString& label, const QKeySequence& default_);