1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-11 00:39:59 +00:00
OpenMW/apps/opencs/model/prefs/setting.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

70 lines
1.6 KiB
C++
Raw Normal View History

2015-12-08 16:21:58 +00:00
#ifndef CSM_PREFS_SETTING_H
#define CSM_PREFS_SETTING_H
#include <string>
#include <utility>
#include <QObject>
class QWidget;
2015-12-11 10:50:06 +00:00
class QColor;
2015-12-15 11:19:48 +00:00
class QMutex;
2015-12-08 16:21:58 +00:00
namespace CSMPrefs
{
class Category;
class Setting : public QObject
{
Q_OBJECT
Category* mParent;
2015-12-15 11:19:48 +00:00
QMutex* mMutex;
2015-12-08 16:21:58 +00:00
std::string mKey;
std::string mLabel;
protected:
2015-12-15 11:19:48 +00:00
QMutex* getMutex();
2015-12-08 16:21:58 +00:00
2022-09-22 18:26:05 +00:00
public:
2015-12-15 11:19:48 +00:00
Setting(Category* parent, QMutex* mutex, const std::string& key, const std::string& label);
2015-12-08 16:21:58 +00:00
virtual ~Setting();
/// Return label, input widget.
2022-09-22 18:26:05 +00:00
///
/// \note first can be a 0-pointer, which means that the label is part of the input
2015-12-08 16:21:58 +00:00
/// widget.
virtual std::pair<QWidget*, QWidget*> makeWidgets(QWidget* parent);
2015-12-08 16:21:58 +00:00
/// Updates the widget returned by makeWidgets() to the current setting.
2022-09-22 18:26:05 +00:00
///
/// \note If make_widgets() has not been called yet then nothing happens.
2015-12-08 16:21:58 +00:00
virtual void updateWidget();
const Category* getParent() const;
const std::string& getKey() const;
2015-12-08 16:21:58 +00:00
const std::string& getLabel() const;
int toInt() const;
double toDouble() const;
2015-12-11 10:50:06 +00:00
std::string toString() const;
bool isTrue() const;
QColor toColor() const;
2015-12-08 16:21:58 +00:00
};
2015-12-11 10:50:06 +00:00
// note: fullKeys have the format categoryKey/settingKey
bool operator==(const Setting& setting, const std::string& fullKey);
bool operator==(const std::string& fullKey, const Setting& setting);
bool operator!=(const Setting& setting, const std::string& fullKey);
bool operator!=(const std::string& fullKey, const Setting& setting);
2015-12-08 16:21:58 +00:00
}
#endif