Krita Source Code Documentation
Loading...
Searching...
No Matches
FillLayerTypeCheck.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef FILLLAYERTYPECHECK_H
8#define FILLLAYERTYPECHECK_H
9
10
12#include <KoID.h>
13#include <klocalizedstring.h>
14#include <kis_assert.h>
15#include <kis_image.h>
17#include <kis_generator_layer.h>
18#include <kis_node_visitor.h>
19#include <kis_group_layer.h>
20
21
23{
24public:
25
27
28 FillLayerTypeCheckVisitor (QString fillLayerID)
29 : m_count(0)
30 , m_fillLayerID(fillLayerID)
31 {
32 }
33
34 quint32 count() {
35 return m_count;
36 }
37
38 bool visit(KisNode*) override {return true;}
39
40 bool visit(KisPaintLayer *) override {return true;}
41
42 bool visit(KisGroupLayer *layer) override {
43 return visitAll(layer);
44 }
45
46
47 bool visit(KisAdjustmentLayer *) override {return true;}
48
49 bool visit(KisExternalLayer *) override {return true;}
50
51 bool visit(KisCloneLayer *) override {return true;}
52
53 bool visit(KisGeneratorLayer * layer) override {
54 return check(layer);
55 }
56
57 bool visit(KisFilterMask *) override {return true;}
58
59 bool visit(KisTransformMask *) override {return true;}
60
61 bool visit(KisTransparencyMask *) override {return true;}
62
63 bool visit(KisSelectionMask *) override {return true;}
64
65 bool visit(KisColorizeMask *) override {return true;}
66
67
68private:
69 bool check(KisGeneratorLayer * node) {
70 if (node->filter()->name() == m_fillLayerID) {
71 m_count++;
72 }
73 return true;
74 }
75
76 quint32 m_count;
77 const QString m_fillLayerID;
78
79};
80
81
83{
84public:
85
86 FillLayerTypeCheck(const QString &generatorID, const QString &id, Level level, const QString &customWarning = QString())
87 : KisExportCheckBase(id, level, customWarning),
88 m_fillLayerID(generatorID)
89 {
90 if (customWarning.isEmpty()) {
91 QString name = KisGeneratorRegistry::instance()->get(generatorID)->name();
92 m_warning = i18nc("image conversion warning", "The image contains a Fill Layer of type <b>%1</b>, which is not supported, the layer will be converted to a paintlayer", name);
93 }
94 }
95
96 bool checkNeeded(KisImageSP image) const override
97 {
99 image->rootLayer()->accept(v);
100 return (v.count() > 0);
101 }
102
103 Level check(KisImageSP /*image*/) const override
104 {
105 return m_level;
106 }
107
108 const QString m_fillLayerID;
109};
110
112{
113public:
114
115 FillLayerTypeCheckFactory(const QString &generatorID)
116 : m_fillLayerID(generatorID)
117 {
118 }
119
121
122 KisExportCheckBase *create(KisExportCheckBase::Level level, const QString &customWarning) override
123 {
124 return new FillLayerTypeCheck(m_fillLayerID, id(), level, customWarning);
125 }
126
127 QString id() const override {
128 return "FillLayerTypeCheck/" + m_fillLayerID;
129 }
130
131 const QString m_fillLayerID;
132};
133#endif // FILLLAYERTYPECHECK_H
qreal v
QString id() const override
KisExportCheckBase * create(KisExportCheckBase::Level level, const QString &customWarning) override
FillLayerTypeCheckFactory(const QString &generatorID)
FillLayerTypeCheckVisitor(QString fillLayerID)
bool visit(KisNode *) override
bool visit(KisSelectionMask *) override
bool visit(KisFilterMask *) override
bool visit(KisGeneratorLayer *layer) override
bool check(KisGeneratorLayer *node)
bool visit(KisPaintLayer *) override
bool visit(KisCloneLayer *) override
bool visit(KisExternalLayer *) override
bool visit(KisTransformMask *) override
bool visit(KisAdjustmentLayer *) override
bool visit(KisGroupLayer *layer) override
bool visit(KisColorizeMask *) override
bool visit(KisTransparencyMask *) override
const QString m_fillLayerID
FillLayerTypeCheck(const QString &generatorID, const QString &id, Level level, const QString &customWarning=QString())
bool checkNeeded(KisImageSP image) const override
Level check(KisImageSP) const override
The KisExportCheckBase class defines the interface of the individual checks of an export filter's cap...
virtual QString id() const
static KisGeneratorRegistry * instance()
KisGroupLayerSP rootLayer() const
virtual KisFilterConfigurationSP filter() const
virtual bool visit(KisNode *node)=0
bool visitAll(KisNode *node, bool breakOnFail=false)
T get(const QString &id) const
bool accept(KisNodeVisitor &v) override