mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 10:47:49 -06:00
Machine name is now also displayed in open project dialog
CURA-1263
This commit is contained in:
parent
b3f1f6b4db
commit
04d268b1fb
3 changed files with 24 additions and 6 deletions
|
@ -52,7 +52,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
else:
|
else:
|
||||||
Logger.log("w", "Could not find reader that was able to read the scene data for 3MF workspace")
|
Logger.log("w", "Could not find reader that was able to read the scene data for 3MF workspace")
|
||||||
return WorkspaceReader.PreReadResult.failed
|
return WorkspaceReader.PreReadResult.failed
|
||||||
|
machine_name = ""
|
||||||
# Check if there are any conflicts, so we can ask the user.
|
# Check if there are any conflicts, so we can ask the user.
|
||||||
archive = zipfile.ZipFile(file_name, "r")
|
archive = zipfile.ZipFile(file_name, "r")
|
||||||
cura_file_names = [name for name in archive.namelist() if name.startswith("Cura/")]
|
cura_file_names = [name for name in archive.namelist() if name.startswith("Cura/")]
|
||||||
|
@ -62,14 +62,16 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
quality_changes_conflict = False
|
quality_changes_conflict = False
|
||||||
for container_stack_file in container_stack_files:
|
for container_stack_file in container_stack_files:
|
||||||
container_id = self._stripFileToId(container_stack_file)
|
container_id = self._stripFileToId(container_stack_file)
|
||||||
|
serialized = archive.open(container_stack_file).read().decode("utf-8")
|
||||||
|
if machine_name == "":
|
||||||
|
machine_name = self._getMachineNameFromSerializedStack(serialized)
|
||||||
stacks = self._container_registry.findContainerStacks(id=container_id)
|
stacks = self._container_registry.findContainerStacks(id=container_id)
|
||||||
if stacks:
|
if stacks:
|
||||||
# Check if there are any changes at all in any of the container stacks.
|
# Check if there are any changes at all in any of the container stacks.
|
||||||
id_list = self._getContainerIdListFromSerialized(archive.open(container_stack_file).read().decode("utf-8"))
|
id_list = self._getContainerIdListFromSerialized(serialized)
|
||||||
for index, container_id in enumerate(id_list):
|
for index, container_id in enumerate(id_list):
|
||||||
if stacks[0].getContainer(index).getId() != container_id:
|
if stacks[0].getContainer(index).getId() != container_id:
|
||||||
machine_conflict = True
|
machine_conflict = True
|
||||||
break
|
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
material_conflict = False
|
material_conflict = False
|
||||||
|
@ -138,6 +140,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
self._dialog.setQualityType(quality_type)
|
self._dialog.setQualityType(quality_type)
|
||||||
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.show()
|
self._dialog.show()
|
||||||
|
|
||||||
# Block until the dialog is closed.
|
# Block until the dialog is closed.
|
||||||
|
@ -437,3 +440,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
||||||
container_string = parser["general"].get("containers", "")
|
container_string = parser["general"].get("containers", "")
|
||||||
container_list = container_string.split(",")
|
container_list = container_string.split(",")
|
||||||
return [container_id for container_id in container_list if container_id != ""]
|
return [container_id for container_id in container_list if container_id != ""]
|
||||||
|
|
||||||
|
def _getMachineNameFromSerializedStack(self, serialized):
|
||||||
|
parser = configparser.ConfigParser(interpolation=None, empty_lines_in_values=False)
|
||||||
|
parser.read_string(serialized)
|
||||||
|
return parser["general"].get("name", "")
|
||||||
|
|
|
@ -35,6 +35,7 @@ class WorkspaceDialog(QObject):
|
||||||
self._quality_name = ""
|
self._quality_name = ""
|
||||||
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 = ""
|
||||||
|
|
||||||
machineConflictChanged = pyqtSignal()
|
machineConflictChanged = pyqtSignal()
|
||||||
qualityChangesConflictChanged = pyqtSignal()
|
qualityChangesConflictChanged = pyqtSignal()
|
||||||
|
@ -44,6 +45,15 @@ class WorkspaceDialog(QObject):
|
||||||
qualityNameChanged = pyqtSignal()
|
qualityNameChanged = pyqtSignal()
|
||||||
numSettingsOverridenByQualityChangesChanged = pyqtSignal()
|
numSettingsOverridenByQualityChangesChanged = pyqtSignal()
|
||||||
qualityTypeChanged = pyqtSignal()
|
qualityTypeChanged = pyqtSignal()
|
||||||
|
machineNameChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@pyqtProperty(str, notify = machineNameChanged)
|
||||||
|
def machineName(self):
|
||||||
|
return self._machine_name
|
||||||
|
|
||||||
|
def setMachineName(self, machine_name):
|
||||||
|
self._machine_name = machine_name
|
||||||
|
self.machineNameChanged.emit()
|
||||||
|
|
||||||
@pyqtProperty(str, notify=qualityTypeChanged)
|
@pyqtProperty(str, notify=qualityTypeChanged)
|
||||||
def qualityType(self):
|
def qualityType(self):
|
||||||
|
|
|
@ -88,12 +88,12 @@ UM.Dialog
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@action:label", "Type")
|
text: catalog.i18nc("@action:label", "Name")
|
||||||
width: parent.width / 3
|
width: parent.width / 3
|
||||||
}
|
}
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@action:label", "TOCHANGE")
|
text: manager.machineName
|
||||||
width: parent.width / 3
|
width: parent.width / 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue