Krita Source Code Documentation
Loading...
Searching...
No Matches
KisReselectActiveSelectionCommand.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include "kis_image.h"
10#include "kis_node.h"
11#include "kis_layer.h"
12#include "kis_selection_mask.h"
13#include <KoProperties.h>
14
15
21
23{
24 bool shouldReselectFGlobalSelection = true;
25
26 if (m_activeNode) {
28
29 if (!mask) {
30
31 KisLayerSP layer;
33 while (node && !(layer = dynamic_cast<KisLayer*>(node.data()))) {
34 node = node->parent();
35 }
36
37 if (layer && !layer->selectionMask()) {
38 KoProperties properties;
39 properties.setProperty("active", false);
40 properties.setProperty("visible", true);
41 QList<KisNodeSP> masks = layer->childNodes(QStringList("KisSelectionMask"), properties);
42
43 if (!masks.isEmpty()) {
44 mask = dynamic_cast<KisSelectionMask*>(masks.first().data());
45 }
46 } else if (layer && layer->selectionMask()) {
47 shouldReselectFGlobalSelection = false;
48 }
49 }
50
51 if (mask) {
52 mask->setActive(true);
53 shouldReselectFGlobalSelection = false;
54 m_reselectedMask = mask;
55 }
56 }
57
58 if (shouldReselectFGlobalSelection) {
60 }
61}
62
QList< QString > QStringList
KisReselectActiveSelectionCommand(KisNodeSP activeNode, KisImageWSP image, KUndo2Command *parent=0)
The command for deselection the global selection of KisImage.
void setProperty(const QString &name, const QVariant &value)
virtual KisSelectionMaskSP selectionMask() const
Definition kis_layer.cc:498
QList< KisNodeSP > childNodes(const QStringList &nodeTypes, const KoProperties &properties) const
Definition kis_node.cpp:439
KisNodeWSP parent
Definition kis_node.cpp:86
void setActive(bool active)