mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Material labels are now also displayed in the open project dialog
CURA-1263
This commit is contained in:
parent
c950288b86
commit
f782a76324
3 changed files with 47 additions and 10 deletions
|
@ -12,6 +12,8 @@ from UM.Job import Job
|
||||||
from UM.Preferences import Preferences
|
from UM.Preferences import Preferences
|
||||||
from .WorkspaceDialog import WorkspaceDialog
|
from .WorkspaceDialog import WorkspaceDialog
|
||||||
|
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
from cura.Settings.ExtruderManager import ExtruderManager
|
from cura.Settings.ExtruderManager import ExtruderManager
|
||||||
|
|
||||||
import zipfile
|
import zipfile
|
||||||
|
@ -74,6 +76,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
machine_conflict = True
|
machine_conflict = True
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
|
material_labels = []
|
||||||
material_conflict = False
|
material_conflict = False
|
||||||
xml_material_profile = self._getXmlProfileClass()
|
xml_material_profile = self._getXmlProfileClass()
|
||||||
if self._material_container_suffix is None:
|
if self._material_container_suffix is None:
|
||||||
|
@ -83,10 +86,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
for material_container_file in material_container_files:
|
for material_container_file in material_container_files:
|
||||||
container_id = self._stripFileToId(material_container_file)
|
container_id = self._stripFileToId(material_container_file)
|
||||||
materials = self._container_registry.findInstanceContainers(id=container_id)
|
materials = self._container_registry.findInstanceContainers(id=container_id)
|
||||||
|
material_labels.append(self._getMaterialLabelFromSerialized(archive.open(material_container_file).read().decode("utf-8")))
|
||||||
if materials and not materials[0].isReadOnly(): # Only non readonly materials can be in conflict
|
if materials and not materials[0].isReadOnly(): # Only non readonly materials can be in conflict
|
||||||
material_conflict = True
|
material_conflict = True
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
# Check if any quality_changes instance container is in conflict.
|
# Check if any quality_changes instance container is in conflict.
|
||||||
instance_container_files = [name for name in cura_file_names if name.endswith(self._instance_container_suffix)]
|
instance_container_files = [name for name in cura_file_names if name.endswith(self._instance_container_suffix)]
|
||||||
quality_name = ""
|
quality_name = ""
|
||||||
|
@ -141,6 +144,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
self._dialog.setNumSettingsOverridenByQualityChanges(num_settings_overriden_by_quality_changes)
|
self._dialog.setNumSettingsOverridenByQualityChanges(num_settings_overriden_by_quality_changes)
|
||||||
self._dialog.setActiveMode(active_mode)
|
self._dialog.setActiveMode(active_mode)
|
||||||
self._dialog.setMachineName(machine_name)
|
self._dialog.setMachineName(machine_name)
|
||||||
|
self._dialog.setMaterialLabels(material_labels)
|
||||||
self._dialog.show()
|
self._dialog.show()
|
||||||
|
|
||||||
# Block until the dialog is closed.
|
# Block until the dialog is closed.
|
||||||
|
@ -445,3 +449,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
parser = configparser.ConfigParser(interpolation=None, empty_lines_in_values=False)
|
parser = configparser.ConfigParser(interpolation=None, empty_lines_in_values=False)
|
||||||
parser.read_string(serialized)
|
parser.read_string(serialized)
|
||||||
return parser["general"].get("name", "")
|
return parser["general"].get("name", "")
|
||||||
|
|
||||||
|
def _getMaterialLabelFromSerialized(self, serialized):
|
||||||
|
data = ET.fromstring(serialized)
|
||||||
|
metadata = data.iterfind("./um:metadata/um:name/um:label", {"um": "http://www.ultimaker.com/material"})
|
||||||
|
for entry in metadata:
|
||||||
|
return entry.text
|
||||||
|
pass
|
|
@ -37,6 +37,7 @@ class WorkspaceDialog(QObject):
|
||||||
self._num_settings_overriden_by_quality_changes = 0
|
self._num_settings_overriden_by_quality_changes = 0
|
||||||
self._quality_type = ""
|
self._quality_type = ""
|
||||||
self._machine_name = ""
|
self._machine_name = ""
|
||||||
|
self._material_labels = []
|
||||||
|
|
||||||
machineConflictChanged = pyqtSignal()
|
machineConflictChanged = pyqtSignal()
|
||||||
qualityChangesConflictChanged = pyqtSignal()
|
qualityChangesConflictChanged = pyqtSignal()
|
||||||
|
@ -47,6 +48,15 @@ class WorkspaceDialog(QObject):
|
||||||
numSettingsOverridenByQualityChangesChanged = pyqtSignal()
|
numSettingsOverridenByQualityChangesChanged = pyqtSignal()
|
||||||
qualityTypeChanged = pyqtSignal()
|
qualityTypeChanged = pyqtSignal()
|
||||||
machineNameChanged = pyqtSignal()
|
machineNameChanged = pyqtSignal()
|
||||||
|
materialLabelsChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtProperty("QVariantList", notify = materialLabelsChanged)
|
||||||
|
def materialLabels(self):
|
||||||
|
return self._material_labels
|
||||||
|
|
||||||
|
def setMaterialLabels(self, material_labels):
|
||||||
|
self._material_labels = material_labels
|
||||||
|
self.materialLabelsChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty(str, notify = machineNameChanged)
|
@pyqtProperty(str, notify = machineNameChanged)
|
||||||
def machineName(self):
|
def machineName(self):
|
||||||
|
|
|
@ -192,19 +192,35 @@ UM.Dialog
|
||||||
text: catalog.i18nc("@action:label", "Material settings")
|
text: catalog.i18nc("@action:label", "Material settings")
|
||||||
font.bold: true
|
font.bold: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Repeater
|
||||||
|
{
|
||||||
|
model: manager.materialLabels
|
||||||
|
delegate: Row
|
||||||
|
{
|
||||||
|
width: parent.width
|
||||||
|
height: childrenRect.height
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@action:label", "Name")
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: modelData
|
||||||
|
width: parent.width / 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Row
|
Row
|
||||||
{
|
{
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
Label
|
Item
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@action:label", "Type")
|
width: parent.width / 3 * 2
|
||||||
width: parent.width / 3
|
height: comboboxHeight
|
||||||
}
|
|
||||||
Label
|
|
||||||
{
|
|
||||||
text: catalog.i18nc("@action:label", "TOCHANGE")
|
|
||||||
width: parent.width / 3
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UM.TooltipArea
|
UM.TooltipArea
|
||||||
|
@ -213,7 +229,7 @@ UM.Dialog
|
||||||
width: parent.width / 3
|
width: parent.width / 3
|
||||||
height: visible ? comboboxHeight : 0
|
height: visible ? comboboxHeight : 0
|
||||||
visible: manager.materialConflict
|
visible: manager.materialConflict
|
||||||
text: catalog.i18nc("@info:tooltip", "How should the conflict in the profile be resolved?")
|
text: catalog.i18nc("@info:tooltip", "How should the conflict in the material be resolved?")
|
||||||
ComboBox
|
ComboBox
|
||||||
{
|
{
|
||||||
model: resolveStrategiesModel
|
model: resolveStrategiesModel
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue