[graphics/krita/krita/4.3] libs/ui/actions: Make Ctrl+C/X/V shortcut work with layers when there is nothing else to copy
Dmitry Kazakov
null at kde.org
Fri Aug 14 12:38:10 BST 2020
Git commit f7509a5c5598b0de960e2c3e6deb2bf155cd3acf by Dmitry Kazakov.
Committed on 14/08/2020 at 11:37.
Pushed by dkazakov into branch 'krita/4.3'.
Make Ctrl+C/X/V shortcut work with layers when there is nothing else to copy
The new priority list for copying/cutting:
1) Cut/Copy selected vector shapes
2) Cut/Copy the content of pixel selection
3) Cut/Copy the selected layer
If the user wants to Cut/Copy a layer when there is a selection active,
then he/she should use a special Layer->Cut/Copy Layer menu action instead
of the default shortcut.
BUG:411463
CC:kimageshop at kde.org
M +6 -0 libs/ui/actions/KisPasteActionFactories.cpp
M +13 -10 libs/ui/actions/kis_selection_action_factories.cpp
https://invent.kde.org/graphics/krita/commit/f7509a5c5598b0de960e2c3e6deb2bf155cd3acf
diff --git a/libs/ui/actions/KisPasteActionFactories.cpp b/libs/ui/actions/KisPasteActionFactories.cpp
index 71b3725ff3..afe6218be5 100644
--- a/libs/ui/actions/KisPasteActionFactories.cpp
+++ b/libs/ui/actions/KisPasteActionFactories.cpp
@@ -35,6 +35,7 @@
#include "commands/kis_image_layer_add_command.h"
#include "KisTransformToolActivationCommand.h"
#include "kis_processing_applicator.h"
+#include "kis_node_manager.h"
#include <KoDocumentInfo.h>
#include <KoSvgPaste.h>
@@ -203,6 +204,11 @@ void KisPasteActionFactory::run(bool pasteAtCursorPosition, KisViewManager *view
KisImageSP image = view->image();
if (!image) return;
+ if (KisClipboard::instance()->hasLayers()) {
+ view->nodeManager()->pasteLayersFromClipboard();
+ return;
+ }
+
if (tryPasteShapes(pasteAtCursorPosition, view)) {
return;
}
diff --git a/libs/ui/actions/kis_selection_action_factories.cpp b/libs/ui/actions/kis_selection_action_factories.cpp
index 1ebfe130fd..666a6e35f2 100644
--- a/libs/ui/actions/kis_selection_action_factories.cpp
+++ b/libs/ui/actions/kis_selection_action_factories.cpp
@@ -63,7 +63,7 @@
#include "kis_image_animation_interface.h"
#include "kis_time_range.h"
#include "kis_keyframe_channel.h"
-
+#include "kis_node_manager.h"
#include <processing/fill_processing_visitor.h>
#include <kis_selection_tool_helper.h>
@@ -269,9 +269,12 @@ void KisCutCopyActionFactory::run(bool willCut, bool makeSharpClip, KisViewManag
KisImageSP image = view->image();
if (!image) return;
- bool haveShapesSelected = view->selectionManager()->haveShapesSelected();
+ const bool haveShapesSelected = view->selectionManager()->haveShapesSelected();
- if (haveShapesSelected) {
+ KisNodeSP node = view->activeNode();
+ KisSelectionSP selection = view->selection();
+
+ if (!makeSharpClip && haveShapesSelected) {
// XXX: "Add saving of XML data for Cut/Copy of shapes"
KisImageBarrierLocker locker(image);
@@ -280,13 +283,7 @@ void KisCutCopyActionFactory::run(bool willCut, bool makeSharpClip, KisViewManag
} else {
view->canvasBase()->toolProxy()->copy();
}
- } else {
- KisNodeSP node = view->activeNode();
- if (!node) return;
-
- KisSelectionSP selection = view->selection();
- if (selection.isNull()) return;
-
+ } else if (node && selection) {
{
KisImageBarrierLocker locker(image);
KisPaintDeviceSP dev = node->paintDevice();
@@ -375,6 +372,12 @@ void KisCutCopyActionFactory::run(bool willCut, bool makeSharpClip, KisViewManag
KisOperationConfiguration config(id());
config.setProperty("will-cut", willCut);
endAction(ap, config.toXML());
+ } else if (!makeSharpClip) {
+ if (willCut) {
+ view->nodeManager()->cutLayersToClipboard();
+ } else {
+ view->nodeManager()->copyLayersToClipboard();
+ }
}
}
More information about the kimageshop
mailing list