mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 15:13:56 -06:00
WIP: Remove delayed update in MachineManager
This commit is contained in:
parent
25dd63dc21
commit
b415a36110
2 changed files with 0 additions and 80 deletions
|
@ -540,8 +540,6 @@ class CuraApplication(QtApplication):
|
||||||
has_user_interaction = True
|
has_user_interaction = True
|
||||||
return has_user_interaction
|
return has_user_interaction
|
||||||
|
|
||||||
onDiscardOrKeepProfileChangesClosed = pyqtSignal() # Used to notify other managers that the dialog was closed
|
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def discardOrKeepProfileChangesClosed(self, option):
|
def discardOrKeepProfileChangesClosed(self, option):
|
||||||
if option == "discard":
|
if option == "discard":
|
||||||
|
@ -564,7 +562,6 @@ class CuraApplication(QtApplication):
|
||||||
user_global_container.update()
|
user_global_container.update()
|
||||||
|
|
||||||
# notify listeners that quality has changed (after user selected discard or keep)
|
# notify listeners that quality has changed (after user selected discard or keep)
|
||||||
self.onDiscardOrKeepProfileChangesClosed.emit()
|
|
||||||
self.getMachineManager().activeQualityChanged.emit()
|
self.getMachineManager().activeQualityChanged.emit()
|
||||||
|
|
||||||
@pyqtSlot(int)
|
@pyqtSlot(int)
|
||||||
|
|
|
@ -54,12 +54,6 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
self.machine_extruder_material_update_dict = collections.defaultdict(list)
|
self.machine_extruder_material_update_dict = collections.defaultdict(list)
|
||||||
|
|
||||||
# Used to store the new containers until after confirming the dialog
|
|
||||||
self._new_variant_container = None # type: Optional[InstanceContainer]
|
|
||||||
self._new_buildplate_container = None # type: Optional[InstanceContainer]
|
|
||||||
self._new_material_container = None # type: Optional[InstanceContainer]
|
|
||||||
self._new_quality_containers = [] # type: List[Dict]
|
|
||||||
|
|
||||||
self._error_check_timer = QTimer()
|
self._error_check_timer = QTimer()
|
||||||
self._error_check_timer.setInterval(250)
|
self._error_check_timer.setInterval(250)
|
||||||
self._error_check_timer.setSingleShot(True)
|
self._error_check_timer.setSingleShot(True)
|
||||||
|
@ -104,9 +98,6 @@ class MachineManager(QObject):
|
||||||
ExtruderManager.getInstance().activeExtruderChanged.connect(self.activeStackChanged)
|
ExtruderManager.getInstance().activeExtruderChanged.connect(self.activeStackChanged)
|
||||||
self.activeStackChanged.connect(self.activeStackValueChanged)
|
self.activeStackChanged.connect(self.activeStackValueChanged)
|
||||||
|
|
||||||
# when a user closed dialog check if any delayed material or variant changes need to be applied
|
|
||||||
Application.getInstance().onDiscardOrKeepProfileChangesClosed.connect(self._executeDelayedActiveContainerStackChanges)
|
|
||||||
|
|
||||||
Preferences.getInstance().addPreference("cura/active_machine", "")
|
Preferences.getInstance().addPreference("cura/active_machine", "")
|
||||||
|
|
||||||
self._global_event_keys = set()
|
self._global_event_keys = set()
|
||||||
|
@ -172,18 +163,6 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
self.outputDevicesChanged.emit()
|
self.outputDevicesChanged.emit()
|
||||||
|
|
||||||
@property
|
|
||||||
def newVariant(self):
|
|
||||||
return self._new_variant_container
|
|
||||||
|
|
||||||
@property
|
|
||||||
def newBuildplate(self):
|
|
||||||
return self._new_buildplate_container
|
|
||||||
|
|
||||||
@property
|
|
||||||
def newMaterial(self):
|
|
||||||
return self._new_material_container
|
|
||||||
|
|
||||||
@pyqtProperty("QVariantList", notify = outputDevicesChanged)
|
@pyqtProperty("QVariantList", notify = outputDevicesChanged)
|
||||||
def printerOutputDevices(self):
|
def printerOutputDevices(self):
|
||||||
return self._printer_output_devices
|
return self._printer_output_devices
|
||||||
|
@ -314,7 +293,6 @@ class MachineManager(QObject):
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def setActiveMachine(self, stack_id: str) -> None:
|
def setActiveMachine(self, stack_id: str) -> None:
|
||||||
self.blurSettings.emit() # Ensure no-one has focus.
|
self.blurSettings.emit() # Ensure no-one has focus.
|
||||||
self._cancelDelayedActiveContainerStackChanges()
|
|
||||||
|
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
|
|
||||||
|
@ -573,61 +551,6 @@ class MachineManager(QObject):
|
||||||
if extruder_stack != self._active_container_stack and extruder_stack.getProperty(key, "value") != new_value:
|
if extruder_stack != self._active_container_stack and extruder_stack.getProperty(key, "value") != new_value:
|
||||||
extruder_stack.userChanges.setProperty(key, "value", new_value) # TODO: nested property access, should be improved
|
extruder_stack.userChanges.setProperty(key, "value", new_value) # TODO: nested property access, should be improved
|
||||||
|
|
||||||
## Used to update material and variant in the active container stack with a delay.
|
|
||||||
# This delay prevents the stack from triggering a lot of signals (eventually resulting in slicing)
|
|
||||||
# before the user decided to keep or discard any of their changes using the dialog.
|
|
||||||
# The Application.onDiscardOrKeepProfileChangesClosed signal triggers this method.
|
|
||||||
def _executeDelayedActiveContainerStackChanges(self):
|
|
||||||
Logger.log("d", "Applying configuration changes...")
|
|
||||||
|
|
||||||
if self._new_variant_container is not None:
|
|
||||||
self._active_container_stack.variant = self._new_variant_container
|
|
||||||
self._new_variant_container = None
|
|
||||||
|
|
||||||
if self._new_buildplate_container is not None:
|
|
||||||
self._global_container_stack.variant = self._new_buildplate_container
|
|
||||||
self._new_buildplate_container = None
|
|
||||||
|
|
||||||
if self._new_material_container is not None:
|
|
||||||
self._active_container_stack.material = self._new_material_container
|
|
||||||
self._new_material_container = None
|
|
||||||
|
|
||||||
# apply the new quality to all stacks
|
|
||||||
if self._new_quality_containers:
|
|
||||||
for new_quality in self._new_quality_containers:
|
|
||||||
self._replaceQualityOrQualityChangesInStack(new_quality["stack"], new_quality["quality"], postpone_emit = True)
|
|
||||||
self._replaceQualityOrQualityChangesInStack(new_quality["stack"], new_quality["quality_changes"], postpone_emit = True)
|
|
||||||
|
|
||||||
for new_quality in self._new_quality_containers:
|
|
||||||
new_quality["stack"].nameChanged.connect(self._onQualityNameChanged)
|
|
||||||
new_quality["stack"].sendPostponedEmits() # Send the signals that were postponed in _replaceQualityOrQualityChangesInStack
|
|
||||||
|
|
||||||
self._new_quality_containers.clear()
|
|
||||||
|
|
||||||
Logger.log("d", "New configuration applied")
|
|
||||||
|
|
||||||
## Cancel set changes for material and variant in the active container stack.
|
|
||||||
# Used for ignoring any changes when switching between printers (setActiveMachine)
|
|
||||||
def _cancelDelayedActiveContainerStackChanges(self):
|
|
||||||
self._new_material_container = None
|
|
||||||
self._new_buildplate_container = None
|
|
||||||
self._new_variant_container = None
|
|
||||||
|
|
||||||
def _replaceQualityOrQualityChangesInStack(self, stack: "CuraContainerStack", container: "InstanceContainer", postpone_emit = False):
|
|
||||||
# Disconnect the signal handling from the old container.
|
|
||||||
container_type = container.getMetaDataEntry("type")
|
|
||||||
if container_type == "quality":
|
|
||||||
stack.quality.nameChanged.disconnect(self._onQualityNameChanged)
|
|
||||||
stack.setQuality(container, postpone_emit = postpone_emit)
|
|
||||||
stack.quality.nameChanged.connect(self._onQualityNameChanged)
|
|
||||||
elif container_type == "quality_changes" or container_type is None:
|
|
||||||
# If the container is an empty container, we need to change the quality_changes.
|
|
||||||
# Quality can never be set to empty.
|
|
||||||
stack.qualityChanges.nameChanged.disconnect(self._onQualityNameChanged)
|
|
||||||
stack.setQualityChanges(container, postpone_emit = postpone_emit)
|
|
||||||
stack.qualityChanges.nameChanged.connect(self._onQualityNameChanged)
|
|
||||||
self._onQualityNameChanged()
|
|
||||||
|
|
||||||
@pyqtProperty(str, notify = activeVariantChanged)
|
@pyqtProperty(str, notify = activeVariantChanged)
|
||||||
def activeVariantName(self) -> str:
|
def activeVariantName(self) -> str:
|
||||||
if self._active_container_stack:
|
if self._active_container_stack:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue