Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/kis_change_file_layer_command.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2017 Wolthera van Hövell tot Westerflier<griffinvalley@mail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | #ifndef KIS_CHANGE_FILE_LAYER_COMMAND_H | ||||
19 | #define KIS_CHANGE_FILE_LAYER_COMMAND_H | ||||
20 | #include <kundo2command.h> | ||||
21 | #include "kis_types.h" | ||||
22 | #include "kis_file_layer.h" | ||||
23 | class KisChangeFileLayerCmd : public KUndo2Command | ||||
24 | { | ||||
25 | | ||||
26 | public: | ||||
27 | KisChangeFileLayerCmd(KisFileLayerSP fileLayer, | ||||
28 | const QString &oldPath, | ||||
29 | const QString &oldFileName, | ||||
30 | const KisFileLayer::ScalingMethod &oldMethod, | ||||
31 | const QString &newPath, | ||||
32 | const QString &newFileName, | ||||
33 | const KisFileLayer::ScalingMethod &newMethod) | ||||
34 | : KUndo2Command(kundo2_i18n("Change File Layer")) { | ||||
35 | m_node = fileLayer; | ||||
36 | | ||||
37 | m_oldPath = oldPath; | ||||
38 | m_newPath = newPath; | ||||
39 | m_oldFileName = oldFileName; | ||||
40 | m_newFileName = newFileName; | ||||
41 | m_oldMethod = oldMethod; | ||||
42 | m_newMethod = newMethod; | ||||
43 | } | ||||
44 | public: | ||||
45 | void redo() override { | ||||
46 | // setFileName() automatically issues a setDirty call | ||||
47 | m_node->setScalingMethod(m_newMethod); | ||||
48 | m_node->setFileName(m_newPath, m_newFileName); | ||||
49 | } | ||||
50 | | ||||
51 | void undo() override { | ||||
52 | // setFileName() automatically issues a setDirty call | ||||
53 | m_node->setScalingMethod(m_oldMethod); | ||||
54 | m_node->setFileName(m_oldPath, m_oldFileName); | ||||
55 | } | ||||
56 | private: | ||||
57 | KisFileLayerSP m_node; | ||||
58 | | ||||
59 | QString m_oldPath; | ||||
60 | QString m_newPath; | ||||
61 | QString m_oldFileName; | ||||
62 | QString m_newFileName; | ||||
63 | KisFileLayer::ScalingMethod m_oldMethod; | ||||
64 | KisFileLayer::ScalingMethod m_newMethod; | ||||
65 | }; | ||||
66 | #endif // KIS_CHANGE_FILE_LAYER_COMMAND_H |