mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 17:27:51 -06:00
Add activeQualityDisplayName to remove code duplication
CURA-6846
This commit is contained in:
parent
618cbffaa7
commit
c528000268
3 changed files with 38 additions and 32 deletions
|
@ -123,6 +123,14 @@ class MachineManager(QObject):
|
|||
self.globalContainerChanged.connect(self.printerConnectedStatusChanged)
|
||||
self.outputDevicesChanged.connect(self.printerConnectedStatusChanged)
|
||||
|
||||
# For updating active quality display name
|
||||
self.activeQualityChanged.connect(self.activeQualityDisplayNameChanged)
|
||||
self.activeIntentChanged.connect(self.activeQualityDisplayNameChanged)
|
||||
self.activeQualityGroupChanged.connect(self.activeQualityDisplayNameChanged)
|
||||
self.activeQualityChangesGroupChanged.connect(self.activeQualityDisplayNameChanged)
|
||||
|
||||
activeQualityDisplayNameChanged = pyqtSignal()
|
||||
|
||||
activeQualityGroupChanged = pyqtSignal()
|
||||
activeQualityChangesGroupChanged = pyqtSignal()
|
||||
|
||||
|
@ -629,16 +637,6 @@ class MachineManager(QObject):
|
|||
intent_category = category
|
||||
return intent_category
|
||||
|
||||
# Returns the human-readable name of the active intent category. If the intent category is "default", returns an
|
||||
# empty string.
|
||||
@pyqtProperty(str, notify = activeIntentChanged)
|
||||
def activeIntentName(self) -> str:
|
||||
intent_category = self.activeIntentCategory
|
||||
if intent_category == "default":
|
||||
intent_category = ""
|
||||
intent_name = intent_category.capitalize()
|
||||
return intent_name
|
||||
|
||||
# Provies a list of extruder positions that have a different intent from the active one.
|
||||
@pyqtProperty("QStringList", notify=activeIntentChanged)
|
||||
def extruderPositionsWithNonActiveIntent(self):
|
||||
|
@ -1591,6 +1589,34 @@ class MachineManager(QObject):
|
|||
if not no_dialog and self.hasUserSettings and self._application.getPreferences().getValue("cura/active_mode") == 1:
|
||||
self._application.discardOrKeepProfileChanges()
|
||||
|
||||
# The display name of currently active quality.
|
||||
# This display name is:
|
||||
# - For built-in qualities (quality/intent): the quality type name, such as "Fine", "Normal", etc.
|
||||
# - For custom qualities: <custom_quality_name> - <intent_name> - <quality_type_name>
|
||||
# Examples:
|
||||
# - "my_profile - Fine" (only based on a default quality, no intent involved)
|
||||
# - "my_profile - Engineering - Fine" (based on an intent)
|
||||
@pyqtProperty(str, notify = activeQualityDisplayNameChanged)
|
||||
def activeQualityDisplayName(self) -> str:
|
||||
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
|
||||
if global_stack is None:
|
||||
return ""
|
||||
|
||||
# Not a custom quality
|
||||
display_name = self.activeQualityOrQualityChangesName
|
||||
if global_stack.qualityChanges == empty_quality_changes_container:
|
||||
return display_name
|
||||
|
||||
# A custom quality
|
||||
intent_category = self.activeIntentCategory
|
||||
if intent_category != "default":
|
||||
from cura.Machines.Models.IntentCategoryModel import IntentCategoryModel
|
||||
intent_display_name = IntentCategoryModel.name_translation.get(intent_category, catalog.i18nc("@label", "Unknown"))
|
||||
display_name += " - {intent_name}".format(intent_name = intent_display_name)
|
||||
|
||||
display_name += " - {quality_level_name}".format(quality_level_name = global_stack.quality.getName())
|
||||
return display_name
|
||||
|
||||
## Change the intent category of the current printer.
|
||||
#
|
||||
# All extruders can change their profiles. If an intent profile is
|
||||
|
|
|
@ -100,17 +100,7 @@ Item
|
|||
|
||||
function generateActiveQualityText()
|
||||
{
|
||||
var result = Cura.MachineManager.activeQualityOrQualityChangesName
|
||||
|
||||
// If this is a custom quality, add intent (if present) and quality it is based on
|
||||
if (Cura.MachineManager.isActiveQualityCustom)
|
||||
{
|
||||
if (Cura.MachineManager.activeIntentName != "")
|
||||
{
|
||||
result += " - " + Cura.MachineManager.activeIntentName
|
||||
}
|
||||
result += " - " + Cura.MachineManager.activeQualityGroup.getName()
|
||||
}
|
||||
var result = Cura.MachineManager.activeQualityDisplayName
|
||||
|
||||
if (Cura.MachineManager.isActiveQualityExperimental)
|
||||
{
|
||||
|
|
|
@ -20,17 +20,7 @@ RowLayout
|
|||
{
|
||||
if (Cura.MachineManager.activeStack)
|
||||
{
|
||||
var text = Cura.MachineManager.activeQualityOrQualityChangesName
|
||||
|
||||
// If this is a custom quality, add intent (if present) and quality it is based on
|
||||
if (Cura.MachineManager.isActiveQualityCustom)
|
||||
{
|
||||
if (Cura.MachineManager.activeIntentName != "")
|
||||
{
|
||||
text += " - " + Cura.MachineManager.activeIntentName
|
||||
}
|
||||
text += " - " + Cura.MachineManager.activeQualityGroup.getName()
|
||||
}
|
||||
var text = Cura.MachineManager.activeQualityDisplayName
|
||||
|
||||
if (!Cura.MachineManager.hasNotSupportedQuality)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue