removing update existing/ create new in case of UCP

also, making sure post processing scripts are not loaded.

CURA-11403
This commit is contained in:
Saumya Jain 2024-03-05 16:37:17 +01:00
parent b119a010ca
commit 8ef7b65710
3 changed files with 47 additions and 36 deletions

View file

@ -117,7 +117,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
self._supported_extensions = [".3mf"] self._supported_extensions = [".3mf"]
self._dialog = WorkspaceDialog() self._dialog = WorkspaceDialog()
self._3mf_mesh_reader = None self._3mf_mesh_reader = None
self._is_ucp = False self._is_ucp = None
self._container_registry = ContainerRegistry.getInstance() self._container_registry = ContainerRegistry.getInstance()
# suffixes registered with the MimeTypes don't start with a dot '.' # suffixes registered with the MimeTypes don't start with a dot '.'
@ -208,6 +208,15 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
raise FileNotFoundError("No global stack file found!") raise FileNotFoundError("No global stack file found!")
return global_stack_file_list[0], extruder_stack_file_list return global_stack_file_list[0], extruder_stack_file_list
def _isProjectUcp(self, file_name) -> bool:
if self._is_ucp == None:
archive = zipfile.ZipFile(file_name, "r")
cura_file_names = [name for name in archive.namelist() if name.startswith("Cura/")]
self._is_ucp =True if USER_SETTINGS_PATH in cura_file_names else False
def getIsProjectUcp(self) -> bool:
return self._is_ucp
def preRead(self, file_name, show_dialog=True, *args, **kwargs): def preRead(self, file_name, show_dialog=True, *args, **kwargs):
"""Read some info so we can make decisions """Read some info so we can make decisions
@ -217,7 +226,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
we don't want to show a dialog. we don't want to show a dialog.
""" """
self._clearState() self._clearState()
self._isProjectUcp(file_name)
self._3mf_mesh_reader = Application.getInstance().getMeshFileHandler().getReaderForFile(file_name) self._3mf_mesh_reader = Application.getInstance().getMeshFileHandler().getReaderForFile(file_name)
if self._3mf_mesh_reader and self._3mf_mesh_reader.preRead(file_name) == WorkspaceReader.PreReadResult.accepted: if self._3mf_mesh_reader and self._3mf_mesh_reader.preRead(file_name) == WorkspaceReader.PreReadResult.accepted:
pass pass
@ -933,7 +942,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
base_file_name = os.path.basename(file_name) base_file_name = os.path.basename(file_name)
self.setWorkspaceName(base_file_name) self.setWorkspaceName(base_file_name)
self._is_ucp = False self._is_ucp = None
return nodes, self._loadMetadata(file_name) return nodes, self._loadMetadata(file_name)
@staticmethod @staticmethod
@ -1312,6 +1321,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
machine_manager.setActiveMachine(global_stack.getId()) machine_manager.setActiveMachine(global_stack.getId())
# Set metadata fields that are missing from the global stack # Set metadata fields that are missing from the global stack
if not self._is_ucp:
for key, value in self._machine_info.metadata_dict.items(): for key, value in self._machine_info.metadata_dict.items():
if key not in global_stack.getMetaData() and key not in _ignored_machine_network_metadata: if key not in global_stack.getMetaData() and key not in _ignored_machine_network_metadata:
global_stack.setMetaDataEntry(key, value) global_stack.setMetaDataEntry(key, value)

View file

@ -253,7 +253,7 @@ UM.Dialog
id: qualityChangesResolveComboBox id: qualityChangesResolveComboBox
model: resolveStrategiesModel model: resolveStrategiesModel
textRole: "label" textRole: "label"
visible: manager.qualityChangesConflict visible: manager.qualityChangesConflict && !manager.isUcp
contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
textFont: UM.Theme.getFont("medium") textFont: UM.Theme.getFont("medium")
@ -307,7 +307,7 @@ UM.Dialog
id: materialResolveComboBox id: materialResolveComboBox
model: resolveStrategiesModel model: resolveStrategiesModel
textRole: "label" textRole: "label"
visible: manager.materialConflict visible: manager.materialConflict && !manager.isUcp
contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width contentLeftPadding: UM.Theme.getSize("default_margin").width + UM.Theme.getSize("narrow_margin").width
textFont: UM.Theme.getFont("medium") textFont: UM.Theme.getFont("medium")

View file

@ -84,7 +84,8 @@ Item
{ {
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: comboboxLabel.verticalCenter anchors.verticalCenter: comboboxLabel.verticalCenter
color: UM.Theme.getColor("small_button_text")
icon: UM.Theme.getIcon("Information")
text: comboboxTooltipText text: comboboxTooltipText
visible: comboboxTooltipText != "" visible: comboboxTooltipText != ""
} }