mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
Add is_experimental to Qt models and QMLs
CURA-5879
This commit is contained in:
parent
c9c7ef7d67
commit
2c8ed99281
@ -21,6 +21,7 @@ class QualityProfilesDropDownMenuModel(ListModel):
|
||||
AvailableRole = Qt.UserRole + 5
|
||||
QualityGroupRole = Qt.UserRole + 6
|
||||
QualityChangesGroupRole = Qt.UserRole + 7
|
||||
IsExperimentalRole = Qt.UserRole + 8
|
||||
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
@ -32,6 +33,7 @@ class QualityProfilesDropDownMenuModel(ListModel):
|
||||
self.addRoleName(self.AvailableRole, "available") #Whether the quality profile is available in our current nozzle + material.
|
||||
self.addRoleName(self.QualityGroupRole, "quality_group")
|
||||
self.addRoleName(self.QualityChangesGroupRole, "quality_changes_group")
|
||||
self.addRoleName(self.IsExperimentalRole, "is_experimental")
|
||||
|
||||
self._application = Application.getInstance()
|
||||
self._machine_manager = self._application.getMachineManager()
|
||||
@ -74,7 +76,8 @@ class QualityProfilesDropDownMenuModel(ListModel):
|
||||
"layer_height": layer_height,
|
||||
"layer_height_unit": self._layer_height_unit,
|
||||
"available": quality_group.is_available,
|
||||
"quality_group": quality_group}
|
||||
"quality_group": quality_group,
|
||||
"is_experimental": quality_group.is_experimental}
|
||||
|
||||
item_list.append(item)
|
||||
|
||||
|
@ -4,6 +4,9 @@
|
||||
from typing import Dict, Optional, List, Set
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSlot
|
||||
|
||||
from UM.Util import parseBool
|
||||
|
||||
from cura.Machines.ContainerNode import ContainerNode
|
||||
|
||||
|
||||
@ -29,6 +32,7 @@ class QualityGroup(QObject):
|
||||
self.nodes_for_extruders = {} # type: Dict[int, ContainerNode]
|
||||
self.quality_type = quality_type
|
||||
self.is_available = False
|
||||
self.is_experimental = False
|
||||
|
||||
@pyqtSlot(result = str)
|
||||
def getName(self) -> str:
|
||||
@ -51,3 +55,17 @@ class QualityGroup(QObject):
|
||||
for extruder_node in self.nodes_for_extruders.values():
|
||||
result.append(extruder_node)
|
||||
return result
|
||||
|
||||
def setGlobalNode(self, node: "ContainerNode") -> None:
|
||||
self.node_for_global = node
|
||||
|
||||
# Update is_experimental flag
|
||||
is_experimental = parseBool(node.getMetaDataEntry("is_experimental", False))
|
||||
self.is_experimental |= is_experimental
|
||||
|
||||
def setExtruderNode(self, position: int, node: "ContainerNode") -> None:
|
||||
self.nodes_for_extruders[position] = node
|
||||
|
||||
# Update is_experimental flag
|
||||
is_experimental = parseBool(node.getMetaDataEntry("is_experimental", False))
|
||||
self.is_experimental |= is_experimental
|
||||
|
@ -235,7 +235,7 @@ class QualityManager(QObject):
|
||||
|
||||
for quality_type, quality_node in node.quality_type_map.items():
|
||||
quality_group = QualityGroup(quality_node.getMetaDataEntry("name", ""), quality_type)
|
||||
quality_group.node_for_global = quality_node
|
||||
quality_group.setGlobalNode(quality_node)
|
||||
quality_group_dict[quality_type] = quality_group
|
||||
break
|
||||
|
||||
@ -337,7 +337,7 @@ class QualityManager(QObject):
|
||||
|
||||
quality_group = quality_group_dict[quality_type]
|
||||
if position not in quality_group.nodes_for_extruders:
|
||||
quality_group.nodes_for_extruders[position] = quality_node
|
||||
quality_group.setExtruderNode(position, quality_node)
|
||||
|
||||
# If the machine has its own specific qualities, for extruders, it should skip the global qualities
|
||||
# and use the material/variant specific qualities.
|
||||
@ -367,7 +367,7 @@ class QualityManager(QObject):
|
||||
if node and node.quality_type_map:
|
||||
for quality_type, quality_node in node.quality_type_map.items():
|
||||
quality_group = QualityGroup(quality_node.getMetaDataEntry("name", ""), quality_type)
|
||||
quality_group.node_for_global = quality_node
|
||||
quality_group.setGlobalNode(quality_node)
|
||||
quality_group_dict[quality_type] = quality_group
|
||||
break
|
||||
|
||||
|
@ -616,6 +616,14 @@ class MachineManager(QObject):
|
||||
is_supported = self._current_quality_group.is_available
|
||||
return is_supported
|
||||
|
||||
@pyqtProperty(bool, notify = activeQualityGroupChanged)
|
||||
def isActiveQualityExperimental(self) -> bool:
|
||||
is_experimental = False
|
||||
if self._global_container_stack:
|
||||
if self._current_quality_group:
|
||||
is_experimental = self._current_quality_group.is_experimental
|
||||
return is_experimental
|
||||
|
||||
## Returns whether there is anything unsupported in the current set-up.
|
||||
#
|
||||
# The current set-up signifies the global stack and all extruder stacks,
|
||||
|
@ -17,7 +17,11 @@ Menu
|
||||
|
||||
MenuItem
|
||||
{
|
||||
text: (model.layer_height != "") ? model.name + " - " + model.layer_height + model.layer_height_unit : model.name
|
||||
text: {
|
||||
var full_text = (model.layer_height != "") ? model.name + " - " + model.layer_height + model.layer_height_unit : model.name;
|
||||
full_text += model.is_experimental ? " - Experimental" : "";
|
||||
return full_text;
|
||||
}
|
||||
checkable: true
|
||||
checked: Cura.MachineManager.activeQualityOrQualityChangesName == model.name
|
||||
exclusiveGroup: group
|
||||
|
@ -66,6 +66,9 @@ Item
|
||||
|
||||
function generateActiveQualityText () {
|
||||
var result = Cura.MachineManager.activeQualityOrQualityChangesName;
|
||||
if (Cura.MachineManager.isActiveQualityExperimental) {
|
||||
result += " (Experimental)";
|
||||
}
|
||||
|
||||
if (Cura.MachineManager.isActiveQualitySupported) {
|
||||
if (Cura.MachineManager.activeQualityLayerHeight > 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user