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.
|
# \return The new global stack or None if an error occurred.
|
||||||
@classmethod
|
@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()
|
registry = ContainerRegistry.getInstance()
|
||||||
definitions = registry.findDefinitionContainers(id = definition_id)
|
definitions = registry.findDefinitionContainers(id = definition_id)
|
||||||
if not definitions:
|
if not definitions:
|
||||||
@ -29,21 +29,29 @@ class CuraStackBuilder:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
machine_definition = definitions[0]
|
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
|
# 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
|
# 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
|
# Note that we don't go for uniqueName() immediately because that function matches with ignore_case set to true
|
||||||
if registry.findContainers(id = name):
|
if registry.findContainers(id = generated_name):
|
||||||
name = registry.uniqueName(name)
|
generated_name = registry.uniqueName(generated_name)
|
||||||
|
|
||||||
new_global_stack = cls.createGlobalStack(
|
new_global_stack = cls.createGlobalStack(
|
||||||
new_stack_id = name,
|
new_stack_id = generated_name,
|
||||||
definition = machine_definition,
|
definition = machine_definition,
|
||||||
quality = "default",
|
quality = "default",
|
||||||
material = "default",
|
material = "default",
|
||||||
variant = "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):
|
for extruder_definition in registry.findDefinitionContainers(machine = machine_definition.id):
|
||||||
position = extruder_definition.getMetaDataEntry("position", None)
|
position = extruder_definition.getMetaDataEntry("position", None)
|
||||||
if not position:
|
if not position:
|
||||||
|
@ -352,9 +352,9 @@ class MachineManager(QObject):
|
|||||||
if containers:
|
if containers:
|
||||||
Application.getInstance().setGlobalContainerStack(containers[0])
|
Application.getInstance().setGlobalContainerStack(containers[0])
|
||||||
|
|
||||||
@pyqtSlot(str, str)
|
@pyqtSlot(str, str, str)
|
||||||
def addMachine(self, name: str, definition_id: str) -> None:
|
def addMachine(self, name: str, definition_id: str, default_name: str) -> None:
|
||||||
new_stack = CuraStackBuilder.createMachine(name, definition_id)
|
new_stack = CuraStackBuilder.createMachine(name, definition_id, default_name)
|
||||||
if new_stack:
|
if new_stack:
|
||||||
Application.getInstance().setGlobalContainerStack(new_stack)
|
Application.getInstance().setGlobalContainerStack(new_stack)
|
||||||
else:
|
else:
|
||||||
|
@ -217,7 +217,8 @@ UM.Dialog
|
|||||||
{
|
{
|
||||||
base.visible = false
|
base.visible = false
|
||||||
var item = machineList.model.getItem(machineList.currentIndex);
|
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.
|
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="Ultimaker",
|
||||||
author_email="a.hiemstra@ultimaker.com",
|
author_email="a.hiemstra@ultimaker.com",
|
||||||
url="http://software.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"],
|
scripts=["cura_app.py"],
|
||||||
windows=[{"script": "cura_app.py", "dest_name": "Cura", "icon_resources": [(1, "icons/cura.ico")]}],
|
windows=[{"script": "cura_app.py", "dest_name": "Cura", "icon_resources": [(1, "icons/cura.ico")]}],
|
||||||
#console=[{"script": "cura_app.py"}],
|
#console=[{"script": "cura_app.py"}],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user