Unify activeQualityDisplayNameMap string creation

Generation quality display names in `CustomPrintSetup.qml` and `PrintSetupSelectorHeader.qml` were so similar that I decided to combine the logic.

Cura-9773
This commit is contained in:
c.lamboo 2022-11-25 16:09:55 +01:00
parent e8f6786e97
commit 52ee149edc
3 changed files with 46 additions and 71 deletions

View file

@ -67,7 +67,7 @@ Item
UM.Label
{
id: textLabel
text: Cura.MachineManager.activeQualityDisplayNameMap["main"]
text: Cura.MachineManager.activeQualityDisplayNameStringParts[0]
Layout.margins: 0
Layout.maximumWidth: Math.floor(parent.width * 0.7) // Always leave >= 30% for the rest of the row.
height: contentHeight
@ -77,7 +77,8 @@ Item
UM.Label
{
text: activeQualityDetailText()
text: Cura.MachineManager.activeQualityDisplayNameStringParts.slice(1).join(" - ")
color: UM.Theme.getColor("text_detail")
Layout.margins: 0
Layout.fillWidth: true
@ -85,32 +86,6 @@ Item
height: contentHeight
elide: Text.ElideRight
wrapMode: Text.NoWrap
function activeQualityDetailText()
{
var resultMap = Cura.MachineManager.activeQualityDisplayNameMap
var resultSuffix = resultMap["suffix"]
var result = ""
if (Cura.MachineManager.isActiveQualityExperimental)
{
resultSuffix += " (Experimental)"
}
if (Cura.MachineManager.isActiveQualitySupported)
{
if (Cura.MachineManager.activeQualityLayerHeight > 0)
{
if (resultSuffix)
{
result += " - " + resultSuffix
}
result += " - "
result += Cura.MachineManager.activeQualityLayerHeight + "mm"
}
}
return result
}
}
}