Merge pull request #10639 from Ultimaker/CURA-8514_inconsistent_material_naming

Use the material name instead of brand + type + color
This commit is contained in:
Remco Burema 2021-10-20 10:47:32 +02:00 committed by GitHub
commit 6d93c651ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -59,6 +59,8 @@ class ExtrudersModel(ListModel):
defaultColors = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"] defaultColors = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"]
"""List of colours to display if there is no material or the material has no known colour. """ """List of colours to display if there is no material or the material has no known colour. """
MaterialNameRole = Qt.UserRole + 13
def __init__(self, parent = None): def __init__(self, parent = None):
"""Initialises the extruders model, defining the roles and listening for changes in the data. """Initialises the extruders model, defining the roles and listening for changes in the data.
@ -79,6 +81,7 @@ class ExtrudersModel(ListModel):
self.addRoleName(self.MaterialBrandRole, "material_brand") self.addRoleName(self.MaterialBrandRole, "material_brand")
self.addRoleName(self.ColorNameRole, "color_name") self.addRoleName(self.ColorNameRole, "color_name")
self.addRoleName(self.MaterialTypeRole, "material_type") self.addRoleName(self.MaterialTypeRole, "material_type")
self.addRoleName(self.MaterialNameRole, "material_name")
self._update_extruder_timer = QTimer() self._update_extruder_timer = QTimer()
self._update_extruder_timer.setInterval(100) self._update_extruder_timer.setInterval(100)
self._update_extruder_timer.setSingleShot(True) self._update_extruder_timer.setSingleShot(True)
@ -199,8 +202,8 @@ class ExtrudersModel(ListModel):
"material_brand": material_brand, "material_brand": material_brand,
"color_name": color_name, "color_name": color_name,
"material_type": extruder.material.getMetaDataEntry("material") if extruder.material else "", "material_type": extruder.material.getMetaDataEntry("material") if extruder.material else "",
"material_name": extruder.material.getMetaDataEntry("name") if extruder.material else "",
} }
items.append(item) items.append(item)
extruders_changed = True extruders_changed = True
@ -224,6 +227,7 @@ class ExtrudersModel(ListModel):
"material_brand": "", "material_brand": "",
"color_name": "", "color_name": "",
"material_type": "", "material_type": "",
"material_label": ""
} }
items.append(item) items.append(item)
if self._items != items: if self._items != items:

View File

@ -79,9 +79,9 @@ Cura.ExpandablePopup
// Label for the brand of the material // Label for the brand of the material
Label Label
{ {
id: materialBrandColorTypeLabel id: materialBrandNameLabel
text: model.material_brand == model.color_name ? model.color_name + " " + model.material_type : model.material_brand + " " + model.color_name + " " + model.material_type text: model.material_brand + " " + model.material_name
elide: Text.ElideRight elide: Text.ElideRight
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
@ -92,15 +92,15 @@ Cura.ExpandablePopup
Label Label
{ {
id: materialColorTypeLabel id: materialNameLabel
text: model.color_name + " " + model.material_type text: model.material_name
elide: Text.ElideRight elide: Text.ElideRight
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
renderType: Text.NativeRendering renderType: Text.NativeRendering
width: parent.width width: parent.width
visible: !materialBrandColorTypeLabel.visible && !truncated visible: !materialBrandNameLabel.visible && !truncated
} }
Label Label
@ -113,7 +113,7 @@ Cura.ExpandablePopup
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
renderType: Text.NativeRendering renderType: Text.NativeRendering
width: parent.width width: parent.width
visible: !materialBrandColorTypeLabel.visible && !materialColorTypeLabel.visible visible: !materialBrandNameLabel.visible && !materialNameLabel.visible
} }
// Label that shows the name of the variant // Label that shows the name of the variant
Label Label