Krita Source Code Documentation
Loading...
Searching...
No Matches
KisChangeCloneLayersCommand.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Tusooa Zhu <tusooa@vista.aero>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <kis_clone_layer.h>
10
17
19 : KUndo2Command(kundo2_i18n("Change Clone Layers"), parent)
20 , d(new Private())
21{
22 KIS_SAFE_ASSERT_RECOVER_RETURN(!cloneLayers.isEmpty());
23 d->cloneLayers = cloneLayers;
24 Q_FOREACH (KisCloneLayerSP layer, d->cloneLayers) {
25 d->originalSource << layer->copyFrom();
26 }
27 d->newSource = newSource;
28}
29
31{
32 Q_FOREACH (KisCloneLayerSP layer, d->cloneLayers) {
33 layer->setCopyFrom(d->newSource);
34 layer->setDirty();
35 }
36}
37
39{
40 KIS_SAFE_ASSERT_RECOVER_RETURN(d->cloneLayers.size() == d->originalSource.size());
41 for (int i = 0; i < d->cloneLayers.size(); ++i) {
42 KisCloneLayerSP layer = d->cloneLayers.at(i);
43 layer->setCopyFrom(d->originalSource.at(i));
44 layer->setDirty();
45 }
46}
47
49{
50 const KisChangeCloneLayersCommand *other = dynamic_cast<const KisChangeCloneLayersCommand *>(command);
51
52 if (other && d->cloneLayers == other->d->cloneLayers) {
53 d->newSource = other->d->newSource;
54 return true;
55 }
56
57 return false;
58}
bool mergeWith(const KUndo2Command *) override
KisChangeCloneLayersCommand(QList< KisCloneLayerSP > cloneLayers, KisLayerSP newSource, KUndo2Command *parent=0)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
KUndo2MagicString kundo2_i18n(const char *text)