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.
37 if (m_nodeType == "KisGroupLayer") {
38 return (v.count() > 1);
39 }
40 else {
41 return (v.count() > 0);
42 }
43 }
44
45 Level check(KisImageSP /*image*/) const override
46 {
47 return m_level;
48 }
49
50 QString m_nodeType;
51};
52
54{
55public:
56
57 NodeTypeCheckFactory(const QString &nodeType, const QString &description)
59 , m_description(description)
60 {}
61
63
64 KisExportCheckBase *create(KisExportCheckBase::Level level, const QString &customWarning) override
65 {
66 return new NodeTypeCheck(m_nodeType, m_description, id(), level, customWarning);
67 }
68
69 QString id() const override {
70 return "NodeTypeCheck/" + m_nodeType;
71 }
72
73 QString m_nodeType;
75
76};
77
78#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