123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- from typing import Set
- from PyQt5.QtCore import QObject, pyqtSignal, pyqtProperty, pyqtSlot
- from UM.Application import Application
- class SimpleModeSettingsManager(QObject):
- def __init__(self, parent = None):
- super().__init__(parent)
- self._machine_manager = Application.getInstance().getMachineManager()
- self._is_profile_customized = False
- self._is_profile_user_created = False
- self._machine_manager.activeStackValueChanged.connect(self._updateIsProfileCustomized)
-
- self._updateIsProfileCustomized()
- isProfileCustomizedChanged = pyqtSignal()
- @pyqtProperty(bool, notify = isProfileCustomizedChanged)
- def isProfileCustomized(self):
- return self._is_profile_customized
- def _updateIsProfileCustomized(self):
- user_setting_keys = set()
- if not self._machine_manager.activeMachine:
- return False
- global_stack = self._machine_manager.activeMachine
-
- user_setting_keys.update(global_stack.userChanges.getAllKeys())
-
- if global_stack.extruderList:
- for extruder_stack in global_stack.extruderList:
- user_setting_keys.update(extruder_stack.userChanges.getAllKeys())
-
- for skip_key in self.__ignored_custom_setting_keys:
- if skip_key in user_setting_keys:
- user_setting_keys.remove(skip_key)
- has_customized_user_settings = len(user_setting_keys) > 0
- if has_customized_user_settings != self._is_profile_customized:
- self._is_profile_customized = has_customized_user_settings
- self.isProfileCustomizedChanged.emit()
-
-
- __ignored_custom_setting_keys = ["support_enable",
- "infill_sparse_density",
- "gradual_infill_steps",
- "adhesion_type",
- "support_extruder_nr"]
|