mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Store the global container stack as an instance property
This reduces the amount of function calls and makes it simpler to check for container existance
This commit is contained in:
parent
5f54d611cf
commit
2e0205f174
1 changed files with 11 additions and 2 deletions
|
@ -8,7 +8,10 @@ import UM.Settings
|
||||||
class MachineManagerModel(QObject):
|
class MachineManagerModel(QObject):
|
||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self._global_container_stack = None
|
||||||
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
||||||
|
self._onGlobalContainerChanged()
|
||||||
|
|
||||||
## When the global container is changed, active material probably needs to be updated.
|
## When the global container is changed, active material probably needs to be updated.
|
||||||
self.globalContainerChanged.connect(self.activeMaterialChanged)
|
self.globalContainerChanged.connect(self.activeMaterialChanged)
|
||||||
|
@ -31,10 +34,16 @@ class MachineManagerModel(QObject):
|
||||||
activeQualityChanged = pyqtSignal()
|
activeQualityChanged = pyqtSignal()
|
||||||
|
|
||||||
def _onGlobalContainerChanged(self):
|
def _onGlobalContainerChanged(self):
|
||||||
Preferences.getInstance().setValue("cura/active_machine", Application.getInstance().getGlobalContainerStack().getId())
|
if self._global_container_stack:
|
||||||
Application.getInstance().getGlobalContainerStack().containersChanged.connect(self._onInstanceContainersChanged)
|
self._global_container_stack.containersChanged.disconnect(self._onInstanceContainersChanged)
|
||||||
|
|
||||||
|
self._global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
self.globalContainerChanged.emit()
|
self.globalContainerChanged.emit()
|
||||||
|
|
||||||
|
if self._global_container_stack:
|
||||||
|
Preferences.getInstance().setValue("cura/active_machine", self._global_container_stack.getId())
|
||||||
|
self._global_container_stack.containersChanged.connect(self._onInstanceContainersChanged)
|
||||||
|
|
||||||
def _onInstanceContainersChanged(self, container):
|
def _onInstanceContainersChanged(self, container):
|
||||||
container_type = container.getMetaDataEntry("type")
|
container_type = container.getMetaDataEntry("type")
|
||||||
if container_type == "material":
|
if container_type == "material":
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue