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-07-06 18:10:21 +02:00
|
|
|
ChatterinoSetting(const std::string &path)
|
|
|
|
: pajlada::Settings::Setting<Type>(path)
|
2018-01-04 01:52:37 +01:00
|
|
|
{
|
|
|
|
_registerSetting(this->data);
|
|
|
|
}
|
|
|
|
|
2018-07-06 18:10:21 +02:00
|
|
|
ChatterinoSetting(const std::string &path, const Type &defaultValue)
|
|
|
|
: pajlada::Settings::Setting<Type>(path, defaultValue)
|
2017-12-31 00:50:07 +01:00
|
|
|
{
|
|
|
|
_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
|