Add "Copy" and "Paste" actions in the "Edit" menu

Also add a "Copy Node(s)" option in the nodes' right click menu.
This commit is contained in:
Candice Bentéjac 2022-08-25 11:10:59 +02:00
parent e11452efdb
commit ede24713d0
2 changed files with 51 additions and 7 deletions

View file

@ -104,13 +104,6 @@ Item {
uigraph.removeNodes(uigraph.selectedNodes)
if (event.key === Qt.Key_D)
duplicateNode(event.modifiers == Qt.AltModifier)
if (event.key === Qt.Key_C)
if (event.modifiers == Qt.ControlModifier)
copyNodes()
if (event.key === Qt.Key_V)
if (event.modifiers == Qt.ControlModifier)
pasteNodes()
}
MouseArea {
@ -407,6 +400,11 @@ Item {
onTriggered: Qt.openUrlExternally(Filepath.stringToUrl(nodeMenu.currentNode.internalFolder))
}
MenuSeparator {}
MenuItem {
text: "Copy Node(s)"
enabled: true
onTriggered: copyNodes()
}
MenuItem {
text: "Duplicate Node(s)" + (duplicateFollowingButton.hovered ? " From Here" : "")
enabled: true

View file

@ -393,6 +393,42 @@ ApplicationWindow {
enabled: _reconstruction.undoStack.canRedo && !_reconstruction.undoStack.lockedRedo
onTriggered: _reconstruction.undoStack.redo()
}
Action {
id: copyAction
property string tooltip: {
var s = "Copy selected node"
s += (_reconstruction.selectedNodes.count > 1 ? "s (" : " (") + getSelectedNodesName()
s += ") to the clipboard"
return s
}
text: "Copy Node" + (_reconstruction.selectedNodes.count > 1 ? "s " : " ")
shortcut: "Ctrl+C"
enabled: _reconstruction.selectedNodes.count > 0
onTriggered: graphEditor.copyNodes()
function getSelectedNodesName()
{
var nodesName = ""
for (var i = 0; i < _reconstruction.selectedNodes.count; i++)
{
if (nodesName !== "")
nodesName += ", "
var node = _reconstruction.selectedNodes.at(i)
nodesName += node.name
}
return nodesName
}
}
Action {
id: pasteAction
property string tooltip: "Paste the clipboard content to the scene if it contains valid nodes"
text: "Paste Node(s)"
shortcut: "Ctrl+V"
onTriggered: graphEditor.pasteNodes()
}
Action {
shortcut: "Ctrl+Shift+P"
@ -568,6 +604,16 @@ ApplicationWindow {
ToolTip.visible: hovered
ToolTip.text: redoAction.tooltip
}
MenuItem {
action: copyAction
ToolTip.visible: hovered
ToolTip.text: copyAction.tooltip
}
MenuItem {
action: pasteAction
ToolTip.visible: hovered
ToolTip.text: pasteAction.tooltip
}
}
Menu {
title: "View"