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

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 #include "io/lottie/lottie_html_format.hpp"
0010 #include "io/svg/svg_renderer.hpp"
0011 
0012 namespace glaxnimate::io::svg {
0013 
0014 class SvgHtmlFormat : public ImportExport
0015 {
0016 public:
0017     QString slug() const override { return "svg_html"; }
0018     QString name() const override { return i18n("SVG Preview"); }
0019     QStringList extensions() const override { return {"html", "htm"}; }
0020     bool can_save() const override { return true; }
0021     bool can_open() const override { return false; }
0022 
0023 private:
0024     bool on_save(QIODevice& file, const QString&, model::Composition* comp, const QVariantMap&) override
0025     {
0026         file.write(lottie::LottieHtmlFormat::html_head(this, comp, {}));
0027         file.write("<body><div id='animation'>");
0028         SvgRenderer rend(SMIL, CssFontType::FontFace);
0029         rend.write_main(comp);
0030         rend.write(&file, true);
0031         file.write("</div></body></html>");
0032         return true;
0033 
0034     }
0035 };
0036 
0037 } // namespace glaxnimate::io::svg