Save default material colour statically

So if you wish to change that colour, you only need to change it in one place.

Contributes to issue CURA-340.
This commit is contained in:
Ghostkeeper 2016-06-09 16:30:54 +02:00
parent beb263025b
commit 9d618282ed
No known key found for this signature in database
GPG key ID: 701948C5954A7385

View file

@ -28,6 +28,10 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
# containers.
IndexRole = Qt.UserRole + 4
## Colour to display if there is no material or the material has no known
# colour.
defaultColour = "#FFFF00"
## Initialises the extruders model, defining the roles and listening for
# changes in the data.
#
@ -71,7 +75,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
if self._add_global:
material = global_container_stack.findContainer({ "type": "material" })
colour = material.getMetaDataEntry("color_code", default = "#FFFF00") if material else "#FFFF00"
colour = material.getMetaDataEntry("color_code", default = self.defaultColour) if material else self.defaultColour
item = {
"id": global_container_stack.getId(),
"name": "Global",
@ -82,7 +86,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
for extruder in manager.getMachineExtruders(global_container_stack.getBottom().getId()):
material = extruder.findContainer({ "type": "material" })
colour = material.getMetaDataEntry("color_code", default = "#FFFF00") if material else "#FFFF00"
colour = material.getMetaDataEntry("color_code", default = self.defaultColour) if material else self.defaultColour
position = extruder.getBottom().getMetaDataEntry("position", default = "0") #Position in the definition.
try:
position = int(position)