mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
chore: add getOrRegisterSetting function
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
564f120c22
commit
5af06dec85
9 changed files with 23 additions and 28 deletions
|
|
@ -124,3 +124,8 @@ void SettingsObject::connectSignals(const Setting& setting)
|
|||
connect(&setting, &Setting::settingReset, this, &SettingsObject::resetSetting);
|
||||
connect(&setting, SIGNAL(settingReset(Setting)), this, SIGNAL(settingReset(const Setting&)));
|
||||
}
|
||||
|
||||
std::shared_ptr<Setting> SettingsObject::getOrRegisterSetting(const QString& id, QVariant defVal)
|
||||
{
|
||||
return contains(id) ? getSetting(id) : registerSetting(id, defVal);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,16 @@ class SettingsObject : public QObject {
|
|||
*/
|
||||
std::shared_ptr<Setting> getSetting(const QString& id) const;
|
||||
|
||||
/*!
|
||||
* \brief Gets the setting with the given ID.
|
||||
* \brief if is not registered yet it does that
|
||||
* \param id The ID of the setting to get.
|
||||
* \return A pointer to the setting with the given ID.
|
||||
* Returns null if there is no setting with the given ID.
|
||||
* \sa operator []()
|
||||
*/
|
||||
std::shared_ptr<Setting> getOrRegisterSetting(const QString& id, QVariant defVal = QVariant());
|
||||
|
||||
/*!
|
||||
* \brief Gets the value of the setting with the given ID.
|
||||
* \param id The ID of the setting to get.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue