mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 03:37:48 -06:00
Fixed code style and machine default name is retrieved from machine definition
CURA-4345
This commit is contained in:
parent
89de83254d
commit
3082038261
3 changed files with 7 additions and 8 deletions
|
@ -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, default_name: str) -> Optional[GlobalStack]:
|
def createMachine(cls, name: str, definition_id: 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,7 +29,7 @@ class CuraStackBuilder:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
machine_definition = definitions[0]
|
machine_definition = definitions[0]
|
||||||
generated_name = registry.createUniqueName("machine", "", default_name, machine_definition.name)
|
generated_name = registry.createUniqueName("machine", "", machine_definition.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
|
||||||
|
@ -45,7 +45,7 @@ class CuraStackBuilder:
|
||||||
)
|
)
|
||||||
|
|
||||||
# after creating a global stack can be set custom defined name
|
# after creating a global stack can be set custom defined name
|
||||||
if(name != generated_name):
|
if name != generated_name:
|
||||||
name = registry.createUniqueName("machine", "", name, machine_definition.name)
|
name = registry.createUniqueName("machine", "", name, machine_definition.name)
|
||||||
if registry.findContainers(id = name):
|
if registry.findContainers(id = name):
|
||||||
name = registry.uniqueName(name)
|
name = registry.uniqueName(name)
|
||||||
|
|
|
@ -352,9 +352,9 @@ class MachineManager(QObject):
|
||||||
if containers:
|
if containers:
|
||||||
Application.getInstance().setGlobalContainerStack(containers[0])
|
Application.getInstance().setGlobalContainerStack(containers[0])
|
||||||
|
|
||||||
@pyqtSlot(str, str, str)
|
@pyqtSlot(str, str)
|
||||||
def addMachine(self, name: str, definition_id: str, default_name: str) -> None:
|
def addMachine(self, name: str, definition_id: str) -> None:
|
||||||
new_stack = CuraStackBuilder.createMachine(name, definition_id, default_name)
|
new_stack = CuraStackBuilder.createMachine(name, definition_id)
|
||||||
if new_stack:
|
if new_stack:
|
||||||
Application.getInstance().setGlobalContainerStack(new_stack)
|
Application.getInstance().setGlobalContainerStack(new_stack)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -217,8 +217,7 @@ UM.Dialog
|
||||||
{
|
{
|
||||||
base.visible = false
|
base.visible = false
|
||||||
var item = machineList.model.getItem(machineList.currentIndex);
|
var item = machineList.model.getItem(machineList.currentIndex);
|
||||||
var defaultName = (item != undefined) ? item.name : ""
|
Cura.MachineManager.addMachine(machineName.text, item.id)
|
||||||
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue