Move simple-mode settings customization check into a separate file

CURA-4333

Simple-mode is a special mode so it makes more sense to put those code
in a separate file instead of in the more generic MachineManager.
This commit is contained in:
Lipu Fei 2017-10-16 13:18:09 +02:00
parent e1234a09aa
commit 9b8dc9bf55
4 changed files with 68 additions and 46 deletions

View file

@ -39,8 +39,6 @@ if TYPE_CHECKING:
from cura.Settings.CuraContainerStack import CuraContainerStack
from cura.Settings.GlobalStack import GlobalStack
import os
class MachineManager(QObject):
def __init__(self, parent = None):
@ -413,45 +411,6 @@ class MachineManager(QObject):
return False
## Check whether user containers have adjusted settings or not
# \param skip_keys \type{list} List of setting keys which will be not taken into account ("support_enable" , "infill_sparse_density"...)
# \return \type{boole} Return true if user containers have any of adjusted settings
def hasUserCustomSettings(self, skip_keys = {}) -> bool:
user_setting_keys = []
if not self._global_container_stack:
return False
allContainers = self._global_container_stack.getContainers()
for container in allContainers:
meta_type = container.getMetaDataEntry("type", None)
if meta_type == "user":
user_setting_keys.extend(container.getAllKeys())
stacks = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()))
for stack in stacks:
for container in stack.getContainers():
meta_type = container.getMetaDataEntry("type", None)
if meta_type == "user":
user_setting_keys.extend(container.getAllKeys())
for skip_key in skip_keys:
if skip_key in user_setting_keys:
user_setting_keys.remove(skip_key)
return len(user_setting_keys) > 0
# These setting keys are used in SettingSimple.qml. They used to validate whether show notification(reset) icon or not
# If a changed setting is in the ignore list then this setting should be skipped and the notification not shown
ignore_list = ["support_enable", "infill_sparse_density", "gradual_infill_steps", "adhesion_type", "support_extruder_nr"]
@pyqtProperty(bool, notify = activeStackValueChanged)
def allActiveUserSettings(self):
return self.hasUserCustomSettings(skip_keys = self.ignore_list)
@pyqtProperty(int, notify = activeStackValueChanged)
def numUserSettings(self) -> int:
if not self._global_container_stack: