mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 11:17:49 -06:00
Fix exporting and importing materials on OSX
OSX's file dialog is stupid and does not understand extensions with a . in them. So instead just use everything after the last . Fixes CURA-1987
This commit is contained in:
parent
34ac8cf66f
commit
570a67556a
2 changed files with 16 additions and 3 deletions
|
@ -244,6 +244,7 @@ class ContainerManager(QObject):
|
||||||
if not type_name or entry["type"] == type_name:
|
if not type_name or entry["type"] == type_name:
|
||||||
filters.append(filter_string)
|
filters.append(filter_string)
|
||||||
|
|
||||||
|
filters.append("All Files (*)")
|
||||||
return filters
|
return filters
|
||||||
|
|
||||||
## Export a container to a file
|
## Export a container to a file
|
||||||
|
@ -280,6 +281,9 @@ class ContainerManager(QObject):
|
||||||
return { "status": "error", "message": "Container not found"}
|
return { "status": "error", "message": "Container not found"}
|
||||||
container = containers[0]
|
container = containers[0]
|
||||||
|
|
||||||
|
if UM.Platform.isOSX() and "." in file_url:
|
||||||
|
file_url = file_url[:file_url.rfind(".")]
|
||||||
|
|
||||||
for suffix in mime_type.suffixes:
|
for suffix in mime_type.suffixes:
|
||||||
if file_url.endswith(suffix):
|
if file_url.endswith(suffix):
|
||||||
break
|
break
|
||||||
|
@ -301,7 +305,7 @@ class ContainerManager(QObject):
|
||||||
with UM.SaveFile(file_url, "w") as f:
|
with UM.SaveFile(file_url, "w") as f:
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
|
|
||||||
return { "status": "success", "message": "Succesfully exported container"}
|
return { "status": "success", "message": "Succesfully exported container", "path": file_url}
|
||||||
|
|
||||||
## Imports a profile from a file
|
## Imports a profile from a file
|
||||||
#
|
#
|
||||||
|
@ -371,11 +375,20 @@ class ContainerManager(QObject):
|
||||||
"container": container_type
|
"container": container_type
|
||||||
}
|
}
|
||||||
|
|
||||||
suffix_list = "*." + mime_type.preferredSuffix
|
suffix = mime_type.preferredSuffix
|
||||||
|
if UM.Platform.isOSX() and "." in suffix:
|
||||||
|
# OSX's File dialog is stupid and does not allow selecting files with a . in its name
|
||||||
|
suffix = suffix[suffix.index(".") + 1:]
|
||||||
|
|
||||||
|
suffix_list = "*." + suffix
|
||||||
for suffix in mime_type.suffixes:
|
for suffix in mime_type.suffixes:
|
||||||
if suffix == mime_type.preferredSuffix:
|
if suffix == mime_type.preferredSuffix:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if UM.Platform.isOSX() and "." in suffix:
|
||||||
|
# OSX's File dialog is stupid and does not allow selecting files with a . in its name
|
||||||
|
suffix = suffix[suffix.index("."):]
|
||||||
|
|
||||||
suffix_list += ", *." + suffix
|
suffix_list += ", *." + suffix
|
||||||
|
|
||||||
name_filter = "{0} ({1})".format(mime_type.comment, suffix_list)
|
name_filter = "{0} ({1})".format(mime_type.comment, suffix_list)
|
||||||
|
|
|
@ -255,7 +255,7 @@ UM.ManagementPage
|
||||||
else if(result.status == "success")
|
else if(result.status == "success")
|
||||||
{
|
{
|
||||||
messageDialog.icon = StandardIcon.Information
|
messageDialog.icon = StandardIcon.Information
|
||||||
messageDialog.text = catalog.i18nc("@info:status", "Successfully exported material to <filename>%1</filename>").arg(fileUrl)
|
messageDialog.text = catalog.i18nc("@info:status", "Successfully exported material to <filename>%1</filename>").arg(result.path)
|
||||||
messageDialog.open()
|
messageDialog.open()
|
||||||
}
|
}
|
||||||
CuraApplication.setDefaultPath("dialog_material_path", folder)
|
CuraApplication.setDefaultPath("dialog_material_path", folder)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue