diff --git a/apps/opencs/model/prefs/boolsetting.cpp b/apps/opencs/model/prefs/boolsetting.cpp index c668bc0af4..c2718cd7aa 100644 --- a/apps/opencs/model/prefs/boolsetting.cpp +++ b/apps/opencs/model/prefs/boolsetting.cpp @@ -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 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()) diff --git a/apps/opencs/model/prefs/boolsetting.hpp b/apps/opencs/model/prefs/boolsetting.hpp index e75ea1a346..60d51a9888 100644 --- a/apps/opencs/model/prefs/boolsetting.hpp +++ b/apps/opencs/model/prefs/boolsetting.hpp @@ -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); diff --git a/apps/opencs/model/prefs/coloursetting.cpp b/apps/opencs/model/prefs/coloursetting.cpp index 86f3a5d772..b3f1b70513 100644 --- a/apps/opencs/model/prefs/coloursetting.cpp +++ b/apps/opencs/model/prefs/coloursetting.cpp @@ -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 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); diff --git a/apps/opencs/model/prefs/coloursetting.hpp b/apps/opencs/model/prefs/coloursetting.hpp index 0c22d9cc5d..e36ceb48b5 100644 --- a/apps/opencs/model/prefs/coloursetting.hpp +++ b/apps/opencs/model/prefs/coloursetting.hpp @@ -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); diff --git a/apps/opencs/model/prefs/doublesetting.cpp b/apps/opencs/model/prefs/doublesetting.cpp index 7e3aadb0c3..d88678a8e9 100644 --- a/apps/opencs/model/prefs/doublesetting.cpp +++ b/apps/opencs/model/prefs/doublesetting.cpp @@ -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 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); diff --git a/apps/opencs/model/prefs/doublesetting.hpp b/apps/opencs/model/prefs/doublesetting.hpp index c951d2a88c..76135c4cdb 100644 --- a/apps/opencs/model/prefs/doublesetting.hpp +++ b/apps/opencs/model/prefs/doublesetting.hpp @@ -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); diff --git a/apps/opencs/model/prefs/enumsetting.cpp b/apps/opencs/model/prefs/enumsetting.cpp index a3ac9bce2b..6d925d1b31 100644 --- a/apps/opencs/model/prefs/enumsetting.cpp +++ b/apps/opencs/model/prefs/enumsetting.cpp @@ -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 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); diff --git a/apps/opencs/model/prefs/enumsetting.hpp b/apps/opencs/model/prefs/enumsetting.hpp index 57bd2115ce..82ce209922 100644 --- a/apps/opencs/model/prefs/enumsetting.hpp +++ b/apps/opencs/model/prefs/enumsetting.hpp @@ -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); diff --git a/apps/opencs/model/prefs/intsetting.cpp b/apps/opencs/model/prefs/intsetting.cpp index 90cc77c788..e8fd4acce6 100644 --- a/apps/opencs/model/prefs/intsetting.cpp +++ b/apps/opencs/model/prefs/intsetting.cpp @@ -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::max()) @@ -51,7 +51,7 @@ CSMPrefs::IntSetting& CSMPrefs::IntSetting::setTooltip(const std::string& toolti std::pair 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); diff --git a/apps/opencs/model/prefs/intsetting.hpp b/apps/opencs/model/prefs/intsetting.hpp index 8a655178a4..48f24e5b78 100644 --- a/apps/opencs/model/prefs/intsetting.hpp +++ b/apps/opencs/model/prefs/intsetting.hpp @@ -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::max()] IntSetting& setRange(int min, int max); diff --git a/apps/opencs/model/prefs/modifiersetting.cpp b/apps/opencs/model/prefs/modifiersetting.cpp index 8752a4d51e..d20a427217 100644 --- a/apps/opencs/model/prefs/modifiersetting.cpp +++ b/apps/opencs/model/prefs/modifiersetting.cpp @@ -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); diff --git a/apps/opencs/model/prefs/modifiersetting.hpp b/apps/opencs/model/prefs/modifiersetting.hpp index ae984243ac..fb186329a9 100644 --- a/apps/opencs/model/prefs/modifiersetting.hpp +++ b/apps/opencs/model/prefs/modifiersetting.hpp @@ -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 makeWidgets(QWidget* parent) override; diff --git a/apps/opencs/model/prefs/setting.cpp b/apps/opencs/model/prefs/setting.cpp index efe360d1e8..d507236cc5 100644 --- a/apps/opencs/model/prefs/setting.cpp +++ b/apps/opencs/model/prefs/setting.cpp @@ -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); diff --git a/apps/opencs/model/prefs/setting.hpp b/apps/opencs/model/prefs/setting.hpp index f63271b3f2..01138c6a14 100644 --- a/apps/opencs/model/prefs/setting.hpp +++ b/apps/opencs/model/prefs/setting.hpp @@ -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; diff --git a/apps/opencs/model/prefs/shortcutsetting.cpp b/apps/opencs/model/prefs/shortcutsetting.cpp index d8c71d7008..23c8d9c7a9 100644 --- a/apps/opencs/model/prefs/shortcutsetting.cpp +++ b/apps/opencs/model/prefs/shortcutsetting.cpp @@ -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); diff --git a/apps/opencs/model/prefs/shortcutsetting.hpp b/apps/opencs/model/prefs/shortcutsetting.hpp index bef140dada..7dd2aecd61 100644 --- a/apps/opencs/model/prefs/shortcutsetting.hpp +++ b/apps/opencs/model/prefs/shortcutsetting.hpp @@ -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 makeWidgets(QWidget* parent) override; diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index 97f29bc8be..f95ceb896f 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -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"); diff --git a/apps/opencs/model/prefs/state.hpp b/apps/opencs/model/prefs/state.hpp index 354f4552e3..c74f317c94 100644 --- a/apps/opencs/model/prefs/state.hpp +++ b/apps/opencs/model/prefs/state.hpp @@ -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_); diff --git a/apps/opencs/model/prefs/stringsetting.cpp b/apps/opencs/model/prefs/stringsetting.cpp index 2a8fdd587a..bb7a9b7fe3 100644 --- a/apps/opencs/model/prefs/stringsetting.cpp +++ b/apps/opencs/model/prefs/stringsetting.cpp @@ -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) diff --git a/apps/opencs/model/prefs/stringsetting.hpp b/apps/opencs/model/prefs/stringsetting.hpp index 4b5499ef86..81adc55361 100644 --- a/apps/opencs/model/prefs/stringsetting.hpp +++ b/apps/opencs/model/prefs/stringsetting.hpp @@ -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); diff --git a/apps/opencs/view/prefs/keybindingpage.cpp b/apps/opencs/view/prefs/keybindingpage.cpp index d3cc1ff889..7b6337a6ab 100644 --- a/apps/opencs/view/prefs/keybindingpage.cpp +++ b/apps/opencs/view/prefs/keybindingpage.cpp @@ -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()); } } }