2015-12-10 16:33:14 +00:00
|
|
|
#ifndef CSM_PREFS_ENUMSETTING_H
|
|
|
|
#define CSM_PREFS_ENUMSETTING_H
|
|
|
|
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
2015-12-10 16:33:14 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "setting.hpp"
|
|
|
|
|
2017-05-09 07:50:16 +00:00
|
|
|
class QComboBox;
|
|
|
|
|
2015-12-10 16:33:14 +00:00
|
|
|
namespace CSMPrefs
|
|
|
|
{
|
2022-10-19 17:02:00 +00:00
|
|
|
class Category;
|
|
|
|
|
2015-12-10 16:33:14 +00:00
|
|
|
struct EnumValue
|
|
|
|
{
|
|
|
|
std::string mValue;
|
|
|
|
std::string mTooltip;
|
|
|
|
|
|
|
|
EnumValue(const std::string& value, const std::string& tooltip = "");
|
|
|
|
|
|
|
|
EnumValue(const char* value);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EnumValues
|
|
|
|
{
|
|
|
|
std::vector<EnumValue> mValues;
|
|
|
|
|
|
|
|
EnumValues& add(const EnumValues& values);
|
|
|
|
|
|
|
|
EnumValues& add(const EnumValue& value);
|
|
|
|
|
|
|
|
EnumValues& add(const std::string& value, const std::string& tooltip);
|
|
|
|
};
|
|
|
|
|
|
|
|
class EnumSetting : public Setting
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
std::string mTooltip;
|
|
|
|
EnumValue mDefault;
|
|
|
|
EnumValues mValues;
|
2017-05-09 07:50:16 +00:00
|
|
|
QComboBox* mWidget;
|
2015-12-10 16:33:14 +00:00
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
public:
|
2015-12-15 11:19:48 +00:00
|
|
|
EnumSetting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label,
|
|
|
|
const EnumValue& default_);
|
2015-12-10 16:33:14 +00:00
|
|
|
|
|
|
|
EnumSetting& setTooltip(const std::string& tooltip);
|
|
|
|
|
|
|
|
EnumSetting& addValues(const EnumValues& values);
|
|
|
|
|
|
|
|
EnumSetting& addValue(const EnumValue& value);
|
|
|
|
|
|
|
|
EnumSetting& addValue(const std::string& value, const std::string& tooltip);
|
|
|
|
|
|
|
|
/// Return label, input widget.
|
2020-10-16 18:18:54 +00:00
|
|
|
std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent) override;
|
2015-12-10 16:33:14 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void updateWidget() override;
|
2017-05-09 07:50:16 +00:00
|
|
|
|
2015-12-10 16:33:14 +00:00
|
|
|
private slots:
|
|
|
|
|
|
|
|
void valueChanged(int value);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|