Browse Source

Split of `getStringParts` function

Spit into `getMainStringParts` and `getTailStringParts` so we can easily differentiate between the two in the front-end.

Cura-9773
c.lamboo 2 years ago
parent
commit
8e8437eab0

+ 15 - 4
cura/Settings/ActiveQuality.py

@@ -16,16 +16,25 @@ class ActiveQuality:
     layer_height: float = None      # Layer height of quality in mm. For example 0.4
     is_experimental: bool = False   # If the quality experimental.
 
-    def getStringParts(self) -> List[str]:
+    def getMainStringParts(self) -> List[str]:
         string_parts = []
 
         if self.custom_profile is not None:
             string_parts.append(self.custom_profile)
-
-        if self.intent_category is not "default":
-            string_parts.append(f"{self.intent_name} - {self.profile}")
         else:
             string_parts.append(self.profile)
+            if self.intent_category is not "default":
+                string_parts.append(self.intent_name)
+
+        return string_parts
+
+    def getTailStringParts(self) -> List[str]:
+        string_parts = []
+
+        if self.custom_profile is not None:
+            string_parts.append(self.profile)
+            if self.intent_category is not "default":
+                string_parts.append(self.intent_name)
 
         if self.layer_height:
             string_parts.append(f"{self.layer_height}mm")
@@ -35,3 +44,5 @@ class ActiveQuality:
 
         return string_parts
 
+    def getStringParts(self) -> List[str]:
+        return self.getMainStringParts() + self.getTailStringParts()

+ 12 - 2
cura/Settings/MachineManager.py

@@ -1636,18 +1636,28 @@ class MachineManager(QObject):
     def activeQualityDisplayNameStringParts(self) -> List[str]:
         return self.activeQualityDisplayNameMap.getStringParts()
 
+    @pyqtProperty("QList<QString>", notify = activeQualityDisplayNameChanged)
+    def activeQualityDisplayNameMainStringParts(self) -> List[str]:
+        return self.activeQualityDisplayNameMap.getMainStringParts()
+
+    @pyqtProperty("QList<QString>", notify = activeQualityDisplayNameChanged)
+    def activeQualityDisplayNameTailStringParts(self) -> List[str]:
+        return self.activeQualityDisplayNameMap.getTailStringParts()
+
     @pyqtProperty("QVariantMap", notify = activeQualityDisplayNameChanged)
     def activeQualityDisplayNameMap(self) -> ActiveQuality:
         global_stack = self._application.getGlobalContainerStack()
         if global_stack is None:
             return ActiveQuality()
 
-        return ActiveQuality(profile = global_stack.quality.getName(),
+        return ActiveQuality(
+            profile = global_stack.quality.getName(),
             intent_category = self.activeIntentCategory,
             intent_name = IntentCategoryModel.translation(self.activeIntentCategory, "name", self.activeIntentCategory.title()),
             custom_profile = self.activeQualityOrQualityChangesName if global_stack.qualityChanges is not empty_quality_changes_container else None,
             layer_height = self.activeQualityLayerHeight if self.isActiveQualitySupported else None,
-            is_experimental = self.isActiveQualityExperimental and self.isActiveQualitySupported)
+            is_experimental = self.isActiveQualityExperimental and self.isActiveQualitySupported
+        )
 
     @pyqtSlot(str)
     def setIntentByCategory(self, intent_category: str) -> None:

+ 13 - 2
resources/qml/PrintSetupSelector/Custom/CustomPrintSetup.qml

@@ -67,7 +67,7 @@ Item
                 UM.Label
                 {
                     id: textLabel
-                    text: Cura.MachineManager.activeQualityDisplayNameStringParts[0]
+                    text: Cura.MachineManager.activeQualityDisplayNameMainStringParts.join(" - ")
                     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,18 @@ Item
 
                 UM.Label
                 {
-                    text: ` - ${Cura.MachineManager.activeQualityDisplayNameStringParts.slice(1).join(" - ")}`
+                    text:
+                    {
+                        const string_parts = Cura.MachineManager.activeQualityDisplayNameTailStringParts;
+                        if (string_parts.length === 0)
+                        {
+                            return "";
+                        }
+                        else
+                        {
+                            ` - ${string_parts.join(" - ")}`
+                        }
+                    }
 
                     color: UM.Theme.getColor("text_detail")
                     Layout.margins: 0