mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 06:28:59 +08:00
Disable copy paste when either 3mf reader or writer is disabled
CURA-7913
This commit is contained in:
parent
f8b3fb3d67
commit
c393d915d7
@ -193,6 +193,9 @@ class CuraActions(QObject):
|
|||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def copy(self) -> None:
|
def copy(self) -> None:
|
||||||
mesh_writer = cura.CuraApplication.CuraApplication.getInstance().getMeshFileHandler().getWriter("3MFWriter")
|
mesh_writer = cura.CuraApplication.CuraApplication.getInstance().getMeshFileHandler().getWriter("3MFWriter")
|
||||||
|
if not mesh_writer:
|
||||||
|
Logger.log("e", "No 3MF writer found, unable to copy.")
|
||||||
|
return
|
||||||
|
|
||||||
# Get the selected nodes
|
# Get the selected nodes
|
||||||
selected_objects = Selection.getAllSelectedObjects()
|
selected_objects = Selection.getAllSelectedObjects()
|
||||||
@ -204,11 +207,14 @@ class CuraActions(QObject):
|
|||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def paste(self) -> None:
|
def paste(self) -> None:
|
||||||
application = cura.CuraApplication.CuraApplication.getInstance()
|
application = cura.CuraApplication.CuraApplication.getInstance()
|
||||||
|
mesh_reader = application.getMeshFileHandler().getReaderForFile(".3mf")
|
||||||
|
if not mesh_reader:
|
||||||
|
Logger.log("e", "No 3MF reader found, unable to paste.")
|
||||||
|
return
|
||||||
|
|
||||||
# Parse the scene from the clipboard
|
# Parse the scene from the clipboard
|
||||||
scene_string = QApplication.clipboard().text()
|
scene_string = QApplication.clipboard().text()
|
||||||
|
|
||||||
mesh_reader = application.getMeshFileHandler().getReaderForFile(".3mf")
|
|
||||||
nodes = mesh_reader.stringToSceneNodes(scene_string)
|
nodes = mesh_reader.stringToSceneNodes(scene_string)
|
||||||
|
|
||||||
# Find all fixed nodes, these are the nodes that should be avoided when arranging
|
# Find all fixed nodes, these are the nodes that should be avoided when arranging
|
||||||
|
@ -6,7 +6,7 @@ pragma Singleton
|
|||||||
import QtQuick 2.10
|
import QtQuick 2.10
|
||||||
import QtQuick.Controls 2.4
|
import QtQuick.Controls 2.4
|
||||||
import UM 1.1 as UM
|
import UM 1.1 as UM
|
||||||
import Cura 1.0 as Cura
|
import Cura 1.5 as Cura
|
||||||
|
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
@ -75,6 +75,11 @@ Item
|
|||||||
property alias copy: copyAction
|
property alias copy: copyAction
|
||||||
property alias cut: cutAction
|
property alias cut: cutAction
|
||||||
|
|
||||||
|
readonly property bool copy_paste_enabled: {
|
||||||
|
const all_enabled_packages = CuraApplication.getPackageManager().allEnabledPackages;
|
||||||
|
return all_enabled_packages.includes("3MFReader") && all_enabled_packages.includes("3MFWriter");
|
||||||
|
}
|
||||||
|
|
||||||
UM.I18nCatalog{id: catalog; name: "cura"}
|
UM.I18nCatalog{id: catalog; name: "cura"}
|
||||||
|
|
||||||
|
|
||||||
@ -318,7 +323,7 @@ Item
|
|||||||
id: copyAction
|
id: copyAction
|
||||||
text: catalog.i18nc("@action:inmenu menubar:edit", "Copy to clipboard")
|
text: catalog.i18nc("@action:inmenu menubar:edit", "Copy to clipboard")
|
||||||
onTriggered: CuraActions.copy()
|
onTriggered: CuraActions.copy()
|
||||||
enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection
|
enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection && copy_paste_enabled
|
||||||
shortcut: StandardKey.Copy
|
shortcut: StandardKey.Copy
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +332,7 @@ Item
|
|||||||
id: pasteAction
|
id: pasteAction
|
||||||
text: catalog.i18nc("@action:inmenu menubar:edit", "Paste from clipboard")
|
text: catalog.i18nc("@action:inmenu menubar:edit", "Paste from clipboard")
|
||||||
onTriggered: CuraActions.paste()
|
onTriggered: CuraActions.paste()
|
||||||
enabled: UM.Controller.toolsEnabled
|
enabled: UM.Controller.toolsEnabled && copy_paste_enabled
|
||||||
shortcut: StandardKey.Paste
|
shortcut: StandardKey.Paste
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -336,7 +341,7 @@ Item
|
|||||||
id: cutAction
|
id: cutAction
|
||||||
text: catalog.i18nc("@action:inmenu menubar:edit", "Cut")
|
text: catalog.i18nc("@action:inmenu menubar:edit", "Cut")
|
||||||
onTriggered: CuraActions.cut()
|
onTriggered: CuraActions.cut()
|
||||||
enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection
|
enabled: UM.Controller.toolsEnabled && UM.Selection.hasSelection && copy_paste_enabled
|
||||||
shortcut: StandardKey.Cut
|
shortcut: StandardKey.Cut
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user