2017-12-31 00:50:07 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-06-28 19:38:57 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <pajlada/settings.hpp>
|
|
|
|
|
2017-12-31 00:50:07 +01:00
|
|
|
namespace chatterino {
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-04-14 21:59:51 +02:00
|
|
|
void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
2017-12-31 00:50:07 +01:00
|
|
|
|
|
|
|
template <typename Type>
|
|
|
|
class ChatterinoSetting : public pajlada::Settings::Setting<Type>
|
|
|
|
{
|
|
|
|
public:
|
2018-01-04 01:52:37 +01:00
|
|
|
ChatterinoSetting(const std::string &_path)
|
|
|
|
: pajlada::Settings::Setting<Type>(_path)
|
|
|
|
{
|
|
|
|
_registerSetting(this->data);
|
|
|
|
}
|
|
|
|
|
2017-12-31 00:50:07 +01:00
|
|
|
ChatterinoSetting(const std::string &_path, const Type &_defaultValue)
|
|
|
|
: pajlada::Settings::Setting<Type>(_path, _defaultValue)
|
|
|
|
{
|
|
|
|
_registerSetting(this->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename T2>
|
|
|
|
ChatterinoSetting &operator=(const T2 &newValue)
|
|
|
|
{
|
|
|
|
this->setValue(newValue);
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChatterinoSetting &operator=(Type &&newValue) noexcept
|
|
|
|
{
|
2018-04-22 14:09:38 +02:00
|
|
|
pajlada::Settings::Setting<Type>::operator=(newValue);
|
2017-12-31 00:50:07 +01:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2018-04-22 14:09:38 +02:00
|
|
|
using pajlada::Settings::Setting<Type>::operator==;
|
|
|
|
using pajlada::Settings::Setting<Type>::operator!=;
|
2017-12-31 00:50:07 +01:00
|
|
|
|
2018-04-22 14:09:38 +02:00
|
|
|
using pajlada::Settings::Setting<Type>::operator const Type;
|
2017-12-31 00:50:07 +01:00
|
|
|
};
|
2018-04-03 02:55:32 +02:00
|
|
|
|
2018-06-28 19:38:57 +02:00
|
|
|
using BoolSetting = ChatterinoSetting<bool>;
|
|
|
|
using FloatSetting = ChatterinoSetting<float>;
|
|
|
|
using IntSetting = ChatterinoSetting<int>;
|
|
|
|
using StringSetting = ChatterinoSetting<std::string>;
|
|
|
|
using QStringSetting = ChatterinoSetting<QString>;
|
|
|
|
|
2018-04-03 02:55:32 +02:00
|
|
|
} // namespace chatterino
|