Change variable names (available -> updatable)

CURA-7609
This commit is contained in:
Kostas Karmas 2020-07-29 17:19:24 +02:00
parent 98cc87d1cf
commit 52ea3e8fcc
3 changed files with 27 additions and 31 deletions

View file

@ -133,12 +133,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# In Cura 2.5 and 2.6, the empty profiles used to have those long names # In Cura 2.5 and 2.6, the empty profiles used to have those long names
self._old_empty_profile_id_dict = {"empty_%s" % k: "empty" for k in ["material", "variant"]} self._old_empty_profile_id_dict = {"empty_%s" % k: "empty" for k in ["material", "variant"]}
# self._is_same_machine_type = False
self._old_new_materials = {} # type: Dict[str, str] self._old_new_materials = {} # type: Dict[str, str]
self._machine_info = None self._machine_info = None
def _clearState(self): def _clearState(self):
# self._is_same_machine_type = False
self._id_mapping = {} self._id_mapping = {}
self._old_new_materials = {} self._old_new_materials = {}
self._machine_info = None self._machine_info = None
@ -229,7 +227,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# Read definition containers # Read definition containers
# #
machine_definition_id = None machine_definition_id = None
available_machines = [] updatable_machines = []
machine_definition_container_count = 0 machine_definition_container_count = 0
extruder_definition_container_count = 0 extruder_definition_container_count = 0
definition_container_files = [name for name in cura_file_names if name.endswith(self._definition_container_suffix)] definition_container_files = [name for name in cura_file_names if name.endswith(self._definition_container_suffix)]
@ -246,9 +244,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
definition_container_type = definition_container.get("type") definition_container_type = definition_container.get("type")
if definition_container_type == "machine": if definition_container_type == "machine":
machine_definition_id = container_id # TODO machine_definition_id = container_id # TODO
my_definition_containers = self._container_registry.findDefinitionContainers(id = machine_definition_id) machine_definition_containers = self._container_registry.findDefinitionContainers(id = machine_definition_id)
available_machines = [i.name for i in self._container_registry.findContainerStacks(type = "machine") if if machine_definition_containers:
i.definition == my_definition_containers[0]] updatable_machines = [machine.name for machine in self._container_registry.findContainerStacks(type = "machine") if machine.definition == machine_definition_containers[0]]
machine_type = definition_container["name"] machine_type = definition_container["name"]
variant_type_name = definition_container.get("variants_name", variant_type_name) variant_type_name = definition_container.get("variants_name", variant_type_name)
@ -390,7 +388,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
machine_definition_id = id_list[7] machine_definition_id = id_list[7]
stacks = self._container_registry.findContainerStacks(name = machine_name, type = "machine") stacks = self._container_registry.findContainerStacks(name = machine_name, type = "machine")
# self._is_same_machine_type = True
existing_global_stack = None existing_global_stack = None
global_stack = None global_stack = None
@ -405,9 +402,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
if global_stack.getContainer(index).getId() != container_id: if global_stack.getContainer(index).getId() != container_id:
machine_conflict = True machine_conflict = True
break break
elif available_machines:
if updatable_machines and not containers_found_dict["machine"]:
containers_found_dict["machine"] = True containers_found_dict["machine"] = True
# self._is_same_machine_type = global_stack.definition.getId() == machine_definition_id
# Get quality type # Get quality type
parser = ConfigParser(interpolation = None) parser = ConfigParser(interpolation = None)
@ -555,9 +552,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
self._machine_info.custom_quality_name = quality_name self._machine_info.custom_quality_name = quality_name
self._machine_info.intent_category = intent_category self._machine_info.intent_category = intent_category
# if machine_conflict and not self._is_same_machine_type:
# machine_conflict = False
is_printer_group = False is_printer_group = False
if machine_conflict: if machine_conflict:
group_name = existing_global_stack.getMetaDataEntry("group_name") group_name = existing_global_stack.getMetaDataEntry("group_name")
@ -578,7 +572,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
self._dialog.setNumSettingsOverriddenByQualityChanges(num_settings_overridden_by_quality_changes) self._dialog.setNumSettingsOverriddenByQualityChanges(num_settings_overridden_by_quality_changes)
self._dialog.setNumUserSettings(num_user_settings) self._dialog.setNumUserSettings(num_user_settings)
self._dialog.setActiveMode(active_mode) self._dialog.setActiveMode(active_mode)
self._dialog.setAvailableMachines(available_machines) self._dialog.setUpdatableMachines(updatable_machines)
self._dialog.setMachineName(machine_name) self._dialog.setMachineName(machine_name)
self._dialog.setMaterialLabels(material_labels) self._dialog.setMaterialLabels(material_labels)
self._dialog.setMachineType(machine_type) self._dialog.setMachineType(machine_type)
@ -659,8 +653,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
application.expandedCategoriesChanged.emit() # Notify the GUI of the change application.expandedCategoriesChanged.emit() # Notify the GUI of the change
# If a machine with the same name is of a different type, always create a new one. # If there are no machines of the same type, create a new machine.
if self._resolve_strategies["machine"] != "override" or not self._dialog.availableMachines: if self._resolve_strategies["machine"] != "override" or not self._dialog.updatableMachines:
# We need to create a new machine # We need to create a new machine
machine_name = self._container_registry.uniqueName(self._machine_info.name) machine_name = self._container_registry.uniqueName(self._machine_info.name)
@ -673,7 +667,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# Find the machine which will be overridden # Find the machine which will be overridden
global_stacks = self._container_registry.findContainerStacks(name = self._dialog.getMachineToOverride(), type = "machine") global_stacks = self._container_registry.findContainerStacks(name = self._dialog.getMachineToOverride(), type = "machine")
if not global_stacks: if not global_stacks:
message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tag <filename>!", "Project file <filename>{0}</filename> is made using profiles that are unknown to this version of Ultimaker Cura.", file_name)) message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tag <filename>!",
"Project file <filename>{0}</filename> is made using profiles that"
" are unknown to this version of Ultimaker Cura.", file_name))
message.show() message.show()
self.setWorkspaceName("") self.setWorkspaceName("")
return [], {} return [], {}

View file

@ -46,7 +46,7 @@ class WorkspaceDialog(QObject):
self._quality_type = "" self._quality_type = ""
self._intent_name = "" self._intent_name = ""
self._machine_name = "" self._machine_name = ""
self._available_machines = [] self._updatable_machines = []
self._machine_type = "" self._machine_type = ""
self._variant_type = "" self._variant_type = ""
self._material_labels = [] self._material_labels = []
@ -65,7 +65,7 @@ class WorkspaceDialog(QObject):
qualityTypeChanged = pyqtSignal() qualityTypeChanged = pyqtSignal()
intentNameChanged = pyqtSignal() intentNameChanged = pyqtSignal()
machineNameChanged = pyqtSignal() machineNameChanged = pyqtSignal()
availableMachinesChanged = pyqtSignal() updatableMachinesChanged = pyqtSignal()
materialLabelsChanged = pyqtSignal() materialLabelsChanged = pyqtSignal()
objectsOnPlateChanged = pyqtSignal() objectsOnPlateChanged = pyqtSignal()
numUserSettingsChanged = pyqtSignal() numUserSettingsChanged = pyqtSignal()
@ -145,18 +145,18 @@ class WorkspaceDialog(QObject):
self._machine_name = machine_name self._machine_name = machine_name
self.machineNameChanged.emit() self.machineNameChanged.emit()
@pyqtProperty("QVariantList", notify = availableMachinesChanged) @pyqtProperty("QVariantList", notify = updatableMachinesChanged)
def availableMachines(self): def updatableMachines(self):
return self._available_machines return self._updatable_machines
def setAvailableMachines(self, available_machines): def setUpdatableMachines(self, updatable_machines):
if self._available_machines != available_machines: if self._updatable_machines != updatable_machines:
self._available_machines = sorted(available_machines) self._updatable_machines = sorted(updatable_machines)
self.availableMachinesChanged.emit() self.updatableMachinesChanged.emit()
@pyqtProperty(int, notify = availableMachinesChanged) @pyqtProperty(int, notify = updatableMachinesChanged)
def availableMachinesCount(self): def updatableMachinesCount(self):
return len(self._available_machines) return len(self._updatable_machines)
@pyqtProperty(str, notify=qualityTypeChanged) @pyqtProperty(str, notify=qualityTypeChanged)
def qualityType(self): def qualityType(self):

View file

@ -105,7 +105,7 @@ UM.Dialog
id: machineResolveStrategyTooltip id: machineResolveStrategyTooltip
width: (parent.width / 3) | 0 width: (parent.width / 3) | 0
height: visible ? comboboxHeight : 0 height: visible ? comboboxHeight : 0
visible: manager.availableMachinesCount != 0 visible: manager.updatableMachinesCount != 0
text: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?") text: catalog.i18nc("@info:tooltip", "How should the conflict in the machine be resolved?")
ComboBox ComboBox
{ {
@ -163,12 +163,12 @@ UM.Dialog
id: machineResolveTooltip id: machineResolveTooltip
width: (parent.width / 3) | 0 width: (parent.width / 3) | 0
height: visible ? comboboxHeight : 0 height: visible ? comboboxHeight : 0
visible: base.visible && manager.availableMachinesCount != 0 && machineResolveStrategyCurrentKey == "override" visible: base.visible && manager.updatableMachinesCount != 0 && machineResolveStrategyCurrentKey == "override"
text: catalog.i18nc("@info:tooltip", "Which machine of the same type should be overriden?") text: catalog.i18nc("@info:tooltip", "Which machine of the same type should be overriden?")
ComboBox ComboBox
{ {
id: selectMachineComboBox id: selectMachineComboBox
model: manager.availableMachines model: manager.updatableMachines
width: parent.width width: parent.width
onCurrentIndexChanged: onCurrentIndexChanged:
{ {