mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-06 08:15:34 +00:00
Avoid std::string to QString conversion for label
This commit is contained in:
parent
d6220b7d03
commit
335dbffe6e
21 changed files with 49 additions and 61 deletions
|
@ -11,7 +11,7 @@
|
|||
#include "state.hpp"
|
||||
|
||||
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)
|
||||
, mDefault(default_)
|
||||
, mWidget(nullptr)
|
||||
|
@ -26,7 +26,7 @@ CSMPrefs::BoolSetting& CSMPrefs::BoolSetting::setTooltip(const std::string& tool
|
|||
|
||||
std::pair<QWidget*, QWidget*> 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);
|
||||
|
||||
if (!mTooltip.empty())
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace CSMPrefs
|
|||
QCheckBox* mWidget;
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "state.hpp"
|
||||
|
||||
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)
|
||||
, mDefault(std::move(default_))
|
||||
, mWidget(nullptr)
|
||||
|
@ -29,7 +29,7 @@ CSMPrefs::ColourSetting& CSMPrefs::ColourSetting::setTooltip(const std::string&
|
|||
|
||||
std::pair<QWidget*, QWidget*> 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);
|
||||
|
||||
|
|
|
@ -29,8 +29,7 @@ namespace CSMPrefs
|
|||
CSVWidget::ColorEditor* mWidget;
|
||||
|
||||
public:
|
||||
ColourSetting(
|
||||
Category* parent, QMutex* mutex, const std::string& key, const std::string& label, QColor default_);
|
||||
ColourSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label, QColor default_);
|
||||
|
||||
ColourSetting& setTooltip(const std::string& tooltip);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "state.hpp"
|
||||
|
||||
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)
|
||||
, mPrecision(2)
|
||||
, mMin(0)
|
||||
|
@ -58,7 +58,7 @@ CSMPrefs::DoubleSetting& CSMPrefs::DoubleSetting::setTooltip(const std::string&
|
|||
|
||||
std::pair<QWidget*, QWidget*> 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->setDecimals(mPrecision);
|
||||
|
|
|
@ -21,8 +21,7 @@ namespace CSMPrefs
|
|||
QDoubleSpinBox* mWidget;
|
||||
|
||||
public:
|
||||
DoubleSetting(
|
||||
Category* parent, QMutex* mutex, const std::string& key, const std::string& label, double default_);
|
||||
DoubleSetting(Category* parent, QMutex* mutex, const std::string& key, const QString& label, double default_);
|
||||
|
||||
DoubleSetting& setPrecision(int precision);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ CSMPrefs::EnumValues& CSMPrefs::EnumValues::add(const std::string& value, const
|
|||
}
|
||||
|
||||
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)
|
||||
, mDefault(default_)
|
||||
, mWidget(nullptr)
|
||||
|
@ -78,7 +78,7 @@ CSMPrefs::EnumSetting& CSMPrefs::EnumSetting::addValue(const std::string& value,
|
|||
|
||||
std::pair<QWidget*, QWidget*> 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);
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ namespace CSMPrefs
|
|||
QComboBox* mWidget;
|
||||
|
||||
public:
|
||||
EnumSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label,
|
||||
const EnumValue& default_);
|
||||
EnumSetting(
|
||||
Category* parent, QMutex* mutex, const std::string& key, const QString& label, const EnumValue& default_);
|
||||
|
||||
EnumSetting& setTooltip(const std::string& tooltip);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "state.hpp"
|
||||
|
||||
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)
|
||||
, mMin(0)
|
||||
, mMax(std::numeric_limits<int>::max())
|
||||
|
@ -51,7 +51,7 @@ CSMPrefs::IntSetting& CSMPrefs::IntSetting::setTooltip(const std::string& toolti
|
|||
|
||||
std::pair<QWidget*, QWidget*> 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->setRange(mMin, mMax);
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace CSMPrefs
|
|||
QSpinBox* mWidget;
|
||||
|
||||
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()]
|
||||
IntSetting& setRange(int min, int max);
|
||||
|
|
|
@ -19,7 +19,7 @@ class QWidget;
|
|||
|
||||
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)
|
||||
, mButton(nullptr)
|
||||
, mEditorActive(false)
|
||||
|
@ -33,7 +33,7 @@ namespace CSMPrefs
|
|||
|
||||
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);
|
||||
|
||||
widget->setCheckable(true);
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace CSMPrefs
|
|||
Q_OBJECT
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ QMutex* CSMPrefs::Setting::getMutex()
|
|||
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())
|
||||
, mParent(parent)
|
||||
, mMutex(mutex)
|
||||
|
@ -40,11 +40,6 @@ const std::string& CSMPrefs::Setting::getKey() const
|
|||
return mKey;
|
||||
}
|
||||
|
||||
const std::string& CSMPrefs::Setting::getLabel() const
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
int CSMPrefs::Setting::toInt() const
|
||||
{
|
||||
QMutexLocker lock(mMutex);
|
||||
|
|
|
@ -21,13 +21,13 @@ namespace CSMPrefs
|
|||
Category* mParent;
|
||||
QMutex* mMutex;
|
||||
std::string mKey;
|
||||
std::string mLabel;
|
||||
QString mLabel;
|
||||
|
||||
protected:
|
||||
QMutex* getMutex();
|
||||
|
||||
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;
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace CSMPrefs
|
|||
|
||||
const std::string& getKey() const;
|
||||
|
||||
const std::string& getLabel() const;
|
||||
const QString& getLabel() const { return mLabel; }
|
||||
|
||||
int toInt() const;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
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)
|
||||
, mButton(nullptr)
|
||||
, mEditorActive(false)
|
||||
|
@ -37,7 +37,7 @@ namespace CSMPrefs
|
|||
|
||||
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);
|
||||
|
||||
widget->setCheckable(true);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace CSMPrefs
|
|||
Q_OBJECT
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -463,7 +463,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())
|
||||
throw std::logic_error("no category for setting");
|
||||
|
@ -479,8 +479,7 @@ CSMPrefs::IntSetting& CSMPrefs::State::declareInt(const std::string& key, const
|
|||
return *setting;
|
||||
}
|
||||
|
||||
CSMPrefs::DoubleSetting& CSMPrefs::State::declareDouble(
|
||||
const std::string& key, const std::string& label, double default_)
|
||||
CSMPrefs::DoubleSetting& CSMPrefs::State::declareDouble(const std::string& key, const QString& label, double default_)
|
||||
{
|
||||
if (mCurrentCategory == mCategories.end())
|
||||
throw std::logic_error("no category for setting");
|
||||
|
@ -499,7 +498,7 @@ CSMPrefs::DoubleSetting& CSMPrefs::State::declareDouble(
|
|||
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())
|
||||
throw std::logic_error("no category for setting");
|
||||
|
@ -516,8 +515,7 @@ CSMPrefs::BoolSetting& CSMPrefs::State::declareBool(const std::string& key, cons
|
|||
return *setting;
|
||||
}
|
||||
|
||||
CSMPrefs::EnumSetting& CSMPrefs::State::declareEnum(
|
||||
const std::string& key, const std::string& label, EnumValue default_)
|
||||
CSMPrefs::EnumSetting& CSMPrefs::State::declareEnum(const std::string& key, const QString& label, EnumValue default_)
|
||||
{
|
||||
if (mCurrentCategory == mCategories.end())
|
||||
throw std::logic_error("no category for setting");
|
||||
|
@ -534,8 +532,7 @@ CSMPrefs::EnumSetting& CSMPrefs::State::declareEnum(
|
|||
return *setting;
|
||||
}
|
||||
|
||||
CSMPrefs::ColourSetting& CSMPrefs::State::declareColour(
|
||||
const std::string& key, const std::string& label, QColor default_)
|
||||
CSMPrefs::ColourSetting& CSMPrefs::State::declareColour(const std::string& key, const QString& label, QColor default_)
|
||||
{
|
||||
if (mCurrentCategory == mCategories.end())
|
||||
throw std::logic_error("no category for setting");
|
||||
|
@ -554,7 +551,7 @@ CSMPrefs::ColourSetting& CSMPrefs::State::declareColour(
|
|||
}
|
||||
|
||||
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())
|
||||
throw std::logic_error("no category for setting");
|
||||
|
@ -576,7 +573,7 @@ CSMPrefs::ShortcutSetting& CSMPrefs::State::declareShortcut(
|
|||
}
|
||||
|
||||
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())
|
||||
throw std::logic_error("no category for setting");
|
||||
|
@ -593,8 +590,7 @@ CSMPrefs::StringSetting& CSMPrefs::State::declareString(
|
|||
return *setting;
|
||||
}
|
||||
|
||||
CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(
|
||||
const std::string& key, const std::string& label, int default_)
|
||||
CSMPrefs::ModifierSetting& CSMPrefs::State::declareModifier(const std::string& key, const QString& label, int default_)
|
||||
{
|
||||
if (mCurrentCategory == mCategories.end())
|
||||
throw std::logic_error("no category for setting");
|
||||
|
@ -625,7 +621,7 @@ void CSMPrefs::State::declareSeparator()
|
|||
mCurrentCategory->second.addSetting(setting);
|
||||
}
|
||||
|
||||
void CSMPrefs::State::declareSubcategory(const std::string& label)
|
||||
void CSMPrefs::State::declareSubcategory(const QString& label)
|
||||
{
|
||||
if (mCurrentCategory == mCategories.end())
|
||||
throw std::logic_error("no category for setting");
|
||||
|
|
|
@ -60,25 +60,24 @@ namespace CSMPrefs
|
|||
|
||||
void declareCategory(const std::string& key);
|
||||
|
||||
IntSetting& declareInt(const std::string& key, const std::string& label, int default_);
|
||||
DoubleSetting& declareDouble(const std::string& key, const std::string& label, double default_);
|
||||
IntSetting& declareInt(const std::string& key, const QString& label, int 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(
|
||||
const std::string& key, const std::string& label, const QKeySequence& default_);
|
||||
ShortcutSetting& declareShortcut(const std::string& key, const QString& 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 std::string& label);
|
||||
void declareSubcategory(const QString& label);
|
||||
|
||||
void setDefault(const std::string& key, const std::string& default_);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include "state.hpp"
|
||||
|
||||
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)
|
||||
, mDefault(default_)
|
||||
, mWidget(nullptr)
|
||||
|
|
|
@ -23,8 +23,8 @@ namespace CSMPrefs
|
|||
QLineEdit* mWidget;
|
||||
|
||||
public:
|
||||
StringSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label,
|
||||
std::string_view default_);
|
||||
StringSetting(
|
||||
Category* parent, QMutex* mutex, const std::string& key, const QString& label, std::string_view default_);
|
||||
|
||||
StringSetting& setTooltip(const std::string& tooltip);
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace CSVPrefs
|
|||
}
|
||||
else
|
||||
{
|
||||
if (setting->getLabel().empty())
|
||||
if (setting->getLabel().isEmpty())
|
||||
{
|
||||
// Insert empty space
|
||||
assert(mPageLayout);
|
||||
|
@ -99,7 +99,7 @@ namespace CSVPrefs
|
|||
|
||||
mStackedLayout->addWidget(pageWidget);
|
||||
|
||||
mPageSelector->addItem(QString::fromUtf8(setting->getLabel().c_str()));
|
||||
mPageSelector->addItem(setting->getLabel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue