File indexing completed on 2024-05-12 15:59:02

0001 /*
0002  * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #ifndef AnimationCHECK_H
0008 #define AnimationCHECK_H
0009 
0010 #include "KisExportCheckRegistry.h"
0011 #include <KoID.h>
0012 #include <klocalizedstring.h>
0013 #include <kis_image.h>
0014 #include <kis_image_animation_interface.h>
0015 #include <KoColorSpace.h>
0016 
0017 class AnimationCheck : public KisExportCheckBase
0018 {
0019 public:
0020 
0021     AnimationCheck(const QString &id, Level level, const QString &customWarning = QString())
0022         : KisExportCheckBase(id, level, customWarning, true)
0023     {
0024         if (customWarning.isEmpty()) {
0025             m_warning = i18nc("image conversion warning", "This image has <b>animated layers</b>. Animation cannot be saved to this format.");
0026         }
0027     }
0028 
0029     bool checkNeeded(KisImageSP image) const override
0030     {
0031         return image->animationInterface()->hasAnimation();
0032     }
0033 
0034     Level check(KisImageSP /*image*/) const override
0035     {
0036         return m_level;
0037     }
0038 };
0039 
0040 class AnimationCheckFactory : public KisExportCheckFactory
0041 {
0042 public:
0043 
0044     AnimationCheckFactory() {}
0045 
0046     ~AnimationCheckFactory() override {}
0047 
0048     KisExportCheckBase *create(KisExportCheckBase::Level level, const QString &customWarning) override
0049     {
0050         return new AnimationCheck(id(), level, customWarning);
0051     }
0052 
0053     QString id() const override {
0054         return "AnimationCheck";
0055     }
0056 };
0057 
0058 #endif // AnimationCHECK_H