mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 02:37:49 -06:00
WIP: Make material export work
This commit is contained in:
parent
4f29fc9ab2
commit
0b859bb308
2 changed files with 41 additions and 10 deletions
|
@ -408,7 +408,7 @@ class ContainerManager(QObject):
|
|||
return {"status": "error", "message": "Invalid path"}
|
||||
|
||||
mime_type = None
|
||||
if not file_type in self._container_name_filters:
|
||||
if file_type not in self._container_name_filters:
|
||||
try:
|
||||
mime_type = MimeTypeDatabase.getMimeTypeForFile(file_url)
|
||||
except MimeTypeNotFoundError:
|
||||
|
@ -448,7 +448,7 @@ class ContainerManager(QObject):
|
|||
with SaveFile(file_url, "w") as f:
|
||||
f.write(contents)
|
||||
|
||||
return { "status": "success", "message": "Succesfully exported container", "path": file_url}
|
||||
return {"status": "success", "message": "Successfully exported container", "path": file_url}
|
||||
|
||||
## Imports a profile from a file
|
||||
#
|
||||
|
|
|
@ -119,8 +119,8 @@ Item
|
|||
text: catalog.i18nc("@action:button", "Export")
|
||||
iconName: "document-export"
|
||||
onClicked: {
|
||||
forceActiveFocus()
|
||||
// TODO
|
||||
forceActiveFocus();
|
||||
exportMaterialDialog.open();
|
||||
}
|
||||
enabled: currentItem != null
|
||||
}
|
||||
|
@ -144,6 +144,37 @@ Item
|
|||
}
|
||||
}
|
||||
|
||||
FileDialog
|
||||
{
|
||||
id: exportMaterialDialog
|
||||
title: catalog.i18nc("@title:window", "Export Material")
|
||||
selectExisting: false
|
||||
nameFilters: Cura.ContainerManager.getContainerNameFilters("material")
|
||||
folder: CuraApplication.getDefaultPath("dialog_material_path")
|
||||
onAccepted:
|
||||
{
|
||||
var result = Cura.ContainerManager.exportContainer(base.currentItem.root_material_id, selectedNameFilter, fileUrl);
|
||||
|
||||
messageDialog.title = catalog.i18nc("@title:window", "Export Material");
|
||||
if (result.status == "error") {
|
||||
messageDialog.icon = StandardIcon.Critical;
|
||||
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tags <filename> and <message>!", "Failed to export material to <filename>%1</filename>: <message>%2</message>").arg(fileUrl).arg(result.message);
|
||||
messageDialog.open();
|
||||
}
|
||||
else if (result.status == "success") {
|
||||
messageDialog.icon = StandardIcon.Information;
|
||||
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Successfully exported material to <filename>%1</filename>").arg(result.path);
|
||||
messageDialog.open();
|
||||
}
|
||||
CuraApplication.setDefaultPath("dialog_material_path", folder);
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog
|
||||
{
|
||||
id: messageDialog
|
||||
}
|
||||
|
||||
|
||||
Item {
|
||||
id: contentsItem
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue