From 9d618282ed614b78ee263187af71f6ed25c3603f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 9 Jun 2016 16:30:54 +0200 Subject: [PATCH] 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. --- cura/ExtrudersModel.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cura/ExtrudersModel.py b/cura/ExtrudersModel.py index 2a4ae54310..960c05bd5e 100644 --- a/cura/ExtrudersModel.py +++ b/cura/ExtrudersModel.py @@ -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)