Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_image_change_layers_command.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org>
3 * SPDX-FileCopyrightText: 2007 Sven Langkamp <sven.langkamp@gmail.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
7
9#include "kis_image.h"
10#include "kis_group_layer.h"
11
12#include <klocalizedstring.h>
13
14
16 : KisImageCommand(kundo2_noi18n("change-layer-command"), image)
17{
18 m_oldRootLayer = oldRootLayer;
19 m_newRootLayer = newRootLayer;
20}
21
23{
25 if (image) {
26 image->setRootLayer(static_cast<KisGroupLayer*>(m_newRootLayer.data()));
27 image->refreshGraphAsync();
28 image->notifyLayersChanged();
29 }
30}
31
33{
35 if (image) {
36 image->setRootLayer(static_cast<KisGroupLayer*>(m_oldRootLayer.data()));
37 image->refreshGraphAsync();
38 image->notifyLayersChanged();
39 }
40}
KisImageChangeLayersCommand(KisImageWSP image, KisNodeSP oldRootLayer, KisNodeSP newRootLayer)
the base command for commands altering a KisImage
void refreshGraphAsync(KisNodeSP root, const QVector< QRect > &rects, const QRect &cropRect, KisProjectionUpdateFlags flags=KisProjectionUpdateFlag::None) override
void notifyLayersChanged()
use if the layers have changed completely (eg. when flattening)
void setRootLayer(KisGroupLayerSP rootLayer)
KisSharedPtr< T > toStrongRef() const
toStrongRef returns a KisSharedPtr which may be dereferenced.
KUndo2MagicString kundo2_noi18n(const QString &text)