! * */
| 26 | * |
| 27 | */ |
| 28 | class Setting : public QObject |
| 29 | { |
| 30 | Q_OBJECT |
| 31 | public: |
| 32 | /** |
| 33 | * Construct a Setting |
| 34 | * |
| 35 | * Synonyms are all the possible names used in the settings object, in order of preference. |
| 36 | * First synonym is the ID, which identifies the setting in PolyMC. |
| 37 | * |
| 38 | * defVal is the default value that will be returned when the settings object |
| 39 | * doesn't have any value for this setting. |
| 40 | */ |
| 41 | explicit Setting(QStringList synonyms, QVariant defVal = QVariant()); |
| 42 | |
| 43 | /*! |
| 44 | * \brief Gets this setting's ID. |
| 45 | * This is used to refer to the setting within the application. |
| 46 | * \warning Changing the ID while the setting is registered with a SettingsObject results in |
| 47 | * undefined behavior. |
| 48 | * \return The ID of the setting. |
| 49 | */ |
| 50 | virtual QString id() const |
| 51 | { |
| 52 | return m_synonyms.first(); |
| 53 | } |
| 54 | |
| 55 | /*! |
| 56 | * \brief Gets this setting's config file key. |
| 57 | * This is used to store the setting's value in the config file. It is usually |
| 58 | * the same as the setting's ID, but it can be different. |
| 59 | * \return The setting's config file key. |
| 60 | */ |
| 61 | virtual QStringList configKeys() const |
| 62 | { |
| 63 | return m_synonyms; |
| 64 | } |
| 65 | |
| 66 | /*! |
| 67 | * \brief Gets this setting's value as a QVariant. |
| 68 | * This is done by calling the SettingsObject's retrieveValue() function. |
| 69 | * If this Setting doesn't have a SettingsObject, this returns an invalid QVariant. |
| 70 | * \return QVariant containing this setting's value. |
| 71 | * \sa value() |
| 72 | */ |
| 73 | virtual QVariant get() const; |
| 74 | |
| 75 | /*! |
| 76 | * \brief Gets this setting's default value. |
| 77 | * \return The default value of this setting. |
| 78 | */ |
| 79 | virtual QVariant defValue() const; |
| 80 | |
| 81 | signals: |
| 82 | /*! |
| 83 | * \brief Signal emitted when this Setting object's value changes. |
| 84 | * \param setting A reference to the Setting that changed. |
| 85 | * \param value This Setting object's new value. |