mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -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()
|
|
@ -45,6 +45,7 @@ from . import CuraSplashScreen
|
|||
from . import MachineManagerModel
|
||||
from . import ContainerSettingsModel
|
||||
from . import MachineActionManager
|
||||
from . import ContainerManager
|
||||
|
||||
import cura.Settings
|
||||
|
||||
|
@ -428,6 +429,8 @@ class CuraApplication(QtApplication):
|
|||
qmlRegisterType(ContainerSettingsModel.ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
|
||||
qmlRegisterType(cura.Settings.MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
|
||||
|
||||
qmlRegisterSingletonType(ContainerManager.ContainerManager, "Cura", 1, 0, "ContainerManager", ContainerManager.createContainerManager)
|
||||
|
||||
qmlRegisterSingletonType(QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, "Actions.qml")), "Cura", 1, 0, "Actions")
|
||||
|
||||
engine.rootContext().setContextProperty("ExtruderManager", ExtruderManager.ExtruderManager.getInstance())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue