Profile export now goes via the plugin system, and does the same filename checks as before.

Contributed to CURA-1667 Profile import/export
This commit is contained in:
Simon Edwards 2016-06-08 14:40:10 +02:00
parent d57e2b2e22
commit c03588c6e5
6 changed files with 9 additions and 6 deletions

View File

@ -294,6 +294,7 @@ class CuraApplication(QtApplication):
# \sa PluginRegistery
def _loadPlugins(self):
self._plugin_registry.addType("profile_reader", self._addProfileReader)
self._plugin_registry.addType("profile_writer", self._addProfileWriter)
self._plugin_registry.addPluginLocation(os.path.join(QtApplication.getInstallPrefix(), "lib", "cura"))
if not hasattr(sys, "frozen"):
self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins"))
@ -788,3 +789,6 @@ class CuraApplication(QtApplication):
def _addProfileReader(self, profile_reader):
# TODO: Add the profile reader to the list of plug-ins that can be used when importing profiles.
pass
def _addProfileWriter(self, profile_writer):
pass

View File

@ -3,7 +3,6 @@
from UM.Application import Application #To get the machine manager to create the new profile in.
from UM.Logger import Logger
from UM.Settings.Profile import Profile
from UM.Settings.ProfileReader import ProfileReader

View File

@ -13,7 +13,7 @@ def getMetaData():
"author": "Ultimaker",
"version": "1.0",
"description": catalog.i18nc("@info:whatsthis", "Provides support for importing Cura profiles."),
"api": 2
"api": 3
},
"profile_reader": [
{

View File

@ -16,10 +16,10 @@ class CuraProfileWriter(ProfileWriter):
# \return \code True \endcode if the writing was successful, or \code
# False \endcode if it wasn't.
def write(self, path, profile):
serialised = profile.serialise()
serialized = profile.serialize()
try:
with SaveFile(path, "wt", -1, "utf-8") as f: # Open the specified file.
f.write(serialised)
f.write(serialized)
except Exception as e:
Logger.log("e", "Failed to write profile to %s: %s", path, str(e))
return False

View File

@ -13,7 +13,7 @@ def getMetaData():
"author": "Ultimaker",
"version": "1.0",
"description": catalog.i18nc("@info:whatsthis", "Provides support for exporting Cura profiles."),
"api": 2
"api": 3
},
"profile_writer": [
{

View File

@ -299,7 +299,7 @@ UM.ManagementPage
folder: base.model.getDefaultPath()
onAccepted:
{
var result = base.model.exportProfile(base.currentItem.id, fileUrl)
var result = base.model.exportProfile(base.currentItem.id, fileUrl, selectedNameFilter)
if(result && result.status == "error")
{
messageDialog.icon = StandardIcon.Critical