mirror-chatterino2/src/settingssnapshot.hpp

32 lines
620 B
C++
Raw Normal View History

#pragma once
2017-01-24 19:51:57 +01:00
2017-06-11 09:31:45 +02:00
#include "setting.hpp"
2017-01-24 19:51:57 +01:00
2017-04-12 17:46:44 +02:00
namespace chatterino {
2017-01-24 19:51:57 +01:00
2017-04-12 17:46:44 +02:00
struct SettingsSnapshot {
2017-01-24 19:51:57 +01:00
public:
SettingsSnapshot()
2017-04-12 17:46:44 +02:00
: _items()
2017-01-24 19:51:57 +01:00
{
}
2017-04-12 17:46:44 +02:00
void addItem(std::reference_wrapper<BaseSetting> setting, const QVariant &value)
2017-01-24 19:51:57 +01:00
{
2017-04-12 17:46:44 +02:00
_items.push_back(
std::pair<std::reference_wrapper<BaseSetting>, QVariant>(setting.get(), value));
2017-01-24 19:51:57 +01:00
}
2017-04-12 17:46:44 +02:00
void apply()
2017-01-24 19:51:57 +01:00
{
2017-04-12 17:46:44 +02:00
for (auto &item : _items) {
2017-01-24 19:51:57 +01:00
item.first.get().setVariant(item.second);
}
}
2017-04-12 17:46:44 +02:00
private:
std::vector<std::pair<std::reference_wrapper<BaseSetting>, QVariant>> _items;
2017-01-24 19:51:57 +01:00
};
} // namespace chatterino