File indexing completed on 2025-01-05 04:01:16

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 
0010 #include "io/glaxnimate/glaxnimate_mime.hpp"
0011 
0012 namespace glaxnimate::io::mime {
0013 
0014 class JsonMime : public io::mime::MimeSerializer
0015 {
0016 public:
0017     QString slug() const override { return "json"; }
0018     QString name() const override { return i18n("JSON"); }
0019     QStringList mime_types() const override { return {"application/json", "text/plain"}; }
0020 
0021     QByteArray serialize(const std::vector<model::DocumentNode*>& selection) const override
0022     {
0023         QJsonDocument json = io::glaxnimate::GlaxnimateMime::serialize_json(selection);
0024         return json.toJson(QJsonDocument::Indented);
0025     }
0026 
0027     bool can_deserialize() const override { return false; }
0028 
0029 private:
0030     static Autoreg<JsonMime> autoreg;
0031 };
0032 
0033 } // namespace glaxnimate::io::mime