Add signal for when extruder list changes

The ExtrudersModel will need to listen to this.

Contributes to issues CURA-1278 and CURA-351.
This commit is contained in:
Ghostkeeper 2016-06-02 12:55:01 +02:00
parent 06f7f90bb0
commit 8a8b0016ba
No known key found for this signature in database
GPG key ID: 701948C5954A7385

View file

@ -5,6 +5,7 @@ from cura.Extruder import Extruder #The individual extruders managed by this man
from UM.Application import Application #To get the global container stack to find the current machine.
from UM.Logger import Logger
from UM.Settings.ContainerRegistry import ContainerRegistry #Finding containers by ID.
import UM.Signal #To notify other components of changes in the extruders.
## Class that handles the current extruder stack.
@ -16,6 +17,9 @@ class ExtruderManager:
## The singleton instance of this manager.
__instance = None
## Signal to notify other components when the list of extruders changes.
extrudersChanged = UM.Signal()
## Registers listeners and such to listen to changes to the extruders.
def __init__(self):
self._extruders = [] #Extruders for the current machine.
@ -49,6 +53,7 @@ class ExtruderManager:
def _reloadExtruders(self):
self._extruders = []
if not self._global_container_stack: #No machine has been added yet.
self.extrudersChanged.emit() #Yes, we just cleared the _extruders list!
return #Then leave them empty!
#Get the extruder definitions belonging to the current machine.
@ -60,4 +65,5 @@ class ExtruderManager:
Logger.log("w", "Machine definition %s refers to an extruder train \"%s\", but no such extruder was found.", machine.getId(), extruder_train_id)
continue
for extruder_definition in extruder_definitions:
self._extruders.append(Extruder(extruder_definition))
self._extruders.append(Extruder(extruder_definition))
self.extrudersChanged.emit()