mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Merge, fix qml files. Contributes to CURA-2007.
Merge branch 'feature_quality_changes' into cura-2007 Conflicts: resources/qml/Settings/SettingItem.qml resources/qml/Settings/SettingView.qml
This commit is contained in:
commit
bfabf8d11a
10 changed files with 207 additions and 184 deletions
|
@ -93,10 +93,10 @@ class CuraApplication(QtApplication):
|
|||
self._open_file_queue = [] # Files to open when plug-ins are loaded.
|
||||
|
||||
# Need to do this before ContainerRegistry tries to load the machines
|
||||
SettingDefinition.addSupportedProperty("settable_per_mesh", DefinitionPropertyType.Any, default = True)
|
||||
SettingDefinition.addSupportedProperty("settable_per_extruder", DefinitionPropertyType.Any, default = True)
|
||||
SettingDefinition.addSupportedProperty("settable_per_meshgroup", DefinitionPropertyType.Any, default = True)
|
||||
SettingDefinition.addSupportedProperty("settable_globally", DefinitionPropertyType.Any, default = True)
|
||||
SettingDefinition.addSupportedProperty("settable_per_mesh", DefinitionPropertyType.Any, default = True, read_only = True)
|
||||
SettingDefinition.addSupportedProperty("settable_per_extruder", DefinitionPropertyType.Any, default = True, read_only = True)
|
||||
SettingDefinition.addSupportedProperty("settable_per_meshgroup", DefinitionPropertyType.Any, default = True, read_only = True)
|
||||
SettingDefinition.addSupportedProperty("settable_globally", DefinitionPropertyType.Any, default = True, read_only = True)
|
||||
SettingDefinition.addSupportedProperty("global_inherits_stack", DefinitionPropertyType.Function, default = "-1")
|
||||
SettingDefinition.addSupportedProperty("resolve", DefinitionPropertyType.Function, default = None)
|
||||
SettingDefinition.addSettingType("extruder", None, str, Validator)
|
||||
|
@ -191,6 +191,10 @@ class CuraApplication(QtApplication):
|
|||
empty_quality_container._id = "empty_quality"
|
||||
empty_quality_container.addMetaDataEntry("type", "quality")
|
||||
ContainerRegistry.getInstance().addContainer(empty_quality_container)
|
||||
empty_quality_changes_container = copy.deepcopy(empty_container)
|
||||
empty_quality_changes_container._id = "empty_quality_changes"
|
||||
empty_quality_changes_container.addMetaDataEntry("type", "quality_changes")
|
||||
ContainerRegistry.getInstance().addContainer(empty_quality_changes_container)
|
||||
|
||||
ContainerRegistry.getInstance().load()
|
||||
|
||||
|
@ -311,7 +315,7 @@ class CuraApplication(QtApplication):
|
|||
path = None
|
||||
if instance_type == "material":
|
||||
path = Resources.getStoragePath(self.ResourceTypes.MaterialInstanceContainer, file_name)
|
||||
elif instance_type == "quality":
|
||||
elif instance_type == "quality" or instance_type == "quality_changes":
|
||||
path = Resources.getStoragePath(self.ResourceTypes.QualityInstanceContainer, file_name)
|
||||
elif instance_type == "user":
|
||||
path = Resources.getStoragePath(self.ResourceTypes.UserInstanceContainer, file_name)
|
||||
|
@ -923,3 +927,8 @@ class CuraApplication(QtApplication):
|
|||
self._additional_components[area_id].append(component)
|
||||
|
||||
self.additionalComponentsChanged.emit(area_id)
|
||||
|
||||
@pyqtSlot(str)
|
||||
def log(self, msg):
|
||||
from UM.Logger import Logger
|
||||
Logger.log("d", msg)
|
||||
|
|
|
@ -14,6 +14,8 @@ import UM.Platform
|
|||
import UM.MimeTypeDatabase
|
||||
import UM.Logger
|
||||
|
||||
import cura.Settings
|
||||
|
||||
from UM.MimeTypeDatabase import MimeTypeNotFoundError
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
|
@ -135,12 +137,11 @@ class ContainerManager(QObject):
|
|||
|
||||
merge = containers[0]
|
||||
|
||||
if type(merge) != type(merge_into):
|
||||
if not isinstance(merge, type(merge_into)):
|
||||
UM.Logger.log("w", "Cannot merge two containers of different types")
|
||||
return False
|
||||
|
||||
for key in merge.getAllKeys():
|
||||
merge_into.setProperty(key, "value", merge.getProperty(key, "value"))
|
||||
self._performMerge(merge_into, merge)
|
||||
|
||||
return True
|
||||
|
||||
|
@ -350,6 +351,105 @@ class ContainerManager(QObject):
|
|||
|
||||
return { "status": "success", "message": "Successfully imported container {0}".format(container.getName()) }
|
||||
|
||||
@pyqtSlot(result = bool)
|
||||
def updateQualityChanges(self):
|
||||
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||
|
||||
containers_to_merge = []
|
||||
|
||||
global_quality_changes = global_stack.findContainer(type = "quality_changes")
|
||||
if not global_quality_changes or global_quality_changes.isReadOnly():
|
||||
UM.Logger.log("e", "Could not update quality of a nonexistant or read only quality profile")
|
||||
return False
|
||||
|
||||
cura.Settings.MachineManager.getInstance().blurSettings.emit()
|
||||
|
||||
containers_to_merge.append((global_quality_changes, global_stack.getTop()))
|
||||
|
||||
for extruder in cura.Settings.ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()):
|
||||
quality_changes = extruder.findContainer(type = "quality_changes")
|
||||
if not quality_changes or quality_changes.isReadOnly():
|
||||
UM.Logger.log("e", "Could not update quality of a nonexistant or read only quality profile")
|
||||
return False
|
||||
|
||||
containers_to_merge.append((quality_changes, extruder.getTop()))
|
||||
|
||||
for merge_into, merge in containers_to_merge:
|
||||
self._performMerge(merge_into, merge)
|
||||
|
||||
@pyqtSlot()
|
||||
def clearUserContainers(self):
|
||||
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||
|
||||
cura.Settings.MachineManager.getInstance().blurSettings.emit()
|
||||
|
||||
for extruder in cura.Settings.ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()):
|
||||
extruder.getTop().clear()
|
||||
|
||||
global_stack.getTop().clear()
|
||||
|
||||
@pyqtSlot(result = bool)
|
||||
def createQualityChanges(self):
|
||||
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||
if not global_stack:
|
||||
return False
|
||||
|
||||
quality_container = global_stack.findContainer(type = "quality")
|
||||
if not quality_container:
|
||||
UM.Logger.log("w", "No quality container found in stack %s, cannot create profile", global_stack.getId())
|
||||
return False
|
||||
|
||||
cura.Settings.MachineManager.getInstance().blurSettings.emit()
|
||||
|
||||
unique_name = UM.Settings.ContainerRegistry.getInstance().uniqueName(quality_container.getName())
|
||||
unique_id = unique_name.lower()
|
||||
unique_id.replace(" ", "_")
|
||||
|
||||
stacks = [ s for s in cura.Settings.ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()) ]
|
||||
stacks.insert(0, global_stack)
|
||||
|
||||
for stack in stacks:
|
||||
user_container = stack.getTop()
|
||||
quality_container = stack.findContainer(type = "quality")
|
||||
quality_changes_container = stack.findContainer(type = "quality_changes")
|
||||
if not quality_container or not quality_changes_container:
|
||||
UM.Logger.log("w", "No quality or quality changes container found in stack %s, ignoring it", stack.getId())
|
||||
return False
|
||||
|
||||
new_quality_changes = user_container.duplicate(stack.getId() + "_" + unique_id, unique_name)
|
||||
new_quality_changes.setMetaDataEntry("type", "quality_changes")
|
||||
new_quality_changes.addMetaDataEntry("quality", quality_container.getId())
|
||||
|
||||
if not global_stack.getMetaDataEntry("has_machine_quality"):
|
||||
new_quality_changes.setDefinition(UM.Settings.ContainerRegistry.getInstance().findContainers(id = "fdmprinter")[0])
|
||||
|
||||
if global_stack.getMetaDataEntry("has_materials"):
|
||||
material = stack.findContainer(type = "material")
|
||||
new_quality_changes.addMetaDataEntry("material", material.getId())
|
||||
|
||||
UM.Settings.ContainerRegistry.getInstance().addContainer(new_quality_changes)
|
||||
|
||||
stack.replaceContainer(stack.getContainerIndex(quality_changes_container), new_quality_changes)
|
||||
stack.getTop().clear()
|
||||
|
||||
return True
|
||||
|
||||
# Factory function, used by QML
|
||||
@staticmethod
|
||||
def createContainerManager(engine, js_engine):
|
||||
return ContainerManager()
|
||||
|
||||
def _performMerge(self, merge_into, merge):
|
||||
assert isinstance(merge, type(merge_into))
|
||||
|
||||
if merge == merge_into:
|
||||
return
|
||||
|
||||
for key in merge.getAllKeys():
|
||||
merge_into.setProperty(key, "value", merge.getProperty(key, "value"))
|
||||
|
||||
merge.clear()
|
||||
|
||||
def _updateContainerNameFilters(self):
|
||||
self._container_name_filters = {}
|
||||
for plugin_id, container_type in UM.Settings.ContainerRegistry.getContainerTypes():
|
||||
|
@ -393,8 +493,3 @@ class ContainerManager(QObject):
|
|||
|
||||
name_filter = "{0} ({1})".format(mime_type.comment, suffix_list)
|
||||
self._container_name_filters[name_filter] = entry
|
||||
|
||||
# Factory function, used by QML
|
||||
@staticmethod
|
||||
def createContainerManager(engine, js_engine):
|
||||
return ContainerManager()
|
||||
|
|
|
@ -235,6 +235,9 @@ class ExtruderManager(QObject):
|
|||
|
||||
container_stack.addContainer(quality)
|
||||
|
||||
empty_quality_changes = container_registry.findInstanceContainers(id = "empty_quality_changes")[0]
|
||||
container_stack.addContainer(empty_quality_changes)
|
||||
|
||||
user_profile = container_registry.findInstanceContainers(type = "user", extruder = extruder_stack_id)
|
||||
if user_profile: # There was already a user profile, loaded from settings.
|
||||
user_profile = user_profile[0]
|
||||
|
|
|
@ -26,6 +26,10 @@ class MachineManager(QObject):
|
|||
self._global_container_stack = None
|
||||
|
||||
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
||||
self.globalContainerChanged.connect(self.activeMaterialChanged)
|
||||
self.globalContainerChanged.connect(self.activeVariantChanged)
|
||||
self.globalContainerChanged.connect(self.activeQualityChanged)
|
||||
|
||||
self._active_stack_valid = None
|
||||
self._onGlobalContainerChanged()
|
||||
|
||||
|
@ -33,9 +37,7 @@ class MachineManager(QObject):
|
|||
self._onActiveExtruderStackChanged()
|
||||
|
||||
## When the global container is changed, active material probably needs to be updated.
|
||||
self.globalContainerChanged.connect(self.activeMaterialChanged)
|
||||
self.globalContainerChanged.connect(self.activeVariantChanged)
|
||||
self.globalContainerChanged.connect(self.activeQualityChanged)
|
||||
|
||||
ExtruderManager.getInstance().activeExtruderChanged.connect(self.activeMaterialChanged)
|
||||
ExtruderManager.getInstance().activeExtruderChanged.connect(self.activeVariantChanged)
|
||||
ExtruderManager.getInstance().activeExtruderChanged.connect(self.activeQualityChanged)
|
||||
|
@ -47,6 +49,7 @@ class MachineManager(QObject):
|
|||
self._empty_variant_container = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = "empty_variant")[0]
|
||||
self._empty_material_container = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = "empty_material")[0]
|
||||
self._empty_quality_container = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = "empty_quality")[0]
|
||||
self._empty_quality_changes_container = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = "empty_quality_changes")[0]
|
||||
|
||||
Preferences.getInstance().addPreference("cura/active_machine", "")
|
||||
|
||||
|
@ -196,107 +199,18 @@ class MachineManager(QObject):
|
|||
if old_index is not None:
|
||||
extruder_manager.setActiveExtruderIndex(old_index)
|
||||
|
||||
def _onGlobalPropertyChanged(self, key, property_name):
|
||||
if property_name == "value":
|
||||
## We can get recursion issues. So we store a list of keys that we are still handling to prevent this.
|
||||
if key in self._global_event_keys:
|
||||
return
|
||||
self._global_event_keys.add(key)
|
||||
self.globalValueChanged.emit()
|
||||
|
||||
if self._active_container_stack and self._active_container_stack != self._global_container_stack:
|
||||
# Make the global current settings mirror the stack values appropriate for this setting
|
||||
if self._active_container_stack.getProperty("extruder_nr", "value") == int(self._active_container_stack.getProperty(key, "global_inherits_stack")):
|
||||
|
||||
new_value = self._active_container_stack.getProperty(key, "value")
|
||||
self._global_container_stack.getTop().setProperty(key, "value", new_value)
|
||||
|
||||
# Global-only setting values should be set on all extruders and the global stack
|
||||
if not self._global_container_stack.getProperty(key, "settable_per_extruder"):
|
||||
extruder_stacks = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()))
|
||||
target_stack_position = int(self._active_container_stack.getProperty(key, "global_inherits_stack"))
|
||||
if target_stack_position == -1: # Prevent -1 from selecting wrong stack.
|
||||
target_stack = self._active_container_stack
|
||||
else:
|
||||
target_stack = extruder_stacks[target_stack_position]
|
||||
new_value = target_stack.getProperty(key, "value")
|
||||
target_stack_has_user_value = target_stack.getTop().getInstance(key) != None
|
||||
for extruder_stack in extruder_stacks:
|
||||
if extruder_stack != target_stack:
|
||||
if target_stack_has_user_value:
|
||||
extruder_stack.getTop().setProperty(key, "value", new_value)
|
||||
else:
|
||||
# Remove from the value from the other stacks as well, unless the
|
||||
# top value from the other stacklevels is different than the new value
|
||||
for container in extruder_stack.getContainers():
|
||||
if container.__class__ == UM.Settings.InstanceContainer and container.getInstance(key) != None:
|
||||
if container.getProperty(key, "value") != new_value:
|
||||
# It could be that the setting needs to be removed instead of updated.
|
||||
temp = extruder_stack
|
||||
containers = extruder_stack.getContainers()
|
||||
# Ensure we have the entire 'chain'
|
||||
while temp.getNextStack():
|
||||
temp = temp.getNextStack()
|
||||
containers.extend(temp.getContainers())
|
||||
instance_needs_removal = False
|
||||
|
||||
if len(containers) > 1:
|
||||
for index in range(1, len(containers)):
|
||||
deeper_container = containers[index]
|
||||
if deeper_container.getProperty(key, "value") is None:
|
||||
continue # Deeper container does not have the value, so continue.
|
||||
if deeper_container.getProperty(key, "value") == new_value:
|
||||
# Removal will result in correct value, so do that.
|
||||
# We do this to prevent the reset from showing up unneeded.
|
||||
instance_needs_removal = True
|
||||
break
|
||||
else:
|
||||
# Container has the value, but it's not the same. Stop looking.
|
||||
break
|
||||
if instance_needs_removal:
|
||||
extruder_stack.getTop().removeInstance(key)
|
||||
else:
|
||||
extruder_stack.getTop().setProperty(key, "value", new_value)
|
||||
else:
|
||||
# Check if we really need to remove something.
|
||||
if extruder_stack.getProperty(key, "value") != new_value:
|
||||
extruder_stack.getTop().removeInstance(key)
|
||||
break
|
||||
if self._global_container_stack.getProperty(key, "value") != new_value:
|
||||
self._global_container_stack.getTop().setProperty(key, "value", new_value)
|
||||
self._global_event_keys.remove(key)
|
||||
|
||||
if property_name == "global_inherits_stack":
|
||||
if self._active_container_stack and self._active_container_stack != self._global_container_stack:
|
||||
# Update the global user value when the "global_inherits_stack" function points to a different stack
|
||||
extruder_stacks = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()))
|
||||
target_stack_position = int(self._active_container_stack.getProperty(key, "global_inherits_stack"))
|
||||
if target_stack_position == -1: # Prevent -1 from selecting wrong stack.
|
||||
target_stack = self._active_container_stack
|
||||
else:
|
||||
target_stack = extruder_stacks[target_stack_position]
|
||||
|
||||
new_value = target_stack.getProperty(key, "value")
|
||||
if self._global_container_stack.getProperty(key, "value") != new_value:
|
||||
self._global_container_stack.getTop().setProperty(key, "value", new_value)
|
||||
|
||||
if property_name == "validationState":
|
||||
if self._active_stack_valid:
|
||||
changed_validation_state = self._active_container_stack.getProperty(key, property_name)
|
||||
if changed_validation_state in (UM.Settings.ValidatorState.Exception, UM.Settings.ValidatorState.MaximumError, UM.Settings.ValidatorState.MinimumError):
|
||||
self._active_stack_valid = False
|
||||
self.activeValidationChanged.emit()
|
||||
else:
|
||||
has_errors = self._checkStackForErrors(self._active_container_stack)
|
||||
if not has_errors:
|
||||
self._active_stack_valid = True
|
||||
self.activeValidationChanged.emit()
|
||||
|
||||
def _onGlobalContainerChanged(self):
|
||||
if self._global_container_stack:
|
||||
self._global_container_stack.nameChanged.disconnect(self._onMachineNameChanged)
|
||||
self._global_container_stack.containersChanged.disconnect(self._onInstanceContainersChanged)
|
||||
self._global_container_stack.propertyChanged.disconnect(self._onGlobalPropertyChanged)
|
||||
|
||||
material = self._global_container_stack.findContainer({"type": "material"})
|
||||
material.nameChanged.disconnect(self._onMaterialNameChanged)
|
||||
|
@ -313,7 +227,6 @@ class MachineManager(QObject):
|
|||
Preferences.getInstance().setValue("cura/active_machine", self._global_container_stack.getId())
|
||||
self._global_container_stack.nameChanged.connect(self._onMachineNameChanged)
|
||||
self._global_container_stack.containersChanged.connect(self._onInstanceContainersChanged)
|
||||
self._global_container_stack.propertyChanged.connect(self._onGlobalPropertyChanged)
|
||||
material = self._global_container_stack.findContainer({"type": "material"})
|
||||
material.nameChanged.connect(self._onMaterialNameChanged)
|
||||
|
||||
|
@ -324,11 +237,9 @@ class MachineManager(QObject):
|
|||
self.blurSettings.emit() # Ensure no-one has focus.
|
||||
if self._active_container_stack and self._active_container_stack != self._global_container_stack:
|
||||
self._active_container_stack.containersChanged.disconnect(self._onInstanceContainersChanged)
|
||||
self._active_container_stack.propertyChanged.disconnect(self._onGlobalPropertyChanged)
|
||||
self._active_container_stack = ExtruderManager.getInstance().getActiveExtruderStack()
|
||||
if self._active_container_stack:
|
||||
self._active_container_stack.containersChanged.connect(self._onInstanceContainersChanged)
|
||||
self._active_container_stack.propertyChanged.connect(self._onGlobalPropertyChanged)
|
||||
else:
|
||||
self._active_container_stack = self._global_container_stack
|
||||
self._active_stack_valid = not self._checkStackForErrors(self._active_container_stack)
|
||||
|
@ -337,16 +248,7 @@ class MachineManager(QObject):
|
|||
def _onInstanceContainersChanged(self, container):
|
||||
container_type = container.getMetaDataEntry("type")
|
||||
|
||||
if self._active_container_stack and self._active_container_stack != self._global_container_stack:
|
||||
if int(self._active_container_stack.getProperty("extruder_nr", "value")) == 0:
|
||||
global_container = self._global_container_stack.findContainer({"type": container_type})
|
||||
if global_container and global_container != container:
|
||||
container_index = self._global_container_stack.getContainerIndex(global_container)
|
||||
self._global_container_stack.replaceContainer(container_index, container)
|
||||
|
||||
for key in container.getAllKeys():
|
||||
# Make sure the values in this profile are distributed to other stacks if necessary
|
||||
self._onGlobalPropertyChanged(key, "value")
|
||||
|
||||
if container_type == "material":
|
||||
self.activeMaterialChanged.emit()
|
||||
|
@ -382,7 +284,6 @@ class MachineManager(QObject):
|
|||
current_settings_instance_container.setDefinition(definitions[0])
|
||||
container_registry.addContainer(current_settings_instance_container)
|
||||
|
||||
# If a definition is found, its a list. Should only have one item.
|
||||
new_global_stack.addContainer(definition)
|
||||
if variant_instance_container:
|
||||
new_global_stack.addContainer(variant_instance_container)
|
||||
|
@ -390,6 +291,8 @@ class MachineManager(QObject):
|
|||
new_global_stack.addContainer(material_instance_container)
|
||||
if quality_instance_container:
|
||||
new_global_stack.addContainer(quality_instance_container)
|
||||
|
||||
new_global_stack.addContainer(self._empty_quality_changes_container)
|
||||
new_global_stack.addContainer(current_settings_instance_container)
|
||||
|
||||
ExtruderManager.getInstance().addMachineExtruders(definition, new_global_stack.getId())
|
||||
|
@ -492,6 +395,9 @@ class MachineManager(QObject):
|
|||
@pyqtProperty(str, notify=activeQualityChanged)
|
||||
def activeQualityName(self):
|
||||
if self._active_container_stack:
|
||||
quality = self._active_container_stack.findContainer({"type": "quality_changes"})
|
||||
if quality and quality != self._empty_quality_changes_container:
|
||||
return quality.getName()
|
||||
quality = self._active_container_stack.findContainer({"type": "quality"})
|
||||
if quality:
|
||||
return quality.getName()
|
||||
|
@ -499,8 +405,11 @@ class MachineManager(QObject):
|
|||
|
||||
@pyqtProperty(str, notify=activeQualityChanged)
|
||||
def activeQualityId(self):
|
||||
if self._active_container_stack:
|
||||
quality = self._active_container_stack.findContainer({"type": "quality"})
|
||||
if self._global_container_stack:
|
||||
quality = self._global_container_stack.findContainer({"type": "quality_changes"})
|
||||
if quality and quality != self._empty_quality_changes_container:
|
||||
return quality.getId()
|
||||
quality = self._global_container_stack.findContainer({"type": "quality"})
|
||||
if quality:
|
||||
return quality.getId()
|
||||
return ""
|
||||
|
@ -526,16 +435,6 @@ class MachineManager(QObject):
|
|||
if extruder_stack != self._active_container_stack and extruder_stack.getProperty(key, "value") != new_value:
|
||||
extruder_stack.getTop().setProperty(key, "value", new_value)
|
||||
|
||||
@pyqtSlot(result = str)
|
||||
def newQualityContainerFromQualityAndUser(self):
|
||||
new_container_id = self.duplicateContainer(self.activeQualityId)
|
||||
if new_container_id == "":
|
||||
return
|
||||
self.blurSettings.emit()
|
||||
self.updateQualityContainerFromUserContainer(new_container_id)
|
||||
self.setActiveQuality(new_container_id)
|
||||
return new_container_id
|
||||
|
||||
@pyqtSlot(str, result=str)
|
||||
def duplicateContainer(self, container_id):
|
||||
if not self._active_container_stack:
|
||||
|
@ -601,29 +500,6 @@ class MachineManager(QObject):
|
|||
self.setActiveQuality(containers[0].getId())
|
||||
self.activeQualityChanged.emit()
|
||||
|
||||
@pyqtSlot(str)
|
||||
@pyqtSlot()
|
||||
def updateQualityContainerFromUserContainer(self, quality_id = None):
|
||||
if not self._active_container_stack:
|
||||
return
|
||||
|
||||
if quality_id:
|
||||
quality = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = quality_id, type = "quality")
|
||||
if quality:
|
||||
quality = quality[0]
|
||||
else:
|
||||
quality = self._active_container_stack.findContainer({"type": "quality"})
|
||||
|
||||
if not quality:
|
||||
return
|
||||
|
||||
user_settings = self._active_container_stack.getTop()
|
||||
|
||||
for key in user_settings.getAllKeys():
|
||||
quality.setProperty(key, "value", user_settings.getProperty(key, "value"))
|
||||
self.clearUserSettings() # As all users settings are noq a quality, remove them.
|
||||
|
||||
|
||||
@pyqtSlot(str)
|
||||
def setActiveMaterial(self, material_id):
|
||||
containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = material_id)
|
||||
|
@ -669,18 +545,53 @@ class MachineManager(QObject):
|
|||
@pyqtSlot(str)
|
||||
def setActiveQuality(self, quality_id):
|
||||
containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = quality_id)
|
||||
if not containers or not self._active_container_stack:
|
||||
if not containers or not self._global_container_stack:
|
||||
return
|
||||
|
||||
old_quality = self._active_container_stack.findContainer({"type": "quality"})
|
||||
if old_quality and old_quality != containers[0]:
|
||||
quality_container = None
|
||||
quality_changes_container = self._empty_quality_changes_container
|
||||
|
||||
container_type = containers[0].getMetaDataEntry("type")
|
||||
|
||||
if container_type == "quality":
|
||||
quality_container = containers[0]
|
||||
elif container_type == "quality_changes":
|
||||
quality_changes_container = containers[0]
|
||||
containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = quality_changes_container.getMetaDataEntry("quality"))
|
||||
if not containers:
|
||||
Logger.log("e", "Could not find quality %s for changes %s, not changing quality", quality_changes_container.getMetaDataEntry("quality"), quality_changes_container.getId())
|
||||
return
|
||||
quality_container = containers[0]
|
||||
else:
|
||||
Logger.log("e", "Tried to set quality to a container that is not of the right type")
|
||||
return
|
||||
|
||||
stacks = [ s for s in ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()) ]
|
||||
stacks.insert(0, self._global_container_stack)
|
||||
|
||||
for stack in stacks:
|
||||
extruder_id = stack.getId() if stack != self._global_container_stack else None
|
||||
stack_quality = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(name = quality_container.getName(), extruder = extruder_id)
|
||||
if not stack_quality:
|
||||
stack_quality = quality_container
|
||||
else:
|
||||
stack_quality = stack_quality[0]
|
||||
|
||||
if quality_changes_container != self._empty_quality_changes_container:
|
||||
stack_quality_changes = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(name = quality_changes_container.getName(), extruder = extruder_id)[0]
|
||||
else:
|
||||
stack_quality_changes = self._empty_quality_changes_container
|
||||
|
||||
old_quality = stack.findContainer(type = "quality")
|
||||
old_quality.nameChanged.disconnect(self._onQualityNameChanged)
|
||||
old_changes = stack.findContainer(type = "quality_changes")
|
||||
old_changes.nameChanged.disconnect(self._onQualityNameChanged)
|
||||
|
||||
quality_index = self._active_container_stack.getContainerIndex(old_quality)
|
||||
stack.replaceContainer(stack.getContainerIndex(old_quality), stack_quality)
|
||||
stack.replaceContainer(stack.getContainerIndex(old_changes), stack_quality_changes)
|
||||
|
||||
self._active_container_stack.replaceContainer(quality_index, containers[0])
|
||||
|
||||
containers[0].nameChanged.connect(self._onQualityNameChanged)
|
||||
stack_quality.nameChanged.connect(self._onQualityNameChanged)
|
||||
stack_quality_changes.nameChanged.connect(self._onQualityNameChanged)
|
||||
|
||||
if self.hasUserSettings and Preferences.getInstance().getValue("cura/active_mode") == 1:
|
||||
# Ask the user if the user profile should be cleared or not (discarding the current settings)
|
||||
|
@ -693,8 +604,6 @@ class MachineManager(QObject):
|
|||
Application.getInstance().messageBox(catalog.i18nc("@window:title", "Switched profiles"), catalog.i18nc("@label", "Do you want to transfer your changed settings to this profile?"),
|
||||
catalog.i18nc("@label", "If you transfer your settings they will override settings in the profile."), details,
|
||||
buttons = QMessageBox.Yes + QMessageBox.No, icon = QMessageBox.Question, callback = self._keepUserSettingsDialogCallback)
|
||||
else:
|
||||
Logger.log("w", "While trying to set the active quality, no quality was found to replace.")
|
||||
|
||||
def _keepUserSettingsDialogCallback(self, button):
|
||||
if button == QMessageBox.Yes:
|
||||
|
|
|
@ -122,7 +122,7 @@ Item
|
|||
id: updateProfileAction;
|
||||
enabled: Cura.MachineManager.isActiveStackValid && Cura.MachineManager.hasUserSettings && !Cura.MachineManager.isReadOnly(Cura.MachineManager.activeQualityId)
|
||||
text: catalog.i18nc("@action:inmenu menubar:profile","&Update profile with current settings");
|
||||
onTriggered: Cura.MachineManager.updateQualityContainerFromUserContainer()
|
||||
onTriggered: Cura.ContainerManager.updateQualityChanges();
|
||||
}
|
||||
|
||||
Action
|
||||
|
@ -130,7 +130,7 @@ Item
|
|||
id: resetProfileAction;
|
||||
enabled: Cura.MachineManager.hasUserSettings
|
||||
text: catalog.i18nc("@action:inmenu menubar:profile","&Discard current settings");
|
||||
onTriggered: Cura.MachineManager.clearUserSettings();
|
||||
onTriggered: Cura.ContainerManager.clearUserContainers();
|
||||
}
|
||||
|
||||
Action
|
||||
|
|
|
@ -150,7 +150,7 @@ UM.MainWindow
|
|||
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem { text: "Set as Active Extruder" }
|
||||
MenuItem { text: catalog.i18nc("@action:inmenu", "Set as Active Extruder"); onTriggered: Cura.ExtruderManager.setActiveExtruderIndex(model.index) }
|
||||
}
|
||||
onObjectAdded: settingsMenu.insertItem(index, object)
|
||||
onObjectRemoved: settingsMenu.removeItem(object)
|
||||
|
@ -459,7 +459,8 @@ UM.MainWindow
|
|||
target: Cura.Actions.addProfile
|
||||
onTriggered:
|
||||
{
|
||||
Cura.MachineManager.newQualityContainerFromQualityAndUser();
|
||||
// Cura.MachineManager.newQualityContainerFromQualityAndUser();
|
||||
Cura.ContainerManager.createQualityChanges();
|
||||
preferences.setPage(4);
|
||||
preferences.show();
|
||||
|
||||
|
@ -764,6 +765,10 @@ UM.MainWindow
|
|||
addMachineDialog.visible = true
|
||||
addMachineDialog.firstRun = false
|
||||
}
|
||||
onClearAllFocus:
|
||||
{
|
||||
contentItem.focus = true
|
||||
}
|
||||
}
|
||||
|
||||
Timer
|
||||
|
|
|
@ -7,7 +7,7 @@ import QtQuick.Controls 1.1
|
|||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Menu
|
||||
Menu
|
||||
{
|
||||
id: menu
|
||||
|
||||
|
@ -15,7 +15,7 @@ import Cura 1.0 as Cura
|
|||
{
|
||||
model: UM.InstanceContainersModel
|
||||
{
|
||||
filter: menu.getFilter({ "read_only": true });
|
||||
filter: menu.getFilter({ "type": "quality" });
|
||||
}
|
||||
|
||||
MenuItem
|
||||
|
@ -38,7 +38,7 @@ import Cura 1.0 as Cura
|
|||
id: customProfileInstantiator
|
||||
model: UM.InstanceContainersModel
|
||||
{
|
||||
filter: menu.getFilter({ "read_only": false });
|
||||
filter: menu.getFilter({ "type": "quality_changes", "extruder": null });
|
||||
onModelReset: customSeparator.visible = rowCount() > 0
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,6 @@ import Cura 1.0 as Cura
|
|||
function getFilter(initial_conditions)
|
||||
{
|
||||
var result = initial_conditions;
|
||||
result.type = "quality"
|
||||
|
||||
if(Cura.MachineManager.filterQualityByMachine)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,6 @@ Item {
|
|||
|
||||
// Create properties to put property provider stuff in (bindings break in qt 5.5.1 otherwise)
|
||||
property var state: propertyProvider.properties.state
|
||||
property var settablePerExtruder: propertyProvider.properties.settable_per_extruder
|
||||
property var value: propertyProvider.properties.value
|
||||
property var globalValue: globalPropertyProvider.properties.value
|
||||
property var resolve: propertyProvider.properties.resolve
|
||||
|
@ -141,7 +140,7 @@ Item {
|
|||
{
|
||||
id: linkedSettingIcon;
|
||||
|
||||
visible: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId && base.settablePerExtruder != "True" && base.showLinkedSettingIcon
|
||||
visible: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId && !definition.settable_per_extruder && base.showLinkedSettingIcon
|
||||
|
||||
height: parent.height;
|
||||
width: height;
|
||||
|
|
|
@ -111,6 +111,9 @@ SettingItem
|
|||
// We have a resolve function. Indicates that the setting is not settable per extruder and that
|
||||
// we have to choose between the resolved value (default) and the global value
|
||||
// (if user has explicitly set this).
|
||||
if (definition.key == "material_bed_temperature") {
|
||||
CuraApplication.log("## global value " + globalPropertyProvider.properties.value);
|
||||
}
|
||||
return (globalPropertyProvider.properties.value != null) ? globalPropertyProvider.properties.value : propertyProvider.properties.resolve;
|
||||
} else {
|
||||
return propertyProvider.properties.value;
|
||||
|
|
|
@ -95,6 +95,7 @@ ScrollView
|
|||
{
|
||||
target: provider
|
||||
property: "containerStackId"
|
||||
when: model.settable_per_extruder || (inheritStackProvider.properties.global_inherits_stack != -1 && inheritStackProvider.properties.global_inherits_stack != null)
|
||||
value:
|
||||
{
|
||||
if(inheritStackProvider.properties.global_inherits_stack == -1 || inheritStackProvider.properties.global_inherits_stack == null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue