mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
CURA-4606 factored activeMaterialName out
This commit is contained in:
parent
f9e2d7fe2c
commit
ad6548a5dc
3 changed files with 15 additions and 23 deletions
|
@ -48,6 +48,7 @@ class MachineManager(QObject):
|
||||||
self._global_container_stack = None # type: GlobalStack
|
self._global_container_stack = None # type: GlobalStack
|
||||||
|
|
||||||
self._current_root_material_id = {}
|
self._current_root_material_id = {}
|
||||||
|
self._current_root_material_name = {}
|
||||||
self._current_quality_group = None
|
self._current_quality_group = None
|
||||||
self._current_quality_changes_group = None
|
self._current_quality_changes_group = None
|
||||||
|
|
||||||
|
@ -445,15 +446,6 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@pyqtProperty(str, notify = activeMaterialChanged)
|
|
||||||
def activeMaterialName(self) -> str:
|
|
||||||
if self._active_container_stack:
|
|
||||||
material = self._active_container_stack.material
|
|
||||||
if material:
|
|
||||||
return material.getName()
|
|
||||||
|
|
||||||
return ""
|
|
||||||
|
|
||||||
@pyqtProperty("QVariantList", notify=activeVariantChanged)
|
@pyqtProperty("QVariantList", notify=activeVariantChanged)
|
||||||
def activeVariantNames(self) -> List[str]:
|
def activeVariantNames(self) -> List[str]:
|
||||||
result = []
|
result = []
|
||||||
|
@ -533,17 +525,6 @@ class MachineManager(QObject):
|
||||||
|
|
||||||
return 0 # No quality profile.
|
return 0 # No quality profile.
|
||||||
|
|
||||||
@pyqtProperty(str, notify=activeQualityChanged)
|
|
||||||
def activeQualityName(self) -> str:
|
|
||||||
if self._active_container_stack and self._global_container_stack:
|
|
||||||
quality = self._global_container_stack.qualityChanges
|
|
||||||
if quality and not isinstance(quality, type(self._empty_quality_changes_container)):
|
|
||||||
return quality.getName()
|
|
||||||
quality = self._active_container_stack.quality
|
|
||||||
if quality:
|
|
||||||
return quality.getName()
|
|
||||||
return ""
|
|
||||||
|
|
||||||
@pyqtProperty(str, notify=activeQualityChanged)
|
@pyqtProperty(str, notify=activeQualityChanged)
|
||||||
def activeQualityId(self) -> str:
|
def activeQualityId(self) -> str:
|
||||||
if self._active_container_stack:
|
if self._active_container_stack:
|
||||||
|
@ -935,6 +916,15 @@ class MachineManager(QObject):
|
||||||
self._current_root_material_id[position] = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file")
|
self._current_root_material_id[position] = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file")
|
||||||
return self._current_root_material_id
|
return self._current_root_material_id
|
||||||
|
|
||||||
|
@pyqtProperty("QVariant", notify = rootMaterialChanged)
|
||||||
|
def currentRootMaterialName(self):
|
||||||
|
# initial filling the current_root_material_name
|
||||||
|
for position in self._global_container_stack.extruders:
|
||||||
|
if position not in self._current_root_material_name:
|
||||||
|
material = self._global_container_stack.extruders[position].material
|
||||||
|
self._current_root_material_name[position] = material.getName()
|
||||||
|
return self._current_root_material_name
|
||||||
|
|
||||||
def _setEmptyQuality(self):
|
def _setEmptyQuality(self):
|
||||||
self._current_quality_group = None
|
self._current_quality_group = None
|
||||||
self._current_quality_changes_group = None
|
self._current_quality_changes_group = None
|
||||||
|
@ -1015,8 +1005,10 @@ class MachineManager(QObject):
|
||||||
self._global_container_stack.extruders[position].material = self._empty_material_container
|
self._global_container_stack.extruders[position].material = self._empty_material_container
|
||||||
# The _current_root_material_id is used in the MaterialMenu to see which material is selected
|
# The _current_root_material_id is used in the MaterialMenu to see which material is selected
|
||||||
root_material_id = container_node.metadata["base_file"]
|
root_material_id = container_node.metadata["base_file"]
|
||||||
|
root_material_name = container_node.getContainer().getName()
|
||||||
if root_material_id != self._current_root_material_id[position]:
|
if root_material_id != self._current_root_material_id[position]:
|
||||||
self._current_root_material_id[position] = root_material_id
|
self._current_root_material_id[position] = root_material_id
|
||||||
|
self._current_root_material_name[position] = root_material_name
|
||||||
self.rootMaterialChanged.emit()
|
self.rootMaterialChanged.emit()
|
||||||
|
|
||||||
def activeMaterialsCompatible(self):
|
def activeMaterialsCompatible(self):
|
||||||
|
|
|
@ -544,4 +544,4 @@ Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -252,8 +252,8 @@ Column
|
||||||
{
|
{
|
||||||
id: materialSelection
|
id: materialSelection
|
||||||
|
|
||||||
text: Cura.MachineManager.activeMaterialName
|
text: Cura.MachineManager.currentRootMaterialName[base.currentExtruderIndex]
|
||||||
tooltip: Cura.MachineManager.activeMaterialName
|
tooltip: Cura.MachineManager.currentRootMaterialName[base.currentExtruderIndex]
|
||||||
visible: Cura.MachineManager.hasMaterials
|
visible: Cura.MachineManager.hasMaterials
|
||||||
enabled: !extrudersList.visible || base.currentExtruderIndex > -1
|
enabled: !extrudersList.visible || base.currentExtruderIndex > -1
|
||||||
height: UM.Theme.getSize("setting_control").height
|
height: UM.Theme.getSize("setting_control").height
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue