diff options
author | Lipu Fei <lipu.fei815@gmail.com> | 2017-05-19 11:13:12 +0300 |
---|---|---|
committer | Lipu Fei <lipu.fei815@gmail.com> | 2017-05-19 11:18:13 +0300 |
commit | 593697e0ed5297a50a4fd1c14f976f0b73976f0b (patch) | |
tree | c5454e068dacc8a506a387d9c6aa29cf49556bb8 /plugins/XmlMaterialProfile/__init__.py | |
parent | bccd4187a3bd4de66e1b3c95c31a44ad93630f92 (diff) |
Fix XML material upgrade
CURA-3756
Diffstat (limited to 'plugins/XmlMaterialProfile/__init__.py')
-rw-r--r-- | plugins/XmlMaterialProfile/__init__.py | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/plugins/XmlMaterialProfile/__init__.py b/plugins/XmlMaterialProfile/__init__.py index 213b9a358a..73965ac8b8 100644 --- a/plugins/XmlMaterialProfile/__init__.py +++ b/plugins/XmlMaterialProfile/__init__.py @@ -1,11 +1,16 @@ -# Copyright (c) 2016 Ultimaker B.V. +# Copyright (c) 2017 Ultimaker B.V. # Cura is released under the terms of the AGPLv3 or higher. from . import XmlMaterialProfile +from . import Upgrader from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase from UM.i18n import i18nCatalog + + catalog = i18nCatalog("cura") +upgrader = Upgrader.Upgrader() + def getMetaData(): return { @@ -19,15 +24,36 @@ def getMetaData(): "settings_container": { "type": "material", "mimetype": "application/x-ultimaker-material-profile" + }, + "version_upgrade": { + ("materials", 1000000): ("materials", 1000001, upgrader.upgradeMaterial), + }, + "sources": { + "materials": { + "get_version": upgrader.getXmlVersion, + "location": {"./materials"} + }, } } + def register(app): + # add Mime type mime_type = MimeType( name = "application/x-ultimaker-material-profile", comment = "Ultimaker Material Profile", suffixes = [ "xml.fdm_material" ] ) MimeTypeDatabase.addMimeType(mime_type) - return { "settings_container": XmlMaterialProfile.XmlMaterialProfile("default_xml_material_profile") } + # add upgrade version + from cura.CuraApplication import CuraApplication + from UM.VersionUpgradeManager import VersionUpgradeManager + VersionUpgradeManager.getInstance().setCurrentVersion( + ("materials", XmlMaterialProfile.XmlMaterialProfile.Version * 1000000 + CuraApplication.SettingVersion), + (CuraApplication.ResourceTypes.MaterialInstanceContainer, "application/x-uranium-instancecontainer") + ) + + return {"version_upgrade": upgrader, + "settings_container": XmlMaterialProfile.XmlMaterialProfile("default_xml_material_profile"), + } |