mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-22 22:23:57 -06:00
Introduce a ContainerManager class to handle container actions like duplicate
Because MachineManager is getting rather large Contributes to CURA-342
This commit is contained in:
parent
f7e4b91569
commit
cd8bc3b60d
2 changed files with 37 additions and 0 deletions
34
cura/ContainerManager.py
Normal file
34
cura/ContainerManager.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
# Copyright (c) 2016 Ultimaker B.V.
|
||||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
|
||||
|
||||
import UM.Settings
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
catalog = i18nCatalog("cura")
|
||||
|
||||
class ContainerManager(QObject):
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
|
||||
@pyqtSlot(str)
|
||||
def duplicateContainer(self, container_id):
|
||||
containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = container_id)
|
||||
if not containers:
|
||||
return
|
||||
|
||||
new_name = UM.Settings.ContainerRegistry.getInstance().uniqueName(containers[0].getName())
|
||||
new_material = containers[0].duplicate(new_name)
|
||||
UM.Settings.ContainerRegistry.getInstance().addContainer(new_material)
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def renameContainer(self, container_id, new_name):
|
||||
pass
|
||||
|
||||
@pyqtSlot(str)
|
||||
def removeContainer(self, container_id):
|
||||
pass
|
||||
|
||||
def createContainerManager(engine, js_engine):
|
||||
return ContainerManager()
|
Loading…
Add table
Add a link
Reference in a new issue