mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-09 16:59:02 +08:00
Merge branch 'master' of https://github.com/Ultimaker/Cura
This commit is contained in:
commit
bbc33f5d70
@ -6,6 +6,7 @@ from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot, QObject #For commun
|
||||
import UM.Application #To get the global container stack to find the current machine.
|
||||
import UM.Logger
|
||||
import UM.Settings.ContainerRegistry #Finding containers by ID.
|
||||
import re
|
||||
|
||||
|
||||
## Manages all existing extruder stacks.
|
||||
@ -48,6 +49,13 @@ class ExtruderManager(QObject):
|
||||
except KeyError: #Extruder index could be -1 if the global tab is selected, or the entry doesn't exist if the machine definition is wrong.
|
||||
return None
|
||||
|
||||
__instance = None
|
||||
@classmethod
|
||||
def getInstance(cls):
|
||||
if not cls.__instance:
|
||||
cls.__instance = ExtruderManager()
|
||||
return cls.__instance
|
||||
|
||||
@pyqtSlot(int)
|
||||
def setActiveExtruderIndex(self, index):
|
||||
self._active_extruder_index = index
|
||||
@ -135,5 +143,25 @@ class ExtruderManager(QObject):
|
||||
|
||||
container_registry.addContainer(container_stack)
|
||||
|
||||
|
||||
def _uniqueName(self, extruder):
|
||||
container_registry = UM.Settings.ContainerRegistry.getInstance()
|
||||
|
||||
name = extruder.strip()
|
||||
num_check = re.compile("(.*?)\s*#\d$").match(name)
|
||||
if num_check: # There is a number in the name.
|
||||
name = num_check.group(1) # Filter out the number.
|
||||
if name == "": # Wait, that deleted everything!
|
||||
name = "Extruder"
|
||||
unique_name = name
|
||||
|
||||
i = 1
|
||||
while container_registry.findContainers(id=unique_name) or container_registry.findContainers(
|
||||
name=unique_name): # A container already has this name.
|
||||
i += 1 # Try next numbering.
|
||||
unique_name = "%s #%d" % (name, i) # Fill name like this: "Extruder #2".
|
||||
return unique_name
|
||||
|
||||
|
||||
def createExtruderManager(engine, script_engine):
|
||||
return ExtruderManager()
|
@ -135,14 +135,14 @@ class MachineManagerModel(QObject):
|
||||
new_global_stack.addContainer(quality_instance_container)
|
||||
new_global_stack.addContainer(current_settings_instance_container)
|
||||
|
||||
for position, extruder_train_id in definitions.getMetaDataEntry("machine_extruder_trains", default = {}).items():
|
||||
for position, extruder_train_id in definition.getMetaDataEntry("machine_extruder_trains", default = {}).items():
|
||||
extruder_definition = UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id = extruder_train_id)
|
||||
if extruder_definition:
|
||||
extruder_definition = extruder_definition[0]
|
||||
else:
|
||||
Logger.log("w", "Machine %s references an extruder with ID %s, which doesn't exist.", definition.getName(), extruder_train_id)
|
||||
continue
|
||||
ExtruderManager.getInstance().createExtruderTrain(extruder_definition, definition, extruder_train_id)
|
||||
ExtruderManager.ExtruderManager.getInstance().createExtruderTrain(extruder_definition, definition, extruder_train_id)
|
||||
|
||||
Application.getInstance().setGlobalContainerStack(new_global_stack)
|
||||
|
||||
|
@ -24,7 +24,7 @@ ScrollView
|
||||
{
|
||||
id: contents
|
||||
spacing: UM.Theme.getSize("default_lining").height;
|
||||
cacheBuffer: 1000000; // A huge to cache to effectively cache everything.
|
||||
cacheBuffer: 1000000; // Set a large cache to effectively just cache every list item.
|
||||
|
||||
model: UM.SettingDefinitionsModel {
|
||||
id: definitionsModel;
|
||||
|
Loading…
x
Reference in New Issue
Block a user