mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-21 12:09:13 +08:00
Merge branch '3.0'
This commit is contained in:
commit
fded206cc3
@ -21,7 +21,7 @@ class CuraStackBuilder:
|
||||
#
|
||||
# \return The new global stack or None if an error occurred.
|
||||
@classmethod
|
||||
def createMachine(cls, name: str, definition_id: str) -> Optional[GlobalStack]:
|
||||
def createMachine(cls, name: str, definition_id: str, default_name: str) -> Optional[GlobalStack]:
|
||||
registry = ContainerRegistry.getInstance()
|
||||
definitions = registry.findDefinitionContainers(id = definition_id)
|
||||
if not definitions:
|
||||
@ -29,21 +29,29 @@ class CuraStackBuilder:
|
||||
return None
|
||||
|
||||
machine_definition = definitions[0]
|
||||
name = registry.createUniqueName("machine", "", name, machine_definition.name)
|
||||
generated_name = registry.createUniqueName("machine", "", default_name, machine_definition.name)
|
||||
# Make sure the new name does not collide with any definition or (quality) profile
|
||||
# createUniqueName() only looks at other stacks, but not at definitions or quality profiles
|
||||
# Note that we don't go for uniqueName() immediately because that function matches with ignore_case set to true
|
||||
if registry.findContainers(id = name):
|
||||
name = registry.uniqueName(name)
|
||||
if registry.findContainers(id = generated_name):
|
||||
generated_name = registry.uniqueName(generated_name)
|
||||
|
||||
new_global_stack = cls.createGlobalStack(
|
||||
new_stack_id = name,
|
||||
new_stack_id = generated_name,
|
||||
definition = machine_definition,
|
||||
quality = "default",
|
||||
material = "default",
|
||||
variant = "default",
|
||||
)
|
||||
|
||||
# after creating a global stack can be set custom defined name
|
||||
if(name != generated_name):
|
||||
name = registry.createUniqueName("machine", "", name, machine_definition.name)
|
||||
if registry.findContainers(id = name):
|
||||
name = registry.uniqueName(name)
|
||||
|
||||
new_global_stack.setName(name)
|
||||
|
||||
for extruder_definition in registry.findDefinitionContainers(machine = machine_definition.id):
|
||||
position = extruder_definition.getMetaDataEntry("position", None)
|
||||
if not position:
|
||||
|
@ -352,9 +352,9 @@ class MachineManager(QObject):
|
||||
if containers:
|
||||
Application.getInstance().setGlobalContainerStack(containers[0])
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def addMachine(self, name: str, definition_id: str) -> None:
|
||||
new_stack = CuraStackBuilder.createMachine(name, definition_id)
|
||||
@pyqtSlot(str, str, str)
|
||||
def addMachine(self, name: str, definition_id: str, default_name: str) -> None:
|
||||
new_stack = CuraStackBuilder.createMachine(name, definition_id, default_name)
|
||||
if new_stack:
|
||||
Application.getInstance().setGlobalContainerStack(new_stack)
|
||||
else:
|
||||
|
@ -217,7 +217,8 @@ UM.Dialog
|
||||
{
|
||||
base.visible = false
|
||||
var item = machineList.model.getItem(machineList.currentIndex);
|
||||
Cura.MachineManager.addMachine(machineName.text, item.id)
|
||||
var defaultName = (item != undefined) ? item.name : ""
|
||||
Cura.MachineManager.addMachine(machineName.text, item.id, defaultName)
|
||||
base.machineAdded(item.id) // Emit signal that the user added a machine.
|
||||
}
|
||||
|
||||
|
2
setup.py
2
setup.py
@ -45,7 +45,7 @@ setup(name="Cura",
|
||||
author="Ultimaker",
|
||||
author_email="a.hiemstra@ultimaker.com",
|
||||
url="http://software.ultimaker.com/",
|
||||
license="GNU AFFERO GENERAL PUBLIC LICENSE (AGPL)",
|
||||
license="GNU LESSER GENERAL PUBLIC LICENSE (LGPL)",
|
||||
scripts=["cura_app.py"],
|
||||
windows=[{"script": "cura_app.py", "dest_name": "Cura", "icon_resources": [(1, "icons/cura.ico")]}],
|
||||
#console=[{"script": "cura_app.py"}],
|
||||
|
Loading…
x
Reference in New Issue
Block a user