mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Fix saving of Global/Extruder stack
Since we now have proper types for them, we can simplify the save code
This commit is contained in:
parent
d3d2bdfaeb
commit
4da2de532b
1 changed files with 11 additions and 7 deletions
|
@ -62,6 +62,8 @@ from cura.Settings.ContainerSettingsModel import ContainerSettingsModel
|
||||||
from cura.Settings.MaterialSettingsVisibilityHandler import MaterialSettingsVisibilityHandler
|
from cura.Settings.MaterialSettingsVisibilityHandler import MaterialSettingsVisibilityHandler
|
||||||
from cura.Settings.QualitySettingsModel import QualitySettingsModel
|
from cura.Settings.QualitySettingsModel import QualitySettingsModel
|
||||||
from cura.Settings.ContainerManager import ContainerManager
|
from cura.Settings.ContainerManager import ContainerManager
|
||||||
|
from cura.Settings.GlobalStack import GlobalStack
|
||||||
|
from cura.Settings.ExtruderStack import ExtruderStack
|
||||||
|
|
||||||
from PyQt5.QtCore import QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
from PyQt5.QtCore import QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
|
||||||
from UM.FlameProfiler import pyqtSlot
|
from UM.FlameProfiler import pyqtSlot
|
||||||
|
@ -427,16 +429,18 @@ class CuraApplication(QtApplication):
|
||||||
|
|
||||||
mime_type = ContainerRegistry.getMimeTypeForContainer(type(stack))
|
mime_type = ContainerRegistry.getMimeTypeForContainer(type(stack))
|
||||||
file_name = urllib.parse.quote_plus(stack.getId()) + "." + mime_type.preferredSuffix
|
file_name = urllib.parse.quote_plus(stack.getId()) + "." + mime_type.preferredSuffix
|
||||||
stack_type = stack.getMetaDataEntry("type", None)
|
|
||||||
path = None
|
path = None
|
||||||
if not stack_type or stack_type == "machine":
|
if isinstance(stack, GlobalStack):
|
||||||
path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
|
path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
|
||||||
elif stack_type == "extruder_train":
|
elif isinstance(stack, ExtruderStack):
|
||||||
path = Resources.getStoragePath(self.ResourceTypes.ExtruderStack, file_name)
|
path = Resources.getStoragePath(self.ResourceTypes.ExtruderStack, file_name)
|
||||||
if path:
|
else:
|
||||||
stack.setPath(path)
|
path = Resources.getStoragePath(Resources.ContainerStacks, file_name)
|
||||||
with SaveFile(path, "wt") as f:
|
|
||||||
f.write(data)
|
stack.setPath(path)
|
||||||
|
with SaveFile(path, "wt") as f:
|
||||||
|
f.write(data)
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot(str, result = QUrl)
|
@pyqtSlot(str, result = QUrl)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue