mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 09:17:50 -06:00
Adjust the text of the material according to the size of the window
Now, when the size of the Cura window changes and the configurationSelector gets resized, instead of eliding the material text it will now change as follows: * If it fits, display "Brand, Color, and Type" of material (e.g. Ultimaker Black PLA) * If "Brand, Color, and Type" doesn't fit, change it to "Color and Type" of material (e.g. Black PLA) * If "Color Type" doesn't fit either, display only the type (e.g. PLA) * If "Type" doesn't fit, elide it CURA-8013
This commit is contained in:
parent
bbfa93c9a7
commit
fae5e2cffd
2 changed files with 54 additions and 4 deletions
|
@ -53,6 +53,9 @@ class ExtrudersModel(ListModel):
|
|||
EnabledRole = Qt.UserRole + 11
|
||||
"""Is the extruder enabled?"""
|
||||
|
||||
MaterialTypeRole = Qt.UserRole + 12
|
||||
"""The type of the material (e.g. PLA, ABS, PETG, etc.)."""
|
||||
|
||||
defaultColors = ["#ffc924", "#86ec21", "#22eeee", "#245bff", "#9124ff", "#ff24c8"]
|
||||
"""List of colours to display if there is no material or the material has no known colour. """
|
||||
|
||||
|
@ -75,6 +78,7 @@ class ExtrudersModel(ListModel):
|
|||
self.addRoleName(self.StackRole, "stack")
|
||||
self.addRoleName(self.MaterialBrandRole, "material_brand")
|
||||
self.addRoleName(self.ColorNameRole, "color_name")
|
||||
self.addRoleName(self.MaterialTypeRole, "material_type")
|
||||
self._update_extruder_timer = QTimer()
|
||||
self._update_extruder_timer.setInterval(100)
|
||||
self._update_extruder_timer.setSingleShot(True)
|
||||
|
@ -193,7 +197,8 @@ class ExtrudersModel(ListModel):
|
|||
"variant": extruder.variant.getName() if extruder.variant else "", # e.g. print core
|
||||
"stack": extruder,
|
||||
"material_brand": material_brand,
|
||||
"color_name": color_name
|
||||
"color_name": color_name,
|
||||
"material_type": extruder.material.getMetaDataEntry("material") if extruder.material else "",
|
||||
}
|
||||
|
||||
items.append(item)
|
||||
|
@ -218,6 +223,7 @@ class ExtrudersModel(ListModel):
|
|||
"stack": None,
|
||||
"material_brand": "",
|
||||
"color_name": "",
|
||||
"material_type": "",
|
||||
}
|
||||
items.append(item)
|
||||
if self._items != items:
|
||||
|
|
|
@ -63,9 +63,9 @@ Cura.ExpandablePopup
|
|||
// Label for the brand of the material
|
||||
Label
|
||||
{
|
||||
id: typeAndBrandNameLabel
|
||||
id: materialBrandColorTypeLabel
|
||||
|
||||
text: model.material_brand + " " + model.material
|
||||
text: model.material_brand == model.color_name ? model.color_name + " " + model.material_type : model.material_brand + " " + model.color_name + " " + model.material_type
|
||||
elide: Text.ElideRight
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
|
@ -79,6 +79,50 @@ Cura.ExpandablePopup
|
|||
right: parent.right
|
||||
rightMargin: UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
visible: !truncated
|
||||
}
|
||||
|
||||
Label
|
||||
{
|
||||
id: materialColorTypeLabel
|
||||
|
||||
text: model.color_name + " " + model.material_type
|
||||
elide: Text.ElideRight
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
renderType: Text.NativeRendering
|
||||
|
||||
anchors
|
||||
{
|
||||
top: extruderIcon.top
|
||||
left: extruderIcon.right
|
||||
leftMargin: UM.Theme.getSize("default_margin").width
|
||||
right: parent.right
|
||||
rightMargin: UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
|
||||
visible: !materialBrandColorTypeLabel.visible && !truncated
|
||||
}
|
||||
|
||||
Label
|
||||
{
|
||||
id: materialTypeLabel
|
||||
|
||||
text: model.material_type
|
||||
elide: Text.ElideRight
|
||||
font: UM.Theme.getFont("default")
|
||||
color: UM.Theme.getColor("text")
|
||||
renderType: Text.NativeRendering
|
||||
|
||||
anchors
|
||||
{
|
||||
top: extruderIcon.top
|
||||
left: extruderIcon.right
|
||||
leftMargin: UM.Theme.getSize("default_margin").width
|
||||
right: parent.right
|
||||
rightMargin: UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
visible: !materialBrandColorTypeLabel.visible && !materialColorTypeLabel.visible
|
||||
}
|
||||
// Label that shows the name of the variant
|
||||
Label
|
||||
|
@ -97,7 +141,7 @@ Cura.ExpandablePopup
|
|||
{
|
||||
left: extruderIcon.right
|
||||
leftMargin: UM.Theme.getSize("default_margin").width
|
||||
top: typeAndBrandNameLabel.bottom
|
||||
top: materialBrandColorTypeLabel.bottom
|
||||
right: parent.right
|
||||
rightMargin: UM.Theme.getSize("default_margin").width
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue