mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-28 23:09:46 +00:00
Merge branch 'settings_values_editor_1' into 'master'
Define editor settings as typed struct members (#6876) See merge request OpenMW/openmw!3597
This commit is contained in:
commit
7c63522870
27 changed files with 712 additions and 158 deletions
|
@ -116,7 +116,7 @@ opencs_units (view/prefs
|
||||||
|
|
||||||
opencs_units (model/prefs
|
opencs_units (model/prefs
|
||||||
state setting intsetting doublesetting boolsetting enumsetting coloursetting shortcut
|
state setting intsetting doublesetting boolsetting enumsetting coloursetting shortcut
|
||||||
shortcuteventhandler shortcutmanager shortcutsetting modifiersetting stringsetting
|
shortcuteventhandler shortcutmanager shortcutsetting modifiersetting stringsetting subcategory
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (model/prefs
|
opencs_units (model/prefs
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "state.hpp"
|
#include "state.hpp"
|
||||||
|
|
||||||
CSMPrefs::BoolSetting::BoolSetting(
|
CSMPrefs::BoolSetting::BoolSetting(
|
||||||
Category* parent, QMutex* mutex, const std::string& key, const std::string& label, bool default_)
|
Category* parent, QMutex* mutex, const std::string& key, const QString& label, bool default_)
|
||||||
: Setting(parent, mutex, key, label)
|
: Setting(parent, mutex, key, label)
|
||||||
, mDefault(default_)
|
, mDefault(default_)
|
||||||
, mWidget(nullptr)
|
, mWidget(nullptr)
|
||||||
|
@ -24,9 +24,9 @@ CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip(const std::string& tool
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> CSMPrefs::BoolSetting::makeWidgets(QWidget* parent)
|
CSMPrefs::SettingWidgets CSMPrefs::BoolSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
mWidget = new QCheckBox(QString::fromUtf8(getLabel().c_str()), parent);
|
mWidget = new QCheckBox(getLabel(), parent);
|
||||||
mWidget->setCheckState(mDefault ? Qt::Checked : Qt::Unchecked);
|
mWidget->setCheckState(mDefault ? Qt::Checked : Qt::Unchecked);
|
||||||
|
|
||||||
if (!mTooltip.empty())
|
if (!mTooltip.empty())
|
||||||
|
@ -37,7 +37,7 @@ std::pair<QWidget*, QWidget*> CSMPrefs::BoolSetting::makeWidgets(QWidget* parent
|
||||||
|
|
||||||
connect(mWidget, &QCheckBox::stateChanged, this, &BoolSetting::valueChanged);
|
connect(mWidget, &QCheckBox::stateChanged, this, &BoolSetting::valueChanged);
|
||||||
|
|
||||||
return std::make_pair(static_cast<QWidget*>(nullptr), mWidget);
|
return SettingWidgets{ .mLabel = nullptr, .mInput = mWidget, .mLayout = nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::BoolSetting::updateWidget()
|
void CSMPrefs::BoolSetting::updateWidget()
|
||||||
|
|
|
@ -21,12 +21,12 @@ namespace CSMPrefs
|
||||||
QCheckBox* mWidget;
|
QCheckBox* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BoolSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label, bool default_);
|
BoolSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label, bool default_);
|
||||||
|
|
||||||
BoolSetting& setTooltip(const std::string& tooltip);
|
BoolSetting& setTooltip(const std::string& tooltip);
|
||||||
|
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;
|
SettingWidgets makeWidgets(QWidget* parent) override;
|
||||||
|
|
||||||
void updateWidget() override;
|
void updateWidget() override;
|
||||||
|
|
||||||
|
|
|
@ -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 std::string& label, QColor default_)
|
Category* parent, QMutex* mutex, const std::string& key, const QString& label, QColor default_)
|
||||||
: Setting(parent, mutex, key, label)
|
: Setting(parent, mutex, key, label)
|
||||||
, mDefault(std::move(default_))
|
, mDefault(std::move(default_))
|
||||||
, mWidget(nullptr)
|
, mWidget(nullptr)
|
||||||
|
@ -27,9 +27,9 @@ CSMPrefs::ColourSetting& CSMPrefs::ColourSetting::setTooltip(const std::string&
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> CSMPrefs::ColourSetting::makeWidgets(QWidget* parent)
|
CSMPrefs::SettingWidgets CSMPrefs::ColourSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
QLabel* label = new QLabel(QString::fromUtf8(getLabel().c_str()), parent);
|
QLabel* label = new QLabel(getLabel(), parent);
|
||||||
|
|
||||||
mWidget = new CSVWidget::ColorEditor(mDefault, parent);
|
mWidget = new CSVWidget::ColorEditor(mDefault, parent);
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ std::pair<QWidget*, QWidget*> CSMPrefs::ColourSetting::makeWidgets(QWidget* pare
|
||||||
|
|
||||||
connect(mWidget, &CSVWidget::ColorEditor::pickingFinished, this, &ColourSetting::valueChanged);
|
connect(mWidget, &CSVWidget::ColorEditor::pickingFinished, this, &ColourSetting::valueChanged);
|
||||||
|
|
||||||
return std::make_pair(label, mWidget);
|
return SettingWidgets{ .mLabel = label, .mInput = mWidget, .mLayout = nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::ColourSetting::updateWidget()
|
void CSMPrefs::ColourSetting::updateWidget()
|
||||||
|
|
|
@ -29,13 +29,12 @@ namespace CSMPrefs
|
||||||
CSVWidget::ColorEditor* mWidget;
|
CSVWidget::ColorEditor* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ColourSetting(
|
ColourSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label, QColor default_);
|
||||||
Category* parent, QMutex* mutex, const std::string& key, const std::string& label, QColor default_);
|
|
||||||
|
|
||||||
ColourSetting& setTooltip(const std::string& tooltip);
|
ColourSetting& setTooltip(const std::string& tooltip);
|
||||||
|
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;
|
SettingWidgets makeWidgets(QWidget* parent) override;
|
||||||
|
|
||||||
void updateWidget() override;
|
void updateWidget() override;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "state.hpp"
|
#include "state.hpp"
|
||||||
|
|
||||||
CSMPrefs::DoubleSetting::DoubleSetting(
|
CSMPrefs::DoubleSetting::DoubleSetting(
|
||||||
Category* parent, QMutex* mutex, const std::string& key, const std::string& label, double default_)
|
Category* parent, QMutex* mutex, const std::string& key, const QString& label, double default_)
|
||||||
: Setting(parent, mutex, key, label)
|
: Setting(parent, mutex, key, label)
|
||||||
, mPrecision(2)
|
, mPrecision(2)
|
||||||
, mMin(0)
|
, mMin(0)
|
||||||
|
@ -56,9 +56,9 @@ CSMPrefs::DoubleSetting& CSMPrefs::DoubleSetting::setTooltip(const std::string&
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> CSMPrefs::DoubleSetting::makeWidgets(QWidget* parent)
|
CSMPrefs::SettingWidgets CSMPrefs::DoubleSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
QLabel* label = new QLabel(QString::fromUtf8(getLabel().c_str()), parent);
|
QLabel* label = new QLabel(getLabel(), parent);
|
||||||
|
|
||||||
mWidget = new QDoubleSpinBox(parent);
|
mWidget = new QDoubleSpinBox(parent);
|
||||||
mWidget->setDecimals(mPrecision);
|
mWidget->setDecimals(mPrecision);
|
||||||
|
@ -74,7 +74,7 @@ std::pair<QWidget*, QWidget*> CSMPrefs::DoubleSetting::makeWidgets(QWidget* pare
|
||||||
|
|
||||||
connect(mWidget, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &DoubleSetting::valueChanged);
|
connect(mWidget, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &DoubleSetting::valueChanged);
|
||||||
|
|
||||||
return std::make_pair(label, mWidget);
|
return SettingWidgets{ .mLabel = label, .mInput = mWidget, .mLayout = nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::DoubleSetting::updateWidget()
|
void CSMPrefs::DoubleSetting::updateWidget()
|
||||||
|
|
|
@ -21,8 +21,7 @@ namespace CSMPrefs
|
||||||
QDoubleSpinBox* mWidget;
|
QDoubleSpinBox* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DoubleSetting(
|
DoubleSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label, double default_);
|
||||||
Category* parent, QMutex* mutex, const std::string& key, const std::string& label, double default_);
|
|
||||||
|
|
||||||
DoubleSetting& setPrecision(int precision);
|
DoubleSetting& setPrecision(int precision);
|
||||||
|
|
||||||
|
@ -36,7 +35,7 @@ namespace CSMPrefs
|
||||||
DoubleSetting& setTooltip(const std::string& tooltip);
|
DoubleSetting& setTooltip(const std::string& tooltip);
|
||||||
|
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;
|
SettingWidgets makeWidgets(QWidget* parent) override;
|
||||||
|
|
||||||
void updateWidget() override;
|
void updateWidget() override;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ CSMPrefs::EnumValues& CSMPrefs::EnumValues::add(const std::string& value, const
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::EnumSetting::EnumSetting(
|
CSMPrefs::EnumSetting::EnumSetting(
|
||||||
Category* parent, QMutex* mutex, const std::string& key, const std::string& label, const EnumValue& default_)
|
Category* parent, QMutex* mutex, const std::string& key, const QString& label, const EnumValue& default_)
|
||||||
: Setting(parent, mutex, key, label)
|
: Setting(parent, mutex, key, label)
|
||||||
, mDefault(default_)
|
, mDefault(default_)
|
||||||
, mWidget(nullptr)
|
, mWidget(nullptr)
|
||||||
|
@ -76,9 +76,9 @@ CSMPrefs::EnumSetting& CSMPrefs::EnumSetting::addValue(const std::string& value,
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> CSMPrefs::EnumSetting::makeWidgets(QWidget* parent)
|
CSMPrefs::SettingWidgets CSMPrefs::EnumSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
QLabel* label = new QLabel(QString::fromUtf8(getLabel().c_str()), parent);
|
QLabel* label = new QLabel(getLabel(), parent);
|
||||||
|
|
||||||
mWidget = new QComboBox(parent);
|
mWidget = new QComboBox(parent);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ std::pair<QWidget*, QWidget*> CSMPrefs::EnumSetting::makeWidgets(QWidget* parent
|
||||||
|
|
||||||
connect(mWidget, qOverload<int>(&QComboBox::currentIndexChanged), this, &EnumSetting::valueChanged);
|
connect(mWidget, qOverload<int>(&QComboBox::currentIndexChanged), this, &EnumSetting::valueChanged);
|
||||||
|
|
||||||
return std::make_pair(label, mWidget);
|
return SettingWidgets{ .mLabel = label, .mInput = mWidget, .mLayout = nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::EnumSetting::updateWidget()
|
void CSMPrefs::EnumSetting::updateWidget()
|
||||||
|
|
|
@ -44,8 +44,8 @@ namespace CSMPrefs
|
||||||
QComboBox* mWidget;
|
QComboBox* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EnumSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label,
|
EnumSetting(
|
||||||
const EnumValue& default_);
|
Category* parent, QMutex* mutex, const std::string& key, const QString& label, const EnumValue& default_);
|
||||||
|
|
||||||
EnumSetting& setTooltip(const std::string& tooltip);
|
EnumSetting& setTooltip(const std::string& tooltip);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ namespace CSMPrefs
|
||||||
EnumSetting& addValue(const std::string& value, const std::string& tooltip);
|
EnumSetting& addValue(const std::string& value, const std::string& tooltip);
|
||||||
|
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;
|
SettingWidgets makeWidgets(QWidget* parent) override;
|
||||||
|
|
||||||
void updateWidget() override;
|
void updateWidget() override;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "state.hpp"
|
#include "state.hpp"
|
||||||
|
|
||||||
CSMPrefs::IntSetting::IntSetting(
|
CSMPrefs::IntSetting::IntSetting(
|
||||||
Category* parent, QMutex* mutex, const std::string& key, const std::string& label, int default_)
|
Category* parent, QMutex* mutex, const std::string& key, const QString& label, int default_)
|
||||||
: Setting(parent, mutex, key, label)
|
: Setting(parent, mutex, key, label)
|
||||||
, mMin(0)
|
, mMin(0)
|
||||||
, mMax(std::numeric_limits<int>::max())
|
, mMax(std::numeric_limits<int>::max())
|
||||||
|
@ -49,9 +49,9 @@ CSMPrefs::IntSetting& CSMPrefs::IntSetting::setTooltip(const std::string& toolti
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> CSMPrefs::IntSetting::makeWidgets(QWidget* parent)
|
CSMPrefs::SettingWidgets CSMPrefs::IntSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
QLabel* label = new QLabel(QString::fromUtf8(getLabel().c_str()), parent);
|
QLabel* label = new QLabel(getLabel(), parent);
|
||||||
|
|
||||||
mWidget = new QSpinBox(parent);
|
mWidget = new QSpinBox(parent);
|
||||||
mWidget->setRange(mMin, mMax);
|
mWidget->setRange(mMin, mMax);
|
||||||
|
@ -66,7 +66,7 @@ std::pair<QWidget*, QWidget*> CSMPrefs::IntSetting::makeWidgets(QWidget* parent)
|
||||||
|
|
||||||
connect(mWidget, qOverload<int>(&QSpinBox::valueChanged), this, &IntSetting::valueChanged);
|
connect(mWidget, qOverload<int>(&QSpinBox::valueChanged), this, &IntSetting::valueChanged);
|
||||||
|
|
||||||
return std::make_pair(label, mWidget);
|
return SettingWidgets{ .mLabel = label, .mInput = mWidget, .mLayout = nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::IntSetting::updateWidget()
|
void CSMPrefs::IntSetting::updateWidget()
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace CSMPrefs
|
||||||
QSpinBox* mWidget;
|
QSpinBox* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IntSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label, int default_);
|
IntSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label, int default_);
|
||||||
|
|
||||||
// defaults to [0, std::numeric_limits<int>::max()]
|
// defaults to [0, std::numeric_limits<int>::max()]
|
||||||
IntSetting& setRange(int min, int max);
|
IntSetting& setRange(int min, int max);
|
||||||
|
@ -35,7 +35,7 @@ namespace CSMPrefs
|
||||||
IntSetting& setTooltip(const std::string& tooltip);
|
IntSetting& setTooltip(const std::string& tooltip);
|
||||||
|
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;
|
SettingWidgets makeWidgets(QWidget* parent) override;
|
||||||
|
|
||||||
void updateWidget() override;
|
void updateWidget() override;
|
||||||
|
|
||||||
|
|
|
@ -19,21 +19,21 @@ class QWidget;
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
ModifierSetting::ModifierSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label)
|
ModifierSetting::ModifierSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label)
|
||||||
: Setting(parent, mutex, key, label)
|
: Setting(parent, mutex, key, label)
|
||||||
, mButton(nullptr)
|
, mButton(nullptr)
|
||||||
, mEditorActive(false)
|
, mEditorActive(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> ModifierSetting::makeWidgets(QWidget* parent)
|
SettingWidgets ModifierSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
int modifier = 0;
|
int modifier = 0;
|
||||||
State::get().getShortcutManager().getModifier(getKey(), modifier);
|
State::get().getShortcutManager().getModifier(getKey(), modifier);
|
||||||
|
|
||||||
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(modifier).c_str());
|
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(modifier).c_str());
|
||||||
|
|
||||||
QLabel* label = new QLabel(QString::fromUtf8(getLabel().c_str()), parent);
|
QLabel* label = new QLabel(getLabel(), parent);
|
||||||
QPushButton* widget = new QPushButton(text, parent);
|
QPushButton* widget = new QPushButton(text, parent);
|
||||||
|
|
||||||
widget->setCheckable(true);
|
widget->setCheckable(true);
|
||||||
|
@ -46,7 +46,7 @@ namespace CSMPrefs
|
||||||
|
|
||||||
connect(widget, &QPushButton::toggled, this, &ModifierSetting::buttonToggled);
|
connect(widget, &QPushButton::toggled, this, &ModifierSetting::buttonToggled);
|
||||||
|
|
||||||
return std::make_pair(label, widget);
|
return SettingWidgets{ .mLabel = label, .mInput = widget, .mLayout = nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModifierSetting::updateWidget()
|
void ModifierSetting::updateWidget()
|
||||||
|
|
|
@ -20,9 +20,9 @@ namespace CSMPrefs
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ModifierSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label);
|
ModifierSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label);
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;
|
SettingWidgets makeWidgets(QWidget* parent) override;
|
||||||
|
|
||||||
void updateWidget() override;
|
void updateWidget() override;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ QMutex* CSMPrefs::Setting::getMutex()
|
||||||
return mMutex;
|
return mMutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::Setting::Setting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label)
|
CSMPrefs::Setting::Setting(Category* parent, QMutex* mutex, const std::string& key, const QString& label)
|
||||||
: QObject(parent->getState())
|
: QObject(parent->getState())
|
||||||
, mParent(parent)
|
, mParent(parent)
|
||||||
, mMutex(mutex)
|
, mMutex(mutex)
|
||||||
|
@ -23,13 +23,6 @@ CSMPrefs::Setting::Setting(Category* parent, QMutex* mutex, const std::string& k
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> CSMPrefs::Setting::makeWidgets(QWidget* parent)
|
|
||||||
{
|
|
||||||
return std::pair<QWidget*, QWidget*>(0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSMPrefs::Setting::updateWidget() {}
|
|
||||||
|
|
||||||
const CSMPrefs::Category* CSMPrefs::Setting::getParent() const
|
const CSMPrefs::Category* CSMPrefs::Setting::getParent() const
|
||||||
{
|
{
|
||||||
return mParent;
|
return mParent;
|
||||||
|
@ -40,11 +33,6 @@ const std::string& CSMPrefs::Setting::getKey() const
|
||||||
return mKey;
|
return mKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& CSMPrefs::Setting::getLabel() const
|
|
||||||
{
|
|
||||||
return mLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CSMPrefs::Setting::toInt() const
|
int CSMPrefs::Setting::toInt() const
|
||||||
{
|
{
|
||||||
QMutexLocker lock(mMutex);
|
QMutexLocker lock(mMutex);
|
||||||
|
|
|
@ -9,11 +9,20 @@
|
||||||
class QWidget;
|
class QWidget;
|
||||||
class QColor;
|
class QColor;
|
||||||
class QMutex;
|
class QMutex;
|
||||||
|
class QGridLayout;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
class Category;
|
class Category;
|
||||||
|
|
||||||
|
struct SettingWidgets
|
||||||
|
{
|
||||||
|
QLabel* mLabel;
|
||||||
|
QWidget* mInput;
|
||||||
|
QGridLayout* mLayout;
|
||||||
|
};
|
||||||
|
|
||||||
class Setting : public QObject
|
class Setting : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -21,32 +30,28 @@ namespace CSMPrefs
|
||||||
Category* mParent;
|
Category* mParent;
|
||||||
QMutex* mMutex;
|
QMutex* mMutex;
|
||||||
std::string mKey;
|
std::string mKey;
|
||||||
std::string mLabel;
|
QString mLabel;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QMutex* getMutex();
|
QMutex* getMutex();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Setting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label);
|
Setting(Category* parent, QMutex* mutex, const std::string& key, const QString& label);
|
||||||
|
|
||||||
~Setting() override = default;
|
~Setting() override = default;
|
||||||
|
|
||||||
/// Return label, input widget.
|
virtual SettingWidgets makeWidgets(QWidget* parent) = 0;
|
||||||
///
|
|
||||||
/// \note first can be a 0-pointer, which means that the label is part of the input
|
|
||||||
/// widget.
|
|
||||||
virtual std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent);
|
|
||||||
|
|
||||||
/// Updates the widget returned by makeWidgets() to the current setting.
|
/// Updates the widget returned by makeWidgets() to the current setting.
|
||||||
///
|
///
|
||||||
/// \note If make_widgets() has not been called yet then nothing happens.
|
/// \note If make_widgets() has not been called yet then nothing happens.
|
||||||
virtual void updateWidget();
|
virtual void updateWidget() = 0;
|
||||||
|
|
||||||
const Category* getParent() const;
|
const Category* getParent() const;
|
||||||
|
|
||||||
const std::string& getKey() const;
|
const std::string& getKey() const;
|
||||||
|
|
||||||
const std::string& getLabel() const;
|
const QString& getLabel() const { return mLabel; }
|
||||||
|
|
||||||
int toInt() const;
|
int toInt() const;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
ShortcutSetting::ShortcutSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label)
|
ShortcutSetting::ShortcutSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label)
|
||||||
: Setting(parent, mutex, key, label)
|
: Setting(parent, mutex, key, label)
|
||||||
, mButton(nullptr)
|
, mButton(nullptr)
|
||||||
, mEditorActive(false)
|
, mEditorActive(false)
|
||||||
|
@ -30,14 +30,14 @@ namespace CSMPrefs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> ShortcutSetting::makeWidgets(QWidget* parent)
|
SettingWidgets ShortcutSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
QKeySequence sequence;
|
QKeySequence sequence;
|
||||||
State::get().getShortcutManager().getSequence(getKey(), sequence);
|
State::get().getShortcutManager().getSequence(getKey(), sequence);
|
||||||
|
|
||||||
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(sequence).c_str());
|
QString text = QString::fromUtf8(State::get().getShortcutManager().convertToString(sequence).c_str());
|
||||||
|
|
||||||
QLabel* label = new QLabel(QString::fromUtf8(getLabel().c_str()), parent);
|
QLabel* label = new QLabel(getLabel(), parent);
|
||||||
QPushButton* widget = new QPushButton(text, parent);
|
QPushButton* widget = new QPushButton(text, parent);
|
||||||
|
|
||||||
widget->setCheckable(true);
|
widget->setCheckable(true);
|
||||||
|
@ -50,7 +50,7 @@ namespace CSMPrefs
|
||||||
|
|
||||||
connect(widget, &QPushButton::toggled, this, &ShortcutSetting::buttonToggled);
|
connect(widget, &QPushButton::toggled, this, &ShortcutSetting::buttonToggled);
|
||||||
|
|
||||||
return std::make_pair(label, widget);
|
return SettingWidgets{ .mLabel = label, .mInput = widget, .mLayout = nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutSetting::updateWidget()
|
void ShortcutSetting::updateWidget()
|
||||||
|
|
|
@ -22,9 +22,9 @@ namespace CSMPrefs
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ShortcutSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label);
|
ShortcutSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label);
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;
|
SettingWidgets makeWidgets(QWidget* parent) override;
|
||||||
|
|
||||||
void updateWidget() override;
|
void updateWidget() override;
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <apps/opencs/model/prefs/enumsetting.hpp>
|
#include <apps/opencs/model/prefs/enumsetting.hpp>
|
||||||
#include <apps/opencs/model/prefs/setting.hpp>
|
#include <apps/opencs/model/prefs/setting.hpp>
|
||||||
#include <apps/opencs/model/prefs/shortcutmanager.hpp>
|
#include <apps/opencs/model/prefs/shortcutmanager.hpp>
|
||||||
|
#include <apps/opencs/model/prefs/subcategory.hpp>
|
||||||
|
|
||||||
#include <components/settings/categories.hpp>
|
#include <components/settings/categories.hpp>
|
||||||
#include <components/settings/settings.hpp>
|
#include <components/settings/settings.hpp>
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
#include "modifiersetting.hpp"
|
#include "modifiersetting.hpp"
|
||||||
#include "shortcutsetting.hpp"
|
#include "shortcutsetting.hpp"
|
||||||
#include "stringsetting.hpp"
|
#include "stringsetting.hpp"
|
||||||
|
#include "values.hpp"
|
||||||
|
|
||||||
CSMPrefs::State* CSMPrefs::State::sThis = nullptr;
|
CSMPrefs::State* CSMPrefs::State::sThis = nullptr;
|
||||||
|
|
||||||
|
@ -40,7 +42,6 @@ void CSMPrefs::State::declare()
|
||||||
.setTooltip(
|
.setTooltip(
|
||||||
"If a newly open top level window is showing status bars or not. "
|
"If a newly open top level window is showing status bars or not. "
|
||||||
" Note that this does not affect existing windows.");
|
" Note that this does not affect existing windows.");
|
||||||
declareSeparator();
|
|
||||||
declareBool("reuse", "Reuse Subviews", true)
|
declareBool("reuse", "Reuse Subviews", true)
|
||||||
.setTooltip(
|
.setTooltip(
|
||||||
"When a new subview is requested and a matching subview already "
|
"When a new subview is requested and a matching subview already "
|
||||||
|
@ -58,7 +59,6 @@ void CSMPrefs::State::declare()
|
||||||
declareInt("minimum-width", "Minimum subview width", 325)
|
declareInt("minimum-width", "Minimum subview width", 325)
|
||||||
.setTooltip("Minimum width of subviews.")
|
.setTooltip("Minimum width of subviews.")
|
||||||
.setRange(50, 10000);
|
.setRange(50, 10000);
|
||||||
declareSeparator();
|
|
||||||
EnumValue scrollbarOnly("Scrollbar Only",
|
EnumValue scrollbarOnly("Scrollbar Only",
|
||||||
"Simple addition of scrollbars, the view window "
|
"Simple addition of scrollbars, the view window "
|
||||||
"does not grow automatically.");
|
"does not grow automatically.");
|
||||||
|
@ -98,7 +98,6 @@ void CSMPrefs::State::declare()
|
||||||
declareEnum("double-s", "Shift Double Click", editRecord).addValues(doubleClickValues);
|
declareEnum("double-s", "Shift Double Click", editRecord).addValues(doubleClickValues);
|
||||||
declareEnum("double-c", "Control Double Click", view).addValues(doubleClickValues);
|
declareEnum("double-c", "Control Double Click", view).addValues(doubleClickValues);
|
||||||
declareEnum("double-sc", "Shift Control Double Click", editRecordAndClose).addValues(doubleClickValues);
|
declareEnum("double-sc", "Shift Control Double Click", editRecordAndClose).addValues(doubleClickValues);
|
||||||
declareSeparator();
|
|
||||||
EnumValue jumpAndSelect("Jump and Select", "Scroll new record into view and make it the selection");
|
EnumValue jumpAndSelect("Jump and Select", "Scroll new record into view and make it the selection");
|
||||||
declareEnum("jump-to-added", "Action on adding or cloning a record", jumpAndSelect)
|
declareEnum("jump-to-added", "Action on adding or cloning a record", jumpAndSelect)
|
||||||
.addValue(jumpAndSelect)
|
.addValue(jumpAndSelect)
|
||||||
|
@ -161,7 +160,6 @@ void CSMPrefs::State::declare()
|
||||||
declareInt("error-height", "Initial height of the error panel", 100).setRange(100, 10000);
|
declareInt("error-height", "Initial height of the error panel", 100).setRange(100, 10000);
|
||||||
declareBool("highlight-occurrences", "Highlight other occurrences of selected names", true);
|
declareBool("highlight-occurrences", "Highlight other occurrences of selected names", true);
|
||||||
declareColour("colour-highlight", "Colour of highlighted occurrences", QColor("lightcyan"));
|
declareColour("colour-highlight", "Colour of highlighted occurrences", QColor("lightcyan"));
|
||||||
declareSeparator();
|
|
||||||
declareColour("colour-int", "Highlight Colour: Integer Literals", QColor("darkmagenta"));
|
declareColour("colour-int", "Highlight Colour: Integer Literals", QColor("darkmagenta"));
|
||||||
declareColour("colour-float", "Highlight Colour: Float Literals", QColor("magenta"));
|
declareColour("colour-float", "Highlight Colour: Float Literals", QColor("magenta"));
|
||||||
declareColour("colour-name", "Highlight Colour: Names", QColor("grey"));
|
declareColour("colour-name", "Highlight Colour: Names", QColor("grey"));
|
||||||
|
@ -180,14 +178,12 @@ void CSMPrefs::State::declare()
|
||||||
|
|
||||||
declareDouble("navi-wheel-factor", "Camera Zoom Sensitivity", 8).setRange(-100.0, 100.0);
|
declareDouble("navi-wheel-factor", "Camera Zoom Sensitivity", 8).setRange(-100.0, 100.0);
|
||||||
declareDouble("s-navi-sensitivity", "Secondary Camera Movement Sensitivity", 50.0).setRange(-1000.0, 1000.0);
|
declareDouble("s-navi-sensitivity", "Secondary Camera Movement Sensitivity", 50.0).setRange(-1000.0, 1000.0);
|
||||||
declareSeparator();
|
|
||||||
|
|
||||||
declareDouble("p-navi-free-sensitivity", "Free Camera Sensitivity", 1 / 650.).setPrecision(5).setRange(0.0, 1.0);
|
declareDouble("p-navi-free-sensitivity", "Free Camera Sensitivity", 1 / 650.).setPrecision(5).setRange(0.0, 1.0);
|
||||||
declareBool("p-navi-free-invert", "Invert Free Camera Mouse Input", false);
|
declareBool("p-navi-free-invert", "Invert Free Camera Mouse Input", false);
|
||||||
declareDouble("navi-free-lin-speed", "Free Camera Linear Speed", 1000.0).setRange(1.0, 10000.0);
|
declareDouble("navi-free-lin-speed", "Free Camera Linear Speed", 1000.0).setRange(1.0, 10000.0);
|
||||||
declareDouble("navi-free-rot-speed", "Free Camera Rotational Speed", 3.14 / 2).setRange(0.001, 6.28);
|
declareDouble("navi-free-rot-speed", "Free Camera Rotational Speed", 3.14 / 2).setRange(0.001, 6.28);
|
||||||
declareDouble("navi-free-speed-mult", "Free Camera Speed Multiplier (from Modifier)", 8).setRange(0.001, 1000.0);
|
declareDouble("navi-free-speed-mult", "Free Camera Speed Multiplier (from Modifier)", 8).setRange(0.001, 1000.0);
|
||||||
declareSeparator();
|
|
||||||
|
|
||||||
declareDouble("p-navi-orbit-sensitivity", "Orbit Camera Sensitivity", 1 / 650.).setPrecision(5).setRange(0.0, 1.0);
|
declareDouble("p-navi-orbit-sensitivity", "Orbit Camera Sensitivity", 1 / 650.).setPrecision(5).setRange(0.0, 1.0);
|
||||||
declareBool("p-navi-orbit-invert", "Invert Orbit Camera Mouse Input", false);
|
declareBool("p-navi-orbit-invert", "Invert Orbit Camera Mouse Input", false);
|
||||||
|
@ -195,7 +191,6 @@ void CSMPrefs::State::declare()
|
||||||
declareDouble("navi-orbit-speed-mult", "Orbital Camera Speed Multiplier (from Modifier)", 4)
|
declareDouble("navi-orbit-speed-mult", "Orbital Camera Speed Multiplier (from Modifier)", 4)
|
||||||
.setRange(0.001, 1000.0);
|
.setRange(0.001, 1000.0);
|
||||||
declareBool("navi-orbit-const-roll", "Keep camera roll constant for orbital camera", true);
|
declareBool("navi-orbit-const-roll", "Keep camera roll constant for orbital camera", true);
|
||||||
declareSeparator();
|
|
||||||
|
|
||||||
declareBool("context-select", "Context Sensitive Selection", false);
|
declareBool("context-select", "Context Sensitive Selection", false);
|
||||||
declareDouble("drag-factor", "Mouse sensitivity during drag operations", 1.0).setRange(0.001, 100.0);
|
declareDouble("drag-factor", "Mouse sensitivity during drag operations", 1.0).setRange(0.001, 100.0);
|
||||||
|
@ -463,7 +458,7 @@ void CSMPrefs::State::declareCategory(const std::string& key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::IntSetting& CSMPrefs::State::declareInt(const std::string& key, const std::string& label, int default_)
|
CSMPrefs::IntSetting& CSMPrefs::State::declareInt(const std::string& key, const QString& label, int default_)
|
||||||
{
|
{
|
||||||
if (mCurrentCategory == mCategories.end())
|
if (mCurrentCategory == mCategories.end())
|
||||||
throw std::logic_error("no category for setting");
|
throw std::logic_error("no category for setting");
|
||||||
|
@ -479,8 +474,7 @@ CSMPrefs::IntSetting& CSMPrefs::State::declareInt(const std::string& key, const
|
||||||
return *setting;
|
return *setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::DoubleSetting& CSMPrefs::State::declareDouble(
|
CSMPrefs::DoubleSetting& CSMPrefs::State::declareDouble(const std::string& key, const QString& label, double default_)
|
||||||
const std::string& key, const std::string& label, double default_)
|
|
||||||
{
|
{
|
||||||
if (mCurrentCategory == mCategories.end())
|
if (mCurrentCategory == mCategories.end())
|
||||||
throw std::logic_error("no category for setting");
|
throw std::logic_error("no category for setting");
|
||||||
|
@ -499,7 +493,7 @@ CSMPrefs::DoubleSetting& CSMPrefs::State::declareDouble(
|
||||||
return *setting;
|
return *setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::BoolSetting& CSMPrefs::State::declareBool(const std::string& key, const std::string& label, bool default_)
|
CSMPrefs::BoolSetting& CSMPrefs::State::declareBool(const std::string& key, const QString& label, bool default_)
|
||||||
{
|
{
|
||||||
if (mCurrentCategory == mCategories.end())
|
if (mCurrentCategory == mCategories.end())
|
||||||
throw std::logic_error("no category for setting");
|
throw std::logic_error("no category for setting");
|
||||||
|
@ -516,8 +510,7 @@ CSMPrefs::BoolSetting& CSMPrefs::State::declareBool(const std::string& key, cons
|
||||||
return *setting;
|
return *setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::EnumSetting& CSMPrefs::State::declareEnum(
|
CSMPrefs::EnumSetting& CSMPrefs::State::declareEnum(const std::string& key, const QString& label, EnumValue default_)
|
||||||
const std::string& key, const std::string& label, EnumValue default_)
|
|
||||||
{
|
{
|
||||||
if (mCurrentCategory == mCategories.end())
|
if (mCurrentCategory == mCategories.end())
|
||||||
throw std::logic_error("no category for setting");
|
throw std::logic_error("no category for setting");
|
||||||
|
@ -534,8 +527,7 @@ CSMPrefs::EnumSetting& CSMPrefs::State::declareEnum(
|
||||||
return *setting;
|
return *setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::ColourSetting& CSMPrefs::State::declareColour(
|
CSMPrefs::ColourSetting& CSMPrefs::State::declareColour(const std::string& key, const QString& label, QColor default_)
|
||||||
const std::string& key, const std::string& label, QColor default_)
|
|
||||||
{
|
{
|
||||||
if (mCurrentCategory == mCategories.end())
|
if (mCurrentCategory == mCategories.end())
|
||||||
throw std::logic_error("no category for setting");
|
throw std::logic_error("no category for setting");
|
||||||
|
@ -554,7 +546,7 @@ CSMPrefs::ColourSetting& CSMPrefs::State::declareColour(
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut(
|
CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut(
|
||||||
const std::string& key, const std::string& label, const QKeySequence& default_)
|
const std::string& key, const QString& label, const QKeySequence& default_)
|
||||||
{
|
{
|
||||||
if (mCurrentCategory == mCategories.end())
|
if (mCurrentCategory == mCategories.end())
|
||||||
throw std::logic_error("no category for setting");
|
throw std::logic_error("no category for setting");
|
||||||
|
@ -576,7 +568,7 @@ CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut(
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::StringSetting& CSMPrefs::State::declareString(
|
CSMPrefs::StringSetting& CSMPrefs::State::declareString(
|
||||||
const std::string& key, const std::string& label, std::string default_)
|
const std::string& key, const QString& label, std::string default_)
|
||||||
{
|
{
|
||||||
if (mCurrentCategory == mCategories.end())
|
if (mCurrentCategory == mCategories.end())
|
||||||
throw std::logic_error("no category for setting");
|
throw std::logic_error("no category for setting");
|
||||||
|
@ -593,8 +585,7 @@ CSMPrefs::StringSetting& CSMPrefs::State::declareString(
|
||||||
return *setting;
|
return *setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(
|
CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(const std::string& key, const QString& label, int default_)
|
||||||
const std::string& key, const std::string& label, int default_)
|
|
||||||
{
|
{
|
||||||
if (mCurrentCategory == mCategories.end())
|
if (mCurrentCategory == mCategories.end())
|
||||||
throw std::logic_error("no category for setting");
|
throw std::logic_error("no category for setting");
|
||||||
|
@ -615,24 +606,12 @@ CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(
|
||||||
return *setting;
|
return *setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::State::declareSeparator()
|
void CSMPrefs::State::declareSubcategory(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::Setting* setting = new CSMPrefs::Setting(&mCurrentCategory->second, &mMutex, "", "");
|
mCurrentCategory->second.addSetting(new CSMPrefs::Subcategory(&mCurrentCategory->second, &mMutex, label));
|
||||||
|
|
||||||
mCurrentCategory->second.addSetting(setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSMPrefs::State::declareSubcategory(const std::string& label)
|
|
||||||
{
|
|
||||||
if (mCurrentCategory == mCategories.end())
|
|
||||||
throw std::logic_error("no category for setting");
|
|
||||||
|
|
||||||
CSMPrefs::Setting* setting = new CSMPrefs::Setting(&mCurrentCategory->second, &mMutex, "", label);
|
|
||||||
|
|
||||||
mCurrentCategory->second.addSetting(setting);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::State::setDefault(const std::string& key, const std::string& default_)
|
void CSMPrefs::State::setDefault(const std::string& key, const std::string& default_)
|
||||||
|
@ -650,13 +629,18 @@ CSMPrefs::State::State(const Files::ConfigurationManager& configurationManager)
|
||||||
, mDefaultConfigFile("defaults-cs.bin")
|
, mDefaultConfigFile("defaults-cs.bin")
|
||||||
, mConfigurationManager(configurationManager)
|
, mConfigurationManager(configurationManager)
|
||||||
, mCurrentCategory(mCategories.end())
|
, mCurrentCategory(mCategories.end())
|
||||||
|
, mIndex(std::make_unique<Settings::Index>())
|
||||||
{
|
{
|
||||||
if (sThis)
|
if (sThis)
|
||||||
throw std::logic_error("An instance of CSMPRefs::State already exists");
|
throw std::logic_error("An instance of CSMPRefs::State already exists");
|
||||||
|
|
||||||
sThis = this;
|
sThis = this;
|
||||||
|
|
||||||
|
Values values(*mIndex);
|
||||||
|
|
||||||
declare();
|
declare();
|
||||||
|
|
||||||
|
mValues = std::make_unique<Values>(std::move(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMPrefs::State::~State()
|
CSMPrefs::State::~State()
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
|
|
||||||
class QColor;
|
class QColor;
|
||||||
|
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
class Index;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSMPrefs
|
namespace CSMPrefs
|
||||||
{
|
{
|
||||||
class IntSetting;
|
class IntSetting;
|
||||||
|
@ -27,6 +32,7 @@ namespace CSMPrefs
|
||||||
class ModifierSetting;
|
class ModifierSetting;
|
||||||
class Setting;
|
class Setting;
|
||||||
class StringSetting;
|
class StringSetting;
|
||||||
|
struct Values;
|
||||||
|
|
||||||
/// \brief User settings state
|
/// \brief User settings state
|
||||||
///
|
///
|
||||||
|
@ -50,43 +56,41 @@ namespace CSMPrefs
|
||||||
Collection mCategories;
|
Collection mCategories;
|
||||||
Iterator mCurrentCategory;
|
Iterator mCurrentCategory;
|
||||||
QMutex mMutex;
|
QMutex mMutex;
|
||||||
|
std::unique_ptr<Settings::Index> mIndex;
|
||||||
|
std::unique_ptr<Values> mValues;
|
||||||
|
|
||||||
// not implemented
|
|
||||||
State(const State&);
|
|
||||||
State& operator=(const State&);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void declare();
|
void declare();
|
||||||
|
|
||||||
void declareCategory(const std::string& key);
|
void declareCategory(const std::string& key);
|
||||||
|
|
||||||
IntSetting& declareInt(const std::string& key, const std::string& label, int default_);
|
IntSetting& declareInt(const std::string& key, const QString& label, int default_);
|
||||||
DoubleSetting& declareDouble(const std::string& key, const std::string& label, double default_);
|
DoubleSetting& declareDouble(const std::string& key, const QString& label, double default_);
|
||||||
|
|
||||||
BoolSetting& declareBool(const std::string& key, const std::string& label, bool default_);
|
BoolSetting& declareBool(const std::string& key, const QString& label, bool default_);
|
||||||
|
|
||||||
EnumSetting& declareEnum(const std::string& key, const std::string& label, EnumValue default_);
|
EnumSetting& declareEnum(const std::string& key, const QString& label, EnumValue default_);
|
||||||
|
|
||||||
ColourSetting& declareColour(const std::string& key, const std::string& label, QColor default_);
|
ColourSetting& declareColour(const std::string& key, const QString& label, QColor default_);
|
||||||
|
|
||||||
ShortcutSetting& declareShortcut(
|
ShortcutSetting& declareShortcut(const std::string& key, const QString& label, const QKeySequence& default_);
|
||||||
const std::string& key, const std::string& label, const QKeySequence& default_);
|
|
||||||
|
|
||||||
StringSetting& declareString(const std::string& key, const std::string& label, std::string default_);
|
StringSetting& declareString(const std::string& key, const QString& label, std::string default_);
|
||||||
|
|
||||||
ModifierSetting& declareModifier(const std::string& key, const std::string& label, int modifier_);
|
ModifierSetting& declareModifier(const std::string& key, const QString& label, int modifier_);
|
||||||
|
|
||||||
void declareSeparator();
|
void declareSubcategory(const QString& label);
|
||||||
|
|
||||||
void declareSubcategory(const std::string& label);
|
|
||||||
|
|
||||||
void setDefault(const std::string& key, const std::string& default_);
|
void setDefault(const std::string& key, const std::string& default_);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
State(const Files::ConfigurationManager& configurationManager);
|
State(const Files::ConfigurationManager& configurationManager);
|
||||||
|
|
||||||
|
State(const State&) = delete;
|
||||||
|
|
||||||
~State();
|
~State();
|
||||||
|
|
||||||
|
State& operator=(const State&) = delete;
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
Iterator begin();
|
Iterator begin();
|
||||||
|
|
|
@ -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 std::string& label, std::string_view default_)
|
Category* parent, QMutex* mutex, const std::string& key, const QString& label, std::string_view default_)
|
||||||
: Setting(parent, mutex, key, label)
|
: Setting(parent, mutex, key, label)
|
||||||
, mDefault(default_)
|
, mDefault(default_)
|
||||||
, mWidget(nullptr)
|
, mWidget(nullptr)
|
||||||
|
@ -25,7 +25,7 @@ CSMPrefs::StringSetting& CSMPrefs::StringSetting::setTooltip(const std::string&
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<QWidget*, QWidget*> CSMPrefs::StringSetting::makeWidgets(QWidget* parent)
|
CSMPrefs::SettingWidgets CSMPrefs::StringSetting::makeWidgets(QWidget* parent)
|
||||||
{
|
{
|
||||||
mWidget = new QLineEdit(QString::fromUtf8(mDefault.c_str()), parent);
|
mWidget = new QLineEdit(QString::fromUtf8(mDefault.c_str()), parent);
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ std::pair<QWidget*, QWidget*> CSMPrefs::StringSetting::makeWidgets(QWidget* pare
|
||||||
|
|
||||||
connect(mWidget, &QLineEdit::textChanged, this, &StringSetting::textChanged);
|
connect(mWidget, &QLineEdit::textChanged, this, &StringSetting::textChanged);
|
||||||
|
|
||||||
return std::make_pair(static_cast<QWidget*>(nullptr), mWidget);
|
return SettingWidgets{ .mLabel = nullptr, .mInput = mWidget, .mLayout = nullptr };
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMPrefs::StringSetting::updateWidget()
|
void CSMPrefs::StringSetting::updateWidget()
|
||||||
|
|
|
@ -23,13 +23,13 @@ namespace CSMPrefs
|
||||||
QLineEdit* mWidget;
|
QLineEdit* mWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StringSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label,
|
StringSetting(
|
||||||
std::string_view default_);
|
Category* parent, QMutex* mutex, const std::string& key, const QString& label, std::string_view default_);
|
||||||
|
|
||||||
StringSetting& setTooltip(const std::string& tooltip);
|
StringSetting& setTooltip(const std::string& tooltip);
|
||||||
|
|
||||||
/// Return label, input widget.
|
/// Return label, input widget.
|
||||||
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;
|
SettingWidgets makeWidgets(QWidget* parent) override;
|
||||||
|
|
||||||
void updateWidget() override;
|
void updateWidget() override;
|
||||||
|
|
||||||
|
|
21
apps/opencs/model/prefs/subcategory.cpp
Normal file
21
apps/opencs/model/prefs/subcategory.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#include "subcategory.hpp"
|
||||||
|
|
||||||
|
#include <QGridLayout>
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class Category;
|
||||||
|
|
||||||
|
Subcategory::Subcategory(Category* parent, QMutex* mutex, const QString& label)
|
||||||
|
: Setting(parent, mutex, "", label)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingWidgets Subcategory::makeWidgets(QWidget* /*parent*/)
|
||||||
|
{
|
||||||
|
QGridLayout* const layout = new QGridLayout();
|
||||||
|
layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||||
|
|
||||||
|
return SettingWidgets{ .mLabel = nullptr, .mInput = nullptr, .mLayout = layout };
|
||||||
|
}
|
||||||
|
}
|
26
apps/opencs/model/prefs/subcategory.hpp
Normal file
26
apps/opencs/model/prefs/subcategory.hpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#ifndef OPENMW_APPS_OPENCS_MODEL_PREFS_SUBCATEGORY_H
|
||||||
|
#define OPENMW_APPS_OPENCS_MODEL_PREFS_SUBCATEGORY_H
|
||||||
|
|
||||||
|
#include "setting.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
class Category;
|
||||||
|
|
||||||
|
class Subcategory final : public Setting
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Subcategory(Category* parent, QMutex* mutex, const QString& label);
|
||||||
|
|
||||||
|
SettingWidgets makeWidgets(QWidget* parent) override;
|
||||||
|
|
||||||
|
void updateWidget() override {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
532
apps/opencs/model/prefs/values.hpp
Normal file
532
apps/opencs/model/prefs/values.hpp
Normal file
|
@ -0,0 +1,532 @@
|
||||||
|
#ifndef OPENMW_APPS_OPENCS_MODEL_PREFS_VALUES_H
|
||||||
|
#define OPENMW_APPS_OPENCS_MODEL_PREFS_VALUES_H
|
||||||
|
|
||||||
|
#include <components/settings/sanitizer.hpp>
|
||||||
|
#include <components/settings/settingvalue.hpp>
|
||||||
|
|
||||||
|
#include <Qt>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <memory>
|
||||||
|
#include <span>
|
||||||
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
|
|
||||||
|
namespace CSMPrefs
|
||||||
|
{
|
||||||
|
struct EnumValueView
|
||||||
|
{
|
||||||
|
std::string_view mValue;
|
||||||
|
std::string_view mTooltip;
|
||||||
|
};
|
||||||
|
|
||||||
|
class EnumSanitizer final : public Settings::Sanitizer<std::string>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit EnumSanitizer(std::span<const EnumValueView> values)
|
||||||
|
: mValues(values)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string apply(const std::string& value) const override
|
||||||
|
{
|
||||||
|
const auto hasValue = [&](const EnumValueView& v) { return v.mValue == value; };
|
||||||
|
if (std::find_if(mValues.begin(), mValues.end(), hasValue) == mValues.end())
|
||||||
|
{
|
||||||
|
std::ostringstream message;
|
||||||
|
message << "Invalid enum value: " << value;
|
||||||
|
throw std::runtime_error(message.str());
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::span<const EnumValueView> mValues;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline std::unique_ptr<Settings::Sanitizer<std::string>> makeEnumSanitizerString(
|
||||||
|
std::span<const EnumValueView> values)
|
||||||
|
{
|
||||||
|
return std::make_unique<EnumSanitizer>(values);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct WindowsCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "Windows";
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 3> sMainwindowScrollbarValues{
|
||||||
|
EnumValueView{
|
||||||
|
"Scrollbar Only", "Simple addition of scrollbars, the view window does not grow automatically." },
|
||||||
|
EnumValueView{ "Grow Only", "The view window grows as subviews are added. No scrollbars." },
|
||||||
|
EnumValueView{
|
||||||
|
"Grow then Scroll", "The view window grows. The scrollbar appears once it cannot grow any further." },
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings::SettingValue<int> mDefaultWidth{ mIndex, sName, "default-width", 800 };
|
||||||
|
Settings::SettingValue<int> mDefaultHeight{ mIndex, sName, "default-height", 600 };
|
||||||
|
Settings::SettingValue<bool> mShowStatusbar{ mIndex, sName, "show-statusbar", true };
|
||||||
|
Settings::SettingValue<bool> mReuse{ mIndex, sName, "reuse", true };
|
||||||
|
Settings::SettingValue<int> mMaxSubviews{ mIndex, sName, "max-subviews", 256 };
|
||||||
|
Settings::SettingValue<bool> mHideSubview{ mIndex, sName, "hide-subview", false };
|
||||||
|
Settings::SettingValue<int> mMinimumWidth{ mIndex, sName, "minimum-width", 325 };
|
||||||
|
Settings::SettingValue<std::string> mMainwindowScrollbar{ mIndex, sName, "mainwindow-scrollbar",
|
||||||
|
std::string(sMainwindowScrollbarValues[0].mValue), makeEnumSanitizerString(sMainwindowScrollbarValues) };
|
||||||
|
Settings::SettingValue<bool> mGrowLimit{ mIndex, sName, "grow-limit", false };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RecordsCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "Records";
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 3> sRecordValues{
|
||||||
|
EnumValueView{ "Icon and Text", "" },
|
||||||
|
EnumValueView{ "Icon Only", "" },
|
||||||
|
EnumValueView{ "Text Only", "" },
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings::SettingValue<std::string> mStatusFormat{ mIndex, sName, "status-format",
|
||||||
|
std::string(sRecordValues[0].mValue), makeEnumSanitizerString(sRecordValues) };
|
||||||
|
Settings::SettingValue<std::string> mTypeFormat{ mIndex, sName, "type-format",
|
||||||
|
std::string(sRecordValues[0].mValue), makeEnumSanitizerString(sRecordValues) };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IdTablesCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "ID Tables";
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 7> sDoubleClickValues{
|
||||||
|
EnumValueView{ "Edit in Place", "Edit the clicked cell" },
|
||||||
|
EnumValueView{ "Edit Record", "Open a dialogue subview for the clicked record" },
|
||||||
|
EnumValueView{ "View", "Open a scene subview for the clicked record (not available everywhere)" },
|
||||||
|
EnumValueView{ "Revert", "" },
|
||||||
|
EnumValueView{ "Delete", "" },
|
||||||
|
EnumValueView{ "Edit Record and Close", "" },
|
||||||
|
EnumValueView{
|
||||||
|
"View and Close", "Open a scene subview for the clicked record and close the table subview" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 3> sJumpAndSelectValues{
|
||||||
|
EnumValueView{ "Jump and Select", "Scroll new record into view and make it the selection" },
|
||||||
|
EnumValueView{ "Jump Only", "Scroll new record into view" },
|
||||||
|
EnumValueView{ "No Jump", "No special action" },
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings::SettingValue<std::string> mDouble{ mIndex, sName, "double", std::string(sDoubleClickValues[0].mValue),
|
||||||
|
makeEnumSanitizerString(sDoubleClickValues) };
|
||||||
|
Settings::SettingValue<std::string> mDoubleS{ mIndex, sName, "double-s",
|
||||||
|
std::string(sDoubleClickValues[1].mValue), makeEnumSanitizerString(sDoubleClickValues) };
|
||||||
|
Settings::SettingValue<std::string> mDoubleC{ mIndex, sName, "double-c",
|
||||||
|
std::string(sDoubleClickValues[2].mValue), makeEnumSanitizerString(sDoubleClickValues) };
|
||||||
|
Settings::SettingValue<std::string> mDoubleSc{ mIndex, sName, "double-sc",
|
||||||
|
std::string(sDoubleClickValues[5].mValue), makeEnumSanitizerString(sDoubleClickValues) };
|
||||||
|
Settings::SettingValue<std::string> mJumpToAdded{ mIndex, sName, "jump-to-added",
|
||||||
|
std::string(sJumpAndSelectValues[0].mValue), makeEnumSanitizerString(sJumpAndSelectValues) };
|
||||||
|
Settings::SettingValue<bool> mExtendedConfig{ mIndex, sName, "extended-config", false };
|
||||||
|
Settings::SettingValue<bool> mSubviewNewWindow{ mIndex, sName, "subview-new-window", false };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct IdDialoguesCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "ID Dialogues";
|
||||||
|
|
||||||
|
Settings::SettingValue<bool> mToolbar{ mIndex, sName, "toolbar", true };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ReportsCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "Reports";
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 4> sReportValues{
|
||||||
|
EnumValueView{ "None", "" },
|
||||||
|
EnumValueView{ "Edit", "Open a table or dialogue suitable for addressing the listed report" },
|
||||||
|
EnumValueView{ "Remove", "Remove the report from the report table" },
|
||||||
|
EnumValueView{ "Edit And Remove",
|
||||||
|
"Open a table or dialogue suitable for addressing the listed report, then remove the report from the "
|
||||||
|
"report table" },
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings::SettingValue<std::string> mDouble{ mIndex, sName, "double", std::string(sReportValues[1].mValue),
|
||||||
|
makeEnumSanitizerString(sReportValues) };
|
||||||
|
Settings::SettingValue<std::string> mDoubleS{ mIndex, sName, "double-s", std::string(sReportValues[2].mValue),
|
||||||
|
makeEnumSanitizerString(sReportValues) };
|
||||||
|
Settings::SettingValue<std::string> mDoubleC{ mIndex, sName, "double-c", std::string(sReportValues[3].mValue),
|
||||||
|
makeEnumSanitizerString(sReportValues) };
|
||||||
|
Settings::SettingValue<std::string> mDoubleSc{ mIndex, sName, "double-sc", std::string(sReportValues[0].mValue),
|
||||||
|
makeEnumSanitizerString(sReportValues) };
|
||||||
|
Settings::SettingValue<bool> mIgnoreBaseRecords{ mIndex, sName, "ignore-base-records", false };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SearchAndReplaceCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "Search & Replace";
|
||||||
|
|
||||||
|
Settings::SettingValue<int> mCharBefore{ mIndex, sName, "char-before", 10 };
|
||||||
|
Settings::SettingValue<int> mCharAfter{ mIndex, sName, "char-after", 10 };
|
||||||
|
Settings::SettingValue<bool> mAutoDelete{ mIndex, sName, "auto-delete", true };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ScriptsCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "Scripts";
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 3> sWarningValues{
|
||||||
|
EnumValueView{ "Ignore", "Do not report warning" },
|
||||||
|
EnumValueView{ "Normal", "Report warnings as warning" },
|
||||||
|
EnumValueView{ "Strict", "Promote warning to an error" },
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings::SettingValue<bool> mShowLinenum{ mIndex, sName, "show-linenum", true };
|
||||||
|
Settings::SettingValue<bool> mWrapLines{ mIndex, sName, "wrap-lines", false };
|
||||||
|
Settings::SettingValue<bool> mMonoFont{ mIndex, sName, "mono-font", true };
|
||||||
|
Settings::SettingValue<int> mTabWidth{ mIndex, sName, "tab-width", 4 };
|
||||||
|
Settings::SettingValue<std::string> mWarnings{ mIndex, sName, "warnings", std::string(sWarningValues[1].mValue),
|
||||||
|
makeEnumSanitizerString(sWarningValues) };
|
||||||
|
Settings::SettingValue<bool> mToolbar{ mIndex, sName, "toolbar", true };
|
||||||
|
Settings::SettingValue<int> mCompileDelay{ mIndex, sName, "compile-delay", 100 };
|
||||||
|
Settings::SettingValue<int> mErrorHeight{ mIndex, sName, "error-height", 100 };
|
||||||
|
Settings::SettingValue<bool> mHighlightOccurrences{ mIndex, sName, "highlight-occurrences", true };
|
||||||
|
Settings::SettingValue<std::string> mColourHighlight{ mIndex, sName, "colour-highlight", "lightcyan" };
|
||||||
|
Settings::SettingValue<std::string> mColourInt{ mIndex, sName, "colour-int", "darkmagenta" };
|
||||||
|
Settings::SettingValue<std::string> mColourFloat{ mIndex, sName, "colour-float", "magenta" };
|
||||||
|
Settings::SettingValue<std::string> mColourName{ mIndex, sName, "colour-name", "grey" };
|
||||||
|
Settings::SettingValue<std::string> mColourKeyword{ mIndex, sName, "colour-keyword", "red" };
|
||||||
|
Settings::SettingValue<std::string> mColourSpecial{ mIndex, sName, "colour-special", "darkorange" };
|
||||||
|
Settings::SettingValue<std::string> mColourComment{ mIndex, sName, "colour-comment", "green" };
|
||||||
|
Settings::SettingValue<std::string> mColourId{ mIndex, sName, "colour-id", "blue" };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct GeneralInputCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "General Input";
|
||||||
|
|
||||||
|
Settings::SettingValue<bool> mCycle{ mIndex, sName, "cycle", false };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SceneInputCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "3D Scene Input";
|
||||||
|
|
||||||
|
Settings::SettingValue<double> mNaviWheelFactor{ mIndex, sName, "navi-wheel-factor", 8 };
|
||||||
|
Settings::SettingValue<double> mSNaviSensitivity{ mIndex, sName, "s-navi-sensitivity", 50 };
|
||||||
|
Settings::SettingValue<double> mPNaviFreeSensitivity{ mIndex, sName, "p-navi-free-sensitivity", 1 / 650.0 };
|
||||||
|
Settings::SettingValue<bool> mPNaviFreeInvert{ mIndex, sName, "p-navi-free-invert", false };
|
||||||
|
Settings::SettingValue<double> mNaviFreeLinSpeed{ mIndex, sName, "navi-free-lin-speed", 1000 };
|
||||||
|
Settings::SettingValue<double> mNaviFreeRotSpeed{ mIndex, sName, "navi-free-rot-speed", 3.14 / 2 };
|
||||||
|
Settings::SettingValue<double> mNaviFreeSpeedMult{ mIndex, sName, "navi-free-speed-mult", 8 };
|
||||||
|
Settings::SettingValue<double> mPNaviOrbitSensitivity{ mIndex, sName, "p-navi-orbit-sensitivity", 1 / 650.0 };
|
||||||
|
Settings::SettingValue<bool> mPNaviOrbitInvert{ mIndex, sName, "p-navi-orbit-invert", false };
|
||||||
|
Settings::SettingValue<double> mNaviOrbitRotSpeed{ mIndex, sName, "navi-orbit-rot-speed", 3.14 / 4 };
|
||||||
|
Settings::SettingValue<double> mNaviOrbitSpeedMult{ mIndex, sName, "navi-orbit-speed-mult", 4 };
|
||||||
|
Settings::SettingValue<bool> mNaviOrbitConstRoll{ mIndex, sName, "navi-orbit-const-roll", true };
|
||||||
|
Settings::SettingValue<bool> mContextSelect{ mIndex, sName, "context-select", false };
|
||||||
|
Settings::SettingValue<double> mDragFactor{ mIndex, sName, "drag-factor", 1 };
|
||||||
|
Settings::SettingValue<double> mDragWheelFactor{ mIndex, sName, "drag-wheel-factor", 1 };
|
||||||
|
Settings::SettingValue<double> mDragShiftFactor{ mIndex, sName, "drag-shift-factor", 4 };
|
||||||
|
Settings::SettingValue<double> mRotateFactor{ mIndex, sName, "rotate-factor", 0.007 };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RenderingCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "Rendering";
|
||||||
|
|
||||||
|
Settings::SettingValue<int> mFramerateLimit{ mIndex, sName, "framerate-limit", 60 };
|
||||||
|
Settings::SettingValue<int> mCameraFov{ mIndex, sName, "camera-fov", 90 };
|
||||||
|
Settings::SettingValue<bool> mCameraOrtho{ mIndex, sName, "camera-ortho", false };
|
||||||
|
Settings::SettingValue<int> mCameraOrthoSize{ mIndex, sName, "camera-ortho-size", 100 };
|
||||||
|
Settings::SettingValue<double> mObjectMarkerAlpha{ mIndex, sName, "object-marker-alpha", 0.5 };
|
||||||
|
Settings::SettingValue<bool> mSceneUseGradient{ mIndex, sName, "scene-use-gradient", true };
|
||||||
|
Settings::SettingValue<std::string> mSceneDayBackgroundColour{ mIndex, sName, "scene-day-background-colour",
|
||||||
|
"#6e7880" };
|
||||||
|
Settings::SettingValue<std::string> mSceneDayGradientColour{ mIndex, sName, "scene-day-gradient-colour",
|
||||||
|
"#2f3333" };
|
||||||
|
Settings::SettingValue<std::string> mSceneBrightBackgroundColour{ mIndex, sName,
|
||||||
|
"scene-bright-background-colour", "#4f575c" };
|
||||||
|
Settings::SettingValue<std::string> mSceneBrightGradientColour{ mIndex, sName, "scene-bright-gradient-colour",
|
||||||
|
"#2f3333" };
|
||||||
|
Settings::SettingValue<std::string> mSceneNightBackgroundColour{ mIndex, sName, "scene-night-background-colour",
|
||||||
|
"#404d4f" };
|
||||||
|
Settings::SettingValue<std::string> mSceneNightGradientColour{ mIndex, sName, "scene-night-gradient-colour",
|
||||||
|
"#2f3333" };
|
||||||
|
Settings::SettingValue<bool> mSceneDayNightSwitchNodes{ mIndex, sName, "scene-day-night-switch-nodes", true };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TooltipsCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "Tooltips";
|
||||||
|
|
||||||
|
Settings::SettingValue<bool> mScene{ mIndex, sName, "scene", true };
|
||||||
|
Settings::SettingValue<bool> mSceneHideBasic{ mIndex, sName, "scene-hide-basic", false };
|
||||||
|
Settings::SettingValue<int> mSceneDelay{ mIndex, sName, "scene-delay", 500 };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SceneEditingCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "3D Scene Editing";
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 3> sInsertOutsideCellValues{
|
||||||
|
EnumValueView{ "Create cell and insert", "" },
|
||||||
|
EnumValueView{ "Discard", "" },
|
||||||
|
EnumValueView{ "Insert anyway", "" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 3> sInsertOutsideVisibleCellValues{
|
||||||
|
EnumValueView{ "Show cell and insert", "" },
|
||||||
|
EnumValueView{ "Discard", "" },
|
||||||
|
EnumValueView{ "Insert anyway", "" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 2> sLandEditOutsideCellValues{
|
||||||
|
EnumValueView{ "Create cell and land, then edit", "" },
|
||||||
|
EnumValueView{ "Discard", "" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 2> sLandEditOutsideVisibleCellValues{
|
||||||
|
EnumValueView{ "Show cell and edit", "" },
|
||||||
|
EnumValueView{ "Discard", "" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 4> sPrimarySelectAction{
|
||||||
|
EnumValueView{ "Select only", "" },
|
||||||
|
EnumValueView{ "Add to selection", "" },
|
||||||
|
EnumValueView{ "Remove from selection", "" },
|
||||||
|
EnumValueView{ "Invert selection", "" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr std::array<EnumValueView, 4> sSecondarySelectAction{
|
||||||
|
EnumValueView{ "Select only", "" },
|
||||||
|
EnumValueView{ "Add to selection", "" },
|
||||||
|
EnumValueView{ "Remove from selection", "" },
|
||||||
|
EnumValueView{ "Invert selection", "" },
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings::SettingValue<double> mGridsnapMovement{ mIndex, sName, "gridsnap-movement", 16 };
|
||||||
|
Settings::SettingValue<double> mGridsnapRotation{ mIndex, sName, "gridsnap-rotation", 15 };
|
||||||
|
Settings::SettingValue<double> mGridsnapScale{ mIndex, sName, "gridsnap-scale", 0.25 };
|
||||||
|
Settings::SettingValue<int> mDistance{ mIndex, sName, "distance", 50 };
|
||||||
|
Settings::SettingValue<std::string> mOutsideDrop{ mIndex, sName, "outside-drop",
|
||||||
|
std::string(sInsertOutsideCellValues[0].mValue), makeEnumSanitizerString(sInsertOutsideCellValues) };
|
||||||
|
Settings::SettingValue<std::string> mOutsideVisibleDrop{ mIndex, sName, "outside-visible-drop",
|
||||||
|
std::string(sInsertOutsideVisibleCellValues[0].mValue),
|
||||||
|
makeEnumSanitizerString(sInsertOutsideVisibleCellValues) };
|
||||||
|
Settings::SettingValue<std::string> mOutsideLandedit{ mIndex, sName, "outside-landedit",
|
||||||
|
std::string(sLandEditOutsideCellValues[0].mValue), makeEnumSanitizerString(sLandEditOutsideCellValues) };
|
||||||
|
Settings::SettingValue<std::string> mOutsideVisibleLandedit{ mIndex, sName, "outside-visible-landedit",
|
||||||
|
std::string(sLandEditOutsideVisibleCellValues[0].mValue),
|
||||||
|
makeEnumSanitizerString(sLandEditOutsideVisibleCellValues) };
|
||||||
|
Settings::SettingValue<int> mTexturebrushMaximumsize{ mIndex, sName, "texturebrush-maximumsize", 50 };
|
||||||
|
Settings::SettingValue<int> mShapebrushMaximumsize{ mIndex, sName, "shapebrush-maximumsize", 100 };
|
||||||
|
Settings::SettingValue<bool> mLandeditPostSmoothpainting{ mIndex, sName, "landedit-post-smoothpainting",
|
||||||
|
false };
|
||||||
|
Settings::SettingValue<double> mLandeditPostSmoothstrength{ mIndex, sName, "landedit-post-smoothstrength",
|
||||||
|
0.25 };
|
||||||
|
Settings::SettingValue<bool> mOpenListView{ mIndex, sName, "open-list-view", false };
|
||||||
|
Settings::SettingValue<std::string> mPrimarySelectAction{ mIndex, sName, "primary-select-action",
|
||||||
|
std::string(sPrimarySelectAction[0].mValue), makeEnumSanitizerString(sPrimarySelectAction) };
|
||||||
|
Settings::SettingValue<std::string> mSecondarySelectAction{ mIndex, sName, "secondary-select-action",
|
||||||
|
std::string(sPrimarySelectAction[1].mValue), makeEnumSanitizerString(sPrimarySelectAction) };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct KeyBindingsCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "Key Bindings";
|
||||||
|
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileNewgame{ mIndex, sName, "document-file-newgame", "Ctrl+N" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileNewaddon{ mIndex, sName, "document-file-newaddon", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileOpen{ mIndex, sName, "document-file-open", "Ctrl+O" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileSave{ mIndex, sName, "document-file-save", "Ctrl+S" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentHelpHelp{ mIndex, sName, "document-help-help", "F1" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentHelpTutorial{ mIndex, sName, "document-help-tutorial", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileVerify{ mIndex, sName, "document-file-verify", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileMerge{ mIndex, sName, "document-file-merge", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileErrorlog{ mIndex, sName, "document-file-errorlog", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileMetadata{ mIndex, sName, "document-file-metadata", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileClose{ mIndex, sName, "document-file-close", "Ctrl+W" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentFileExit{ mIndex, sName, "document-file-exit", "Ctrl+Q" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentEditUndo{ mIndex, sName, "document-edit-undo", "Ctrl+Z" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentEditRedo{ mIndex, sName, "document-edit-redo", "Ctrl+Shift+Z" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentEditPreferences{ mIndex, sName, "document-edit-preferences", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentEditSearch{ mIndex, sName, "document-edit-search", "Ctrl+F" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentViewNewview{ mIndex, sName, "document-view-newview", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentViewStatusbar{ mIndex, sName, "document-view-statusbar", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentViewFilters{ mIndex, sName, "document-view-filters", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentWorldRegions{ mIndex, sName, "document-world-regions", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentWorldCells{ mIndex, sName, "document-world-cells", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentWorldReferencables{ mIndex, sName, "document-world-referencables",
|
||||||
|
"" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentWorldReferences{ mIndex, sName, "document-world-references", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentWorldLands{ mIndex, sName, "document-world-lands", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentWorldLandtextures{ mIndex, sName, "document-world-landtextures",
|
||||||
|
"" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentWorldPathgrid{ mIndex, sName, "document-world-pathgrid", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentWorldRegionmap{ mIndex, sName, "document-world-regionmap", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentMechanicsGlobals{ mIndex, sName, "document-mechanics-globals",
|
||||||
|
"" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentMechanicsGamesettings{ mIndex, sName,
|
||||||
|
"document-mechanics-gamesettings", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentMechanicsScripts{ mIndex, sName, "document-mechanics-scripts",
|
||||||
|
"" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentMechanicsSpells{ mIndex, sName, "document-mechanics-spells", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentMechanicsEnchantments{ mIndex, sName,
|
||||||
|
"document-mechanics-enchantments", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentMechanicsMagiceffects{ mIndex, sName,
|
||||||
|
"document-mechanics-magiceffects", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentMechanicsStartscripts{ mIndex, sName,
|
||||||
|
"document-mechanics-startscripts", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterSkills{ mIndex, sName, "document-character-skills", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterClasses{ mIndex, sName, "document-character-classes",
|
||||||
|
"" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterFactions{ mIndex, sName, "document-character-factions",
|
||||||
|
"" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterRaces{ mIndex, sName, "document-character-races", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterBirthsigns{ mIndex, sName,
|
||||||
|
"document-character-birthsigns", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterTopics{ mIndex, sName, "document-character-topics", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterJournals{ mIndex, sName, "document-character-journals",
|
||||||
|
"" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterTopicinfos{ mIndex, sName,
|
||||||
|
"document-character-topicinfos", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterJournalinfos{ mIndex, sName,
|
||||||
|
"document-character-journalinfos", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentCharacterBodyparts{ mIndex, sName, "document-character-bodyparts",
|
||||||
|
"" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentAssetsReload{ mIndex, sName, "document-assets-reload", "F5" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentAssetsSounds{ mIndex, sName, "document-assets-sounds", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentAssetsSoundgens{ mIndex, sName, "document-assets-soundgens", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentAssetsMeshes{ mIndex, sName, "document-assets-meshes", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentAssetsIcons{ mIndex, sName, "document-assets-icons", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentAssetsMusic{ mIndex, sName, "document-assets-music", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentAssetsSoundres{ mIndex, sName, "document-assets-soundres", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentAssetsTextures{ mIndex, sName, "document-assets-textures", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentAssetsVideos{ mIndex, sName, "document-assets-videos", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentDebugRun{ mIndex, sName, "document-debug-run", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentDebugShutdown{ mIndex, sName, "document-debug-shutdown", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentDebugProfiles{ mIndex, sName, "document-debug-profiles", "" };
|
||||||
|
Settings::SettingValue<std::string> mDocumentDebugRunlog{ mIndex, sName, "document-debug-runlog", "" };
|
||||||
|
Settings::SettingValue<std::string> mTableEdit{ mIndex, sName, "table-edit", "" };
|
||||||
|
Settings::SettingValue<std::string> mTableAdd{ mIndex, sName, "table-add", "Shift+A" };
|
||||||
|
Settings::SettingValue<std::string> mTableClone{ mIndex, sName, "table-clone", "Shift+D" };
|
||||||
|
Settings::SettingValue<std::string> mTouchRecord{ mIndex, sName, "touch-record", "" };
|
||||||
|
Settings::SettingValue<std::string> mTableRevert{ mIndex, sName, "table-revert", "" };
|
||||||
|
Settings::SettingValue<std::string> mTableRemove{ mIndex, sName, "table-remove", "Delete" };
|
||||||
|
Settings::SettingValue<std::string> mTableMoveup{ mIndex, sName, "table-moveup", "" };
|
||||||
|
Settings::SettingValue<std::string> mTableMovedown{ mIndex, sName, "table-movedown", "" };
|
||||||
|
Settings::SettingValue<std::string> mTableView{ mIndex, sName, "table-view", "Shift+C" };
|
||||||
|
Settings::SettingValue<std::string> mTablePreview{ mIndex, sName, "table-preview", "Shift+V" };
|
||||||
|
Settings::SettingValue<std::string> mTableExtendeddelete{ mIndex, sName, "table-extendeddelete", "" };
|
||||||
|
Settings::SettingValue<std::string> mTableExtendedrevert{ mIndex, sName, "table-extendedrevert", "" };
|
||||||
|
Settings::SettingValue<std::string> mReporttableShow{ mIndex, sName, "reporttable-show", "" };
|
||||||
|
Settings::SettingValue<std::string> mReporttableRemove{ mIndex, sName, "reporttable-remove", "Delete" };
|
||||||
|
Settings::SettingValue<std::string> mReporttableReplace{ mIndex, sName, "reporttable-replace", "" };
|
||||||
|
Settings::SettingValue<std::string> mReporttableRefresh{ mIndex, sName, "reporttable-refresh", "" };
|
||||||
|
Settings::SettingValue<std::string> mSceneNaviPrimary{ mIndex, sName, "scene-navi-primary", "LMB" };
|
||||||
|
Settings::SettingValue<std::string> mSceneNaviSecondary{ mIndex, sName, "scene-navi-secondary", "Ctrl+LMB" };
|
||||||
|
Settings::SettingValue<std::string> mSceneOpenPrimary{ mIndex, sName, "scene-open-primary", "Shift+LMB" };
|
||||||
|
Settings::SettingValue<std::string> mSceneEditPrimary{ mIndex, sName, "scene-edit-primary", "RMB" };
|
||||||
|
Settings::SettingValue<std::string> mSceneEditSecondary{ mIndex, sName, "scene-edit-secondary", "Ctrl+RMB" };
|
||||||
|
Settings::SettingValue<std::string> mSceneSelectPrimary{ mIndex, sName, "scene-select-primary", "MMB" };
|
||||||
|
Settings::SettingValue<std::string> mSceneSelectSecondary{ mIndex, sName, "scene-select-secondary",
|
||||||
|
"Ctrl+MMB" };
|
||||||
|
Settings::SettingValue<std::string> mSceneSelectTertiary{ mIndex, sName, "scene-select-tertiary", "Shift+MMB" };
|
||||||
|
Settings::SettingValue<std::string> mSceneSpeedModifier{ mIndex, sName, "scene-speed-modifier", "Shift" };
|
||||||
|
Settings::SettingValue<std::string> mSceneDelete{ mIndex, sName, "scene-delete", "Delete" };
|
||||||
|
Settings::SettingValue<std::string> mSceneInstanceDropTerrain{ mIndex, sName, "scene-instance-drop-terrain",
|
||||||
|
"G" };
|
||||||
|
Settings::SettingValue<std::string> mSceneInstanceDropCollision{ mIndex, sName, "scene-instance-drop-collision",
|
||||||
|
"H" };
|
||||||
|
Settings::SettingValue<std::string> mSceneInstanceDropTerrainSeparately{ mIndex, sName,
|
||||||
|
"scene-instance-drop-terrain-separately", "" };
|
||||||
|
Settings::SettingValue<std::string> mSceneInstanceDropCollisionSeparately{ mIndex, sName,
|
||||||
|
"scene-instance-drop-collision-separately", "" };
|
||||||
|
Settings::SettingValue<std::string> mSceneLoadCamCell{ mIndex, sName, "scene-load-cam-cell", "Keypad+5" };
|
||||||
|
Settings::SettingValue<std::string> mSceneLoadCamEastcell{ mIndex, sName, "scene-load-cam-eastcell",
|
||||||
|
"Keypad+6" };
|
||||||
|
Settings::SettingValue<std::string> mSceneLoadCamNorthcell{ mIndex, sName, "scene-load-cam-northcell",
|
||||||
|
"Keypad+8" };
|
||||||
|
Settings::SettingValue<std::string> mSceneLoadCamWestcell{ mIndex, sName, "scene-load-cam-westcell",
|
||||||
|
"Keypad+4" };
|
||||||
|
Settings::SettingValue<std::string> mSceneLoadCamSouthcell{ mIndex, sName, "scene-load-cam-southcell",
|
||||||
|
"Keypad+2" };
|
||||||
|
Settings::SettingValue<std::string> mSceneEditAbort{ mIndex, sName, "scene-edit-abort", "Escape" };
|
||||||
|
Settings::SettingValue<std::string> mSceneFocusToolbar{ mIndex, sName, "scene-focus-toolbar", "T" };
|
||||||
|
Settings::SettingValue<std::string> mSceneRenderStats{ mIndex, sName, "scene-render-stats", "F3" };
|
||||||
|
Settings::SettingValue<std::string> mFreeForward{ mIndex, sName, "free-forward", "W" };
|
||||||
|
Settings::SettingValue<std::string> mFreeBackward{ mIndex, sName, "free-backward", "S" };
|
||||||
|
Settings::SettingValue<std::string> mFreeLeft{ mIndex, sName, "free-left", "A" };
|
||||||
|
Settings::SettingValue<std::string> mFreeRight{ mIndex, sName, "free-right", "D" };
|
||||||
|
Settings::SettingValue<std::string> mFreeRollLeft{ mIndex, sName, "free-roll-left", "Q" };
|
||||||
|
Settings::SettingValue<std::string> mFreeRollRight{ mIndex, sName, "free-roll-right", "E" };
|
||||||
|
Settings::SettingValue<std::string> mFreeSpeedMode{ mIndex, sName, "free-speed-mode", "F" };
|
||||||
|
Settings::SettingValue<std::string> mOrbitUp{ mIndex, sName, "orbit-up", "W" };
|
||||||
|
Settings::SettingValue<std::string> mOrbitDown{ mIndex, sName, "orbit-down", "S" };
|
||||||
|
Settings::SettingValue<std::string> mOrbitLeft{ mIndex, sName, "orbit-left", "A" };
|
||||||
|
Settings::SettingValue<std::string> mOrbitRight{ mIndex, sName, "orbit-right", "D" };
|
||||||
|
Settings::SettingValue<std::string> mOrbitRollLeft{ mIndex, sName, "orbit-roll-left", "Q" };
|
||||||
|
Settings::SettingValue<std::string> mOrbitRollRight{ mIndex, sName, "orbit-roll-right", "E" };
|
||||||
|
Settings::SettingValue<std::string> mOrbitSpeedMode{ mIndex, sName, "orbit-speed-mode", "F" };
|
||||||
|
Settings::SettingValue<std::string> mOrbitCenterSelection{ mIndex, sName, "orbit-center-selection", "C" };
|
||||||
|
Settings::SettingValue<std::string> mScriptEditorComment{ mIndex, sName, "script-editor-comment", "" };
|
||||||
|
Settings::SettingValue<std::string> mScriptEditorUncomment{ mIndex, sName, "script-editor-uncomment", "" };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ModelsCategory : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
static constexpr std::string_view sName = "Models";
|
||||||
|
|
||||||
|
Settings::SettingValue<std::string> mBaseanim{ mIndex, sName, "baseanim", "meshes/base_anim.nif" };
|
||||||
|
Settings::SettingValue<std::string> mBaseanimkna{ mIndex, sName, "baseanimkna", "meshes/base_animkna.nif" };
|
||||||
|
Settings::SettingValue<std::string> mBaseanimfemale{ mIndex, sName, "baseanimfemale",
|
||||||
|
"meshes/base_anim_female.nif" };
|
||||||
|
Settings::SettingValue<std::string> mWolfskin{ mIndex, sName, "wolfskin", "meshes/wolf/skin.nif" };
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Values : Settings::WithIndex
|
||||||
|
{
|
||||||
|
using Settings::WithIndex::WithIndex;
|
||||||
|
|
||||||
|
WindowsCategory mWindows{ mIndex };
|
||||||
|
RecordsCategory mRecords{ mIndex };
|
||||||
|
IdTablesCategory mIdTables{ mIndex };
|
||||||
|
IdDialoguesCategory mIdDialogues{ mIndex };
|
||||||
|
ReportsCategory mReports{ mIndex };
|
||||||
|
SearchAndReplaceCategory mSearchAndReplace{ mIndex };
|
||||||
|
ScriptsCategory mScripts{ mIndex };
|
||||||
|
GeneralInputCategory mGeneralInput{ mIndex };
|
||||||
|
SceneInputCategory mSceneInput{ mIndex };
|
||||||
|
RenderingCategory mRendering{ mIndex };
|
||||||
|
TooltipsCategory mTooltips{ mIndex };
|
||||||
|
SceneEditingCategory mSceneEditing{ mIndex };
|
||||||
|
KeyBindingsCategory mKeyBindings{ mIndex };
|
||||||
|
ModelsCategory mModels{ mIndex };
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
@ -61,46 +62,35 @@ namespace CSVPrefs
|
||||||
|
|
||||||
void KeyBindingPage::addSetting(CSMPrefs::Setting* setting)
|
void KeyBindingPage::addSetting(CSMPrefs::Setting* setting)
|
||||||
{
|
{
|
||||||
std::pair<QWidget*, QWidget*> widgets = setting->makeWidgets(this);
|
const CSMPrefs::SettingWidgets widgets = setting->makeWidgets(this);
|
||||||
|
|
||||||
if (widgets.first)
|
if (widgets.mLabel != nullptr && widgets.mInput != nullptr)
|
||||||
{
|
{
|
||||||
// Label, Option widgets
|
// Label, Option widgets
|
||||||
assert(mPageLayout);
|
assert(mPageLayout);
|
||||||
|
|
||||||
int next = mPageLayout->rowCount();
|
int next = mPageLayout->rowCount();
|
||||||
mPageLayout->addWidget(widgets.first, next, 0);
|
mPageLayout->addWidget(widgets.mLabel, next, 0);
|
||||||
mPageLayout->addWidget(widgets.second, next, 1);
|
mPageLayout->addWidget(widgets.mInput, next, 1);
|
||||||
}
|
}
|
||||||
else if (widgets.second)
|
else if (widgets.mInput != nullptr)
|
||||||
{
|
{
|
||||||
// Wide single widget
|
// Wide single widget
|
||||||
assert(mPageLayout);
|
assert(mPageLayout);
|
||||||
|
|
||||||
int next = mPageLayout->rowCount();
|
int next = mPageLayout->rowCount();
|
||||||
mPageLayout->addWidget(widgets.second, next, 0, 1, 2);
|
mPageLayout->addWidget(widgets.mInput, next, 0, 1, 2);
|
||||||
}
|
}
|
||||||
else
|
else if (widgets.mLayout != nullptr)
|
||||||
{
|
|
||||||
if (setting->getLabel().empty())
|
|
||||||
{
|
|
||||||
// Insert empty space
|
|
||||||
assert(mPageLayout);
|
|
||||||
|
|
||||||
int next = mPageLayout->rowCount();
|
|
||||||
mPageLayout->addWidget(new QWidget(), next, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Create new page
|
// Create new page
|
||||||
QWidget* pageWidget = new QWidget();
|
QWidget* pageWidget = new QWidget();
|
||||||
mPageLayout = new QGridLayout(pageWidget);
|
mPageLayout = widgets.mLayout;
|
||||||
mPageLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
mPageLayout->setParent(pageWidget);
|
||||||
|
|
||||||
mStackedLayout->addWidget(pageWidget);
|
mStackedLayout->addWidget(pageWidget);
|
||||||
|
|
||||||
mPageSelector->addItem(QString::fromUtf8(setting->getLabel().c_str()));
|
mPageSelector->addItem(setting->getLabel());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <apps/opencs/view/prefs/pagebase.hpp>
|
#include <apps/opencs/view/prefs/pagebase.hpp>
|
||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
#include "../../model/prefs/category.hpp"
|
#include "../../model/prefs/category.hpp"
|
||||||
#include "../../model/prefs/setting.hpp"
|
#include "../../model/prefs/setting.hpp"
|
||||||
|
@ -24,21 +25,17 @@ CSVPrefs::Page::Page(CSMPrefs::Category& category, QWidget* parent)
|
||||||
|
|
||||||
void CSVPrefs::Page::addSetting(CSMPrefs::Setting* setting)
|
void CSVPrefs::Page::addSetting(CSMPrefs::Setting* setting)
|
||||||
{
|
{
|
||||||
std::pair<QWidget*, QWidget*> widgets = setting->makeWidgets(this);
|
const CSMPrefs::SettingWidgets widgets = setting->makeWidgets(this);
|
||||||
|
|
||||||
int next = mGrid->rowCount();
|
int next = mGrid->rowCount();
|
||||||
|
|
||||||
if (widgets.first)
|
if (widgets.mLabel != nullptr && widgets.mInput != nullptr)
|
||||||
{
|
{
|
||||||
mGrid->addWidget(widgets.first, next, 0);
|
mGrid->addWidget(widgets.mLabel, next, 0);
|
||||||
mGrid->addWidget(widgets.second, next, 1);
|
mGrid->addWidget(widgets.mInput, next, 1);
|
||||||
}
|
}
|
||||||
else if (widgets.second)
|
else if (widgets.mInput != nullptr)
|
||||||
{
|
{
|
||||||
mGrid->addWidget(widgets.second, next, 0, 1, 2);
|
mGrid->addWidget(widgets.mInput, next, 0, 1, 2);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mGrid->addWidget(new QWidget(this), next, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -335,6 +335,15 @@ namespace Settings
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
explicit SettingValue(Index& index, std::string_view category, std::string_view name, T&& defaultValue,
|
||||||
|
std::unique_ptr<const Sanitizer<T>>&& sanitizer = nullptr)
|
||||||
|
: BaseSettingValue(getSettingValueType<T>(), category, name, index)
|
||||||
|
, mSanitizer(std::move(sanitizer))
|
||||||
|
, mDefaultValue(defaultValue)
|
||||||
|
, mValue(defaultValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
SettingValue(SettingValue&& other)
|
SettingValue(SettingValue&& other)
|
||||||
: BaseSettingValue(std::move(other))
|
: BaseSettingValue(std::move(other))
|
||||||
, mSanitizer(std::move(other.mSanitizer))
|
, mSanitizer(std::move(other.mSanitizer))
|
||||||
|
|
Loading…
Reference in a new issue