Krita Source Code Documentation
Loading...
Searching...
No Matches
NodeTypeCheck.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef NodeTypeCheck_H
8#define NodeTypeCheck_H
9
11#include <KoID.h>
12#include <klocalizedstring.h>
13#include <kis_image.h>
14#include <kis_count_visitor.h>
15
17{
18public:
19
20 NodeTypeCheck(const QString &nodeType, const QString &description, const QString &id, Level level, const QString &customWarning = QString())
21 : KisExportCheckBase(id, level, customWarning, true)
23 {
24 if (customWarning.isEmpty()) {
25 m_warning = i18nc("image conversion warning", "The image contains layers of unsupported type <b>%1</b>. Only the rendered result will be saved.", description);
26 }
27 }
28
29 bool checkNeeded(KisImageSP image) const override
30 {
31 QStringList nodetypes = QStringList() << m_nodeType;
32 KoProperties props;
33 KisCountVisitor v(nodetypes, props);
34 image->rootLayer()->accept(v);
35
36 // There is always one group layer, the root layer. When checking
37 // selection masks, discount the global selection mask, since that's
38 // ephemeral and not worth warning about.
39 if (m_nodeType == QStringLiteral("KisGroupLayer")
40 || (m_nodeType == QStringLiteral("KisSelectionMask") && image->rootLayer()->selectionMask())) {
41 return (v.count() > 1);
42 }
43 else {
44 return (v.count() > 0);
45 }
46 }
47
48 Level check(KisImageSP /*image*/) const override
49 {
50 return m_level;
51 }
52
53 QString m_nodeType;
54};
55
57{
58public:
59
60 NodeTypeCheckFactory(const QString &nodeType, const QString &description)
62 , m_description(description)
63 {}
64
66
67 KisExportCheckBase *create(KisExportCheckBase::Level level, const QString &customWarning) override
68 {
69 return new NodeTypeCheck(m_nodeType, m_description, id(), level, customWarning);
70 }
71
72 QString id() const override {
73 return "NodeTypeCheck/" + m_nodeType;
74 }
75
76 QString m_nodeType;
78
79};
80
81#endif // NodeTypeCheck_H
qreal v
QList< QString > QStringList
char nodeType(const KoPathPoint *point)
The KisExportCheckBase class defines the interface of the individual checks of an export filter's cap...
virtual QString id() const
KisGroupLayerSP rootLayer() const
NodeTypeCheckFactory(const QString &nodeType, const QString &description)
KisExportCheckBase * create(KisExportCheckBase::Level level, const QString &customWarning) override
~NodeTypeCheckFactory() override
QString id() const override
Level check(KisImageSP) const override
QString m_nodeType
NodeTypeCheck(const QString &nodeType, const QString &description, const QString &id, Level level, const QString &customWarning=QString())
bool checkNeeded(KisImageSP image) const override
bool accept(KisNodeVisitor &v) override
virtual KisSelectionMaskSP selectionMask() const
Definition kis_layer.cc:504