mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-16 05:06:03 +08:00
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:
parent
06f7f90bb0
commit
8a8b0016ba
@ -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.Application import Application #To get the global container stack to find the current machine.
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry #Finding containers by ID.
|
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.
|
## Class that handles the current extruder stack.
|
||||||
@ -16,6 +17,9 @@ class ExtruderManager:
|
|||||||
## The singleton instance of this manager.
|
## The singleton instance of this manager.
|
||||||
__instance = None
|
__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.
|
## Registers listeners and such to listen to changes to the extruders.
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._extruders = [] #Extruders for the current machine.
|
self._extruders = [] #Extruders for the current machine.
|
||||||
@ -49,6 +53,7 @@ class ExtruderManager:
|
|||||||
def _reloadExtruders(self):
|
def _reloadExtruders(self):
|
||||||
self._extruders = []
|
self._extruders = []
|
||||||
if not self._global_container_stack: #No machine has been added yet.
|
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!
|
return #Then leave them empty!
|
||||||
|
|
||||||
#Get the extruder definitions belonging to the current machine.
|
#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)
|
Logger.log("w", "Machine definition %s refers to an extruder train \"%s\", but no such extruder was found.", machine.getId(), extruder_train_id)
|
||||||
continue
|
continue
|
||||||
for extruder_definition in extruder_definitions:
|
for extruder_definition in extruder_definitions:
|
||||||
self._extruders.append(Extruder(extruder_definition))
|
self._extruders.append(Extruder(extruder_definition))
|
||||||
|
self.extrudersChanged.emit()
|
Loading…
x
Reference in New Issue
Block a user