Krita Source Code Documentation
Loading...
Searching...
No Matches
MultiTransparencyMaskCheck.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 Srirupa Datta <srirupa.sps@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
7#ifndef MultiTransparencyMaskCheck_H
8#define MultiTransparencyMaskCheck_H
9
11#include <KoID.h>
12#include <klocalizedstring.h>
13#include <kis_image.h>
14#include <kis_group_layer.h>
15#include <kis_layer_utils.h>
16
18{
19public:
20
21 MultiTransparencyMaskCheck(const QString &id, Level level, const QString &customWarning = QString())
22 : KisExportCheckBase(id, level, customWarning, true)
23 {
24 if (customWarning.isEmpty()) {
25 m_warning = i18nc("image conversion warning", "The image has <b>more than one transparency mask on a layer</b>. For all layers that have multiple transparency masks, only the rendered result will be saved.");
26 }
27 }
28
29 bool checkNeeded(KisImageSP image) const override
30 {
32 [] (KisNodeSP node)
33 {
34 quint32 transparencyMasks = 0;
35 KisNodeSP mask;
36
37 for (mask = node->firstChild(); mask != 0; mask = mask->nextSibling()) {
38 if (mask->inherits("KisTransparencyMask")) {
39 transparencyMasks += 1;
40 if (transparencyMasks > 1) {
41 return true;
42 }
43 }
44 }
45
46 return false;
47 });
48
49 return (layer != 0);
50 }
51
52 Level check(KisImageSP /*image*/) const override
53 {
54 return m_level;
55 }
56
57};
58
60{
61public:
62
64
66
67 KisExportCheckBase *create(KisExportCheckBase::Level level, const QString &customWarning) override
68 {
69 return new MultiTransparencyMaskCheck(id(), level, customWarning);
70 }
71
72 QString id() const override {
73 return "MultiTransparencyMaskCheck";
74 }
75};
76
77#endif // MultiTransparencyMaskCheck_H
The KisExportCheckBase class defines the interface of the individual checks of an export filter's cap...
virtual QString id() const
KisGroupLayerSP rootLayer() const
KisExportCheckBase * create(KisExportCheckBase::Level level, const QString &customWarning) override
MultiTransparencyMaskCheck(const QString &id, Level level, const QString &customWarning=QString())
bool checkNeeded(KisImageSP image) const override
Level check(KisImageSP) const override
KisNodeSP recursiveFindNode(KisNodeSP node, std::function< bool(KisNodeSP)> func)