mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
Add a method to get overrides for a specified (extruder)stack
Since the main getOverrides method only accounts for the active extruder and we sometimes need to check other extruders in case of limit_to_extruder. Contributes to CURA-2752
This commit is contained in:
parent
b718109f72
commit
bdaa4a5a6d
1 changed files with 23 additions and 6 deletions
|
@ -38,6 +38,22 @@ class SettingInheritanceManager(QObject):
|
||||||
result.append(key)
|
result.append(key)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@pyqtSlot(str, str, result = "QStringList")
|
||||||
|
def getOverridesForExtruder(self, key, extruder):
|
||||||
|
extruder = cura.Settings.ExtruderManager.getInstance().getExtruderStack(extruder)
|
||||||
|
if not extruder:
|
||||||
|
return []
|
||||||
|
|
||||||
|
definitions = self._global_container_stack.getBottom().findDefinitions(key=key)
|
||||||
|
if not definitions:
|
||||||
|
return
|
||||||
|
result = []
|
||||||
|
for key in definitions[0].getAllKeys():
|
||||||
|
if self._settingIsOverwritingInheritance(key, extruder):
|
||||||
|
result.append(key)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def manualRemoveOverride(self, key):
|
def manualRemoveOverride(self, key):
|
||||||
if key in self._settings_with_inheritance_warning:
|
if key in self._settings_with_inheritance_warning:
|
||||||
|
@ -115,22 +131,23 @@ class SettingInheritanceManager(QObject):
|
||||||
return self._settings_with_inheritance_warning
|
return self._settings_with_inheritance_warning
|
||||||
|
|
||||||
## Check if a setting has an inheritance function that is overwritten
|
## Check if a setting has an inheritance function that is overwritten
|
||||||
def _settingIsOverwritingInheritance(self, key):
|
def _settingIsOverwritingInheritance(self, key, stack = None):
|
||||||
has_setting_function = False
|
has_setting_function = False
|
||||||
|
if not stack:
|
||||||
stack = self._active_container_stack
|
stack = self._active_container_stack
|
||||||
containers = []
|
containers = []
|
||||||
|
|
||||||
## Check if the setting has a user state. If not, it is never overwritten.
|
## Check if the setting has a user state. If not, it is never overwritten.
|
||||||
has_user_state = self._active_container_stack.getProperty(key, "state") == UM.Settings.InstanceState.User
|
has_user_state = stack.getProperty(key, "state") == UM.Settings.InstanceState.User
|
||||||
if not has_user_state:
|
if not has_user_state:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
## If a setting is not enabled, don't label it as overwritten (It's never visible anyway).
|
## If a setting is not enabled, don't label it as overwritten (It's never visible anyway).
|
||||||
if not self._active_container_stack.getProperty(key, "enabled"):
|
if not stack.getProperty(key, "enabled"):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
## Also check if the top container is not a setting function (this happens if the inheritance is restored).
|
## Also check if the top container is not a setting function (this happens if the inheritance is restored).
|
||||||
if isinstance(self._active_container_stack.getTop().getProperty(key, "value"), UM.Settings.SettingFunction):
|
if isinstance(stack.getTop().getProperty(key, "value"), UM.Settings.SettingFunction):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
## Mash all containers for all the stacks together.
|
## Mash all containers for all the stacks together.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue