mirror-chatterino2/src/settingssnapshot.h

34 lines
689 B
C
Raw Normal View History

2017-01-24 19:51:57 +01:00
#ifndef SETTINGSSNAPSHOT_H
#define SETTINGSSNAPSHOT_H
#include "setting.h"
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
};
2017-04-14 17:52:22 +02:00
} // namespace chatterino
2017-01-24 19:51:57 +01:00
#endif // SETTINGSSNAPSHOT_H