File indexing completed on 2024-05-12 15:59:02
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #ifndef KISEXPORTCHECKBASE_H 0007 #define KISEXPORTCHECKBASE_H 0008 0009 #include <QString> 0010 0011 #include "KoGenericRegistry.h" 0012 0013 #include <kis_types.h> 0014 0015 #include "kritaimpex_export.h" 0016 0017 /** 0018 * @brief The KisExportCheckBase class defines the interface 0019 * of the individual checks of an export filter's capabilities 0020 */ 0021 class KRITAIMPEX_EXPORT KisExportCheckBase 0022 { 0023 public: 0024 0025 /// The level determines the level of support the export 0026 /// filter has for the given feature. 0027 enum Level { 0028 SUPPORTED, //< The filter fully supports this 0029 PARTIALLY, //< The filter can handle this, but the user needs to be warned about possible degradation 0030 UNSUPPORTED //< This cannot be saved using this filter 0031 }; 0032 0033 /** 0034 * @brief KisExportCheckBase 0035 * @param level the level of support the filter has for the given feature 0036 * @param customWarning A custom warning to use instead of the default one 0037 */ 0038 KisExportCheckBase(const QString &id, Level level, const QString &customWarning = QString(), bool perLayerCheck = false); 0039 0040 virtual ~KisExportCheckBase(); 0041 0042 /// @return the unique id of the check 0043 virtual QString id() const; 0044 0045 /// @return whether the image uses this feature 0046 virtual bool checkNeeded(KisImageSP image) const = 0; 0047 0048 /// @returns true if this check is only relevant for file formats that can save multiple layers 0049 virtual bool perLayerCheck() const; 0050 0051 /// @return the level of support for this feature 0052 virtual Level check(KisImageSP image) const = 0; 0053 0054 /// @return the message to show the user 0055 QString warning() const; 0056 0057 protected: 0058 0059 QString m_id; 0060 Level m_level {UNSUPPORTED}; 0061 QString m_warning; 0062 bool m_perLayerCheck {false}; 0063 0064 }; 0065 0066 class KRITAIMPEX_EXPORT KisExportCheckFactory 0067 { 0068 public: 0069 virtual KisExportCheckBase *create(KisExportCheckBase::Level level, const QString &customWarning = QString()) = 0; 0070 virtual ~KisExportCheckFactory() {} 0071 virtual QString id() const = 0; 0072 }; 0073 0074 0075 #endif