mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 12:17:50 -06:00
No longer spam the GUI with hasUserSettingsUpdates
The QML profiler showed me that it was causing a *lot* of issues when switching between extruders. More than 10% of the time in QML was spent on just updating ine property in the workspace summary dialog. There were other properties that were also being updated without there being a point. Contributes to #8250
This commit is contained in:
parent
6dbdee8d98
commit
175244fdc8
1 changed files with 23 additions and 22 deletions
|
@ -63,6 +63,7 @@ class MachineManager(QObject):
|
|||
self._current_root_material_id = {} # type: Dict[str, str]
|
||||
|
||||
self._default_extruder_position = "0" # to be updated when extruders are switched on and off
|
||||
self._num_user_settings = 0
|
||||
|
||||
self._instance_container_timer = QTimer() # type: QTimer
|
||||
self._instance_container_timer.setInterval(250)
|
||||
|
@ -126,6 +127,8 @@ class MachineManager(QObject):
|
|||
self.activeQualityGroupChanged.connect(self.activeQualityDisplayNameChanged)
|
||||
self.activeQualityChangesGroupChanged.connect(self.activeQualityDisplayNameChanged)
|
||||
|
||||
self.activeStackValueChanged.connect(self._reCalculateNumUserSettings)
|
||||
|
||||
activeQualityDisplayNameChanged = pyqtSignal()
|
||||
|
||||
activeQualityGroupChanged = pyqtSignal()
|
||||
|
@ -151,6 +154,22 @@ class MachineManager(QObject):
|
|||
printerConnectedStatusChanged = pyqtSignal() # Emitted every time the active machine change or the outputdevices change
|
||||
|
||||
rootMaterialChanged = pyqtSignal()
|
||||
numUserSettingsChanged = pyqtSignal()
|
||||
|
||||
def _reCalculateNumUserSettings(self):
|
||||
if not self._global_container_stack:
|
||||
if self._num_user_settings != 0:
|
||||
self.numUserSettingsChanged.emit()
|
||||
self._num_user_settings = 0
|
||||
return
|
||||
num_user_settings = self._global_container_stack.getTop().getNumInstances()
|
||||
stacks = self._global_container_stack.extruderList
|
||||
for stack in stacks:
|
||||
num_user_settings += stack.getTop().getNumInstances()
|
||||
|
||||
if self._num_user_settings != num_user_settings:
|
||||
self._num_user_settings = num_user_settings
|
||||
self.numUserSettingsChanged.emit()
|
||||
|
||||
def setInitialActiveMachine(self) -> None:
|
||||
active_machine_id = self._application.getPreferences().getValue("cura/active_machine")
|
||||
|
@ -415,31 +434,13 @@ class MachineManager(QObject):
|
|||
Logger.log("d", "Checking %s stacks for errors took %.2f s" % (count, time.time() - time_start))
|
||||
return False
|
||||
|
||||
@pyqtProperty(bool, notify = activeStackValueChanged)
|
||||
@pyqtProperty(bool, notify = numUserSettingsChanged)
|
||||
def hasUserSettings(self) -> bool:
|
||||
"""Check if the global_container has instances in the user container"""
|
||||
return self._num_user_settings != 0
|
||||
|
||||
if not self._global_container_stack:
|
||||
return False
|
||||
|
||||
if self._global_container_stack.getTop().getNumInstances() != 0:
|
||||
return True
|
||||
|
||||
for stack in self._global_container_stack.extruderList:
|
||||
if stack.getTop().getNumInstances() != 0:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@pyqtProperty(int, notify = activeStackValueChanged)
|
||||
@pyqtProperty(int, notify = numUserSettingsChanged)
|
||||
def numUserSettings(self) -> int:
|
||||
if not self._global_container_stack:
|
||||
return 0
|
||||
num_user_settings = self._global_container_stack.getTop().getNumInstances()
|
||||
stacks = self._global_container_stack.extruderList
|
||||
for stack in stacks:
|
||||
num_user_settings += stack.getTop().getNumInstances()
|
||||
return num_user_settings
|
||||
return self._num_user_settings
|
||||
|
||||
@pyqtSlot(str)
|
||||
def clearUserSettingAllCurrentStacks(self, key: str) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue