|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <QString> |
| 4 | +#include <QVariant> |
| 5 | + |
| 6 | +namespace MOBase |
| 7 | +{ |
| 8 | + |
| 9 | +// class representing a group of settings |
| 10 | +// |
| 11 | +class SettingGroup |
| 12 | +{ |
| 13 | +public: |
| 14 | + SettingGroup(QString const& name, QString const& title, QString const& description) |
| 15 | + : m_Name{name}, m_Title{title}, m_Description{description} |
| 16 | + {} |
| 17 | + |
| 18 | + // return the (internal) name of this group, localization independent |
| 19 | + // |
| 20 | + const auto& name() const { return m_Name; } |
| 21 | + |
| 22 | + // retrieve the title of this group, can be localized |
| 23 | + // |
| 24 | + const auto& title() const { return m_Title; } |
| 25 | + |
| 26 | + // retrieve the description of this group, can be localized |
| 27 | + // |
| 28 | + const auto& description() const { return m_Description; } |
| 29 | + |
| 30 | +private: |
| 31 | + QString m_Name, m_Title, m_Description; |
| 32 | +}; |
| 33 | + |
| 34 | +// class that represents an extension or a plugin setting |
| 35 | +// |
| 36 | +class Setting |
| 37 | +{ |
| 38 | +public: |
| 39 | + // deprecated constructor that was previously available as PluginSettin |
| 40 | + // |
| 41 | + [[deprecated]] Setting(const QString& name, const QString& description, |
| 42 | + const QVariant& defaultValue) |
| 43 | + : m_Name{name}, m_Title{name}, m_Description{description}, m_Group{}, |
| 44 | + m_DefaultValue{defaultValue} |
| 45 | + {} |
| 46 | + |
| 47 | + Setting(const QString& name, const QString& title, const QString& description, |
| 48 | + const QVariant& defaultValue) |
| 49 | + : m_Name{name}, m_Title{title}, m_Description{description}, m_Group{}, |
| 50 | + m_DefaultValue{defaultValue} |
| 51 | + {} |
| 52 | + |
| 53 | + Setting(const QString& name, const QString& title, const QString& description, |
| 54 | + const QString& group, const QVariant& defaultValue) |
| 55 | + : m_Name{name}, m_Title{title}, m_Description{description}, m_Group{group}, |
| 56 | + m_DefaultValue{defaultValue} |
| 57 | + {} |
| 58 | + |
| 59 | +public: |
| 60 | + // return the (internal) name of this setting, localization independent |
| 61 | + // |
| 62 | + const auto& name() const { return m_Name; } |
| 63 | + |
| 64 | + // retrieve the title of this setting, can be localized |
| 65 | + // |
| 66 | + const auto& title() const { return m_Title; } |
| 67 | + |
| 68 | + // retrieve the description of this setting, can be localized |
| 69 | + // |
| 70 | + const auto& description() const { return m_Description; } |
| 71 | + |
| 72 | + // retrieve the name of the group this settings belongs to or an empty string if there |
| 73 | + // is none |
| 74 | + // |
| 75 | + const auto& group() const { return m_Group; } |
| 76 | + |
| 77 | + // retrieve the default value of this setting |
| 78 | + // |
| 79 | + const auto& defaultValue() const { return m_DefaultValue; } |
| 80 | + |
| 81 | +private: |
| 82 | + QString m_Name; |
| 83 | + QString m_Title; |
| 84 | + QString m_Description; |
| 85 | + QString m_Group; |
| 86 | + QVariant m_DefaultValue; |
| 87 | +}; |
| 88 | + |
| 89 | +} // namespace MOBase |
0 commit comments