Remember Popped-up Chat Size (#5635)

This commit is contained in:
maliByatzes
2024-10-12 12:35:39 +02:00
committed by GitHub
parent bc1850ce2d
commit 2d818a7657
5 changed files with 73 additions and 2 deletions
+52
View File
@@ -0,0 +1,52 @@
#pragma once
#include "util/RapidjsonHelpers.hpp"
#include <pajlada/serialize.hpp>
#include <QSize>
namespace pajlada {
template <>
struct Serialize<QSize> {
static rapidjson::Value get(const QSize &value,
rapidjson::Document::AllocatorType &a)
{
rapidjson::Value ret(rapidjson::kObjectType);
chatterino::rj::set(ret, "width", value.width(), a);
chatterino::rj::set(ret, "height", value.height(), a);
return ret;
}
};
template <>
struct Deserialize<QSize> {
static QSize get(const rapidjson::Value &value, bool *error = nullptr)
{
if (!value.IsObject())
{
PAJLADA_REPORT_ERROR(error);
return {};
}
int width{};
int height{};
if (!chatterino::rj::getSafe(value, "width", width))
{
PAJLADA_REPORT_ERROR(error);
return {};
}
if (!chatterino::rj::getSafe(value, "height", height))
{
PAJLADA_REPORT_ERROR(error);
return {};
}
return {width, height};
}
};
} // namespace pajlada