mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-05 23:04:30 +08:00
Added activeMaterial property
CURA-1278
This commit is contained in:
parent
44f5559db3
commit
89c0644e4b
@ -3,13 +3,18 @@ from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
|
|||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
from UM.Settings.ContainerStack import ContainerStack
|
from UM.Settings.ContainerStack import ContainerStack
|
||||||
|
from UM.Settings.InstanceContainer import InstanceContainer
|
||||||
|
|
||||||
class MachineManagerModel(QObject):
|
class MachineManagerModel(QObject):
|
||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
||||||
|
|
||||||
|
## When the global container is changed, active material probably needs to be updated.
|
||||||
|
self.globalContainerChanged.connect(self.activeMaterialChanged)
|
||||||
|
|
||||||
globalContainerChanged = pyqtSignal()
|
globalContainerChanged = pyqtSignal()
|
||||||
|
activeMaterialChanged = pyqtSignal()
|
||||||
|
|
||||||
def _onGlobalContainerChanged(self):
|
def _onGlobalContainerChanged(self):
|
||||||
self.globalContainerChanged.emit()
|
self.globalContainerChanged.emit()
|
||||||
@ -27,8 +32,19 @@ class MachineManagerModel(QObject):
|
|||||||
new_global_stack = ContainerStack(name)
|
new_global_stack = ContainerStack(name)
|
||||||
new_global_stack.addMetaDataEntry("type", "machine")
|
new_global_stack.addMetaDataEntry("type", "machine")
|
||||||
ContainerRegistry.getInstance().addContainer(new_global_stack)
|
ContainerRegistry.getInstance().addContainer(new_global_stack)
|
||||||
|
|
||||||
|
variant_instance_container = InstanceContainer(name + "_variant")
|
||||||
|
material_instance_container = InstanceContainer("test_material")
|
||||||
|
material_instance_container.addMetaDataEntry("type", "material")
|
||||||
|
material_instance_container.setDefinition(definitions[0])
|
||||||
|
#material_instance_container.setMetaData({"type","material"})
|
||||||
|
quality_instance_container = InstanceContainer(name + "_quality")
|
||||||
|
current_settings_instance_container = InstanceContainer(name + "_current_settings")
|
||||||
|
ContainerRegistry.getInstance().addContainer(material_instance_container)
|
||||||
|
|
||||||
# If a definition is found, its a list. Should only have one item.
|
# If a definition is found, its a list. Should only have one item.
|
||||||
new_global_stack.addContainer(definitions[0])
|
new_global_stack.addContainer(definitions[0])
|
||||||
|
new_global_stack.addContainer(material_instance_container)
|
||||||
Application.getInstance().setGlobalContainerStack(new_global_stack)
|
Application.getInstance().setGlobalContainerStack(new_global_stack)
|
||||||
|
|
||||||
@pyqtProperty(str, notify = globalContainerChanged)
|
@pyqtProperty(str, notify = globalContainerChanged)
|
||||||
@ -39,6 +55,12 @@ class MachineManagerModel(QObject):
|
|||||||
def activeMachineId(self):
|
def activeMachineId(self):
|
||||||
return Application.getInstance().getGlobalContainerStack().getId()
|
return Application.getInstance().getGlobalContainerStack().getId()
|
||||||
|
|
||||||
|
@pyqtProperty(str, notify = activeMaterialChanged)
|
||||||
|
def activeMaterialName(self):
|
||||||
|
material = Application.getInstance().getGlobalContainerStack().findContainer({"type":"material"})
|
||||||
|
if material:
|
||||||
|
return material.getName()
|
||||||
|
|
||||||
@pyqtSlot(str, str)
|
@pyqtSlot(str, str)
|
||||||
def renameMachine(self, machine_id, new_name):
|
def renameMachine(self, machine_id, new_name):
|
||||||
containers = ContainerRegistry.getInstance().findContainerStacks(id = machine_id)
|
containers = ContainerRegistry.getInstance().findContainerStacks(id = machine_id)
|
||||||
|
@ -172,8 +172,8 @@ Item
|
|||||||
|
|
||||||
ToolButton {
|
ToolButton {
|
||||||
id: materialSelection
|
id: materialSelection
|
||||||
text: UM.MachineManager.activeMaterial
|
text: Cura.MachineManager.activeMaterialName
|
||||||
tooltip: UM.MachineManager.activeMaterial
|
tooltip: Cura.MachineManager.activeMaterialName
|
||||||
visible: UM.MachineManager.hasMaterials
|
visible: UM.MachineManager.hasMaterials
|
||||||
|
|
||||||
height: UM.Theme.getSize("setting_control").height
|
height: UM.Theme.getSize("setting_control").height
|
||||||
@ -187,6 +187,11 @@ Item
|
|||||||
Instantiator
|
Instantiator
|
||||||
{
|
{
|
||||||
id: materialSelectionInstantiator
|
id: materialSelectionInstantiator
|
||||||
|
model: UM.InstanceContainersModel
|
||||||
|
{
|
||||||
|
filter: {"type": "material"}
|
||||||
|
}
|
||||||
|
//model: UM.InstancesModel {filter: {"type":"material"}}
|
||||||
// model: UM.MachineMaterialsModel { id: machineMaterialsModel }
|
// model: UM.MachineMaterialsModel { id: machineMaterialsModel }
|
||||||
MenuItem
|
MenuItem
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user