mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 04:59:00 +08:00
Changing the profile name to something unique.
Imported profiles will be now called "Custom profile (<G-code filename>)"
This commit is contained in:
parent
9511692638
commit
4ca247cf37
@ -7,6 +7,8 @@ import re #Regular expressions for parsing escape characters in the settings.
|
||||
from UM.Application import Application #To get the machine manager to create the new profile in.
|
||||
from UM.Settings.InstanceContainer import InstanceContainer
|
||||
from UM.Logger import Logger
|
||||
from UM.i18n import i18nCatalog
|
||||
catalog = i18nCatalog("cura")
|
||||
|
||||
from cura.ProfileReader import ProfileReader
|
||||
|
||||
@ -71,7 +73,7 @@ class GCodeProfileReader(ProfileReader):
|
||||
serialized = pattern.sub(lambda m: GCodeProfileReader.escape_characters[re.escape(m.group(0))], serialized)
|
||||
Logger.log("i", "Serialized the following from %s: %s" %(file_name, repr(serialized)))
|
||||
|
||||
# Create an empty profile with the name of the G-code file
|
||||
# Create an empty profile - the id will be changed later
|
||||
profile = InstanceContainer("G-code-imported-profile")
|
||||
profile.addMetaDataEntry("type", "quality")
|
||||
try:
|
||||
@ -80,4 +82,9 @@ class GCodeProfileReader(ProfileReader):
|
||||
Logger.log("e", "Unable to serialise the profile: %s", str(e))
|
||||
return None
|
||||
|
||||
#Creating a unique name using the filename of the GCode
|
||||
new_name = catalog.i18nc("@label", "Custom profile (%s)") %(os.path.splitext(os.path.basename(file_name))[0])
|
||||
profile.setName(new_name)
|
||||
profile._id = new_name
|
||||
|
||||
return profile
|
Loading…
x
Reference in New Issue
Block a user