Remove cache of material manager

It doesn't make the code much simpler because the cache is also not a local variable.

Contributes to issue CURA-6679.
This commit is contained in:
Ghostkeeper 2019-07-24 16:04:16 +02:00
parent 33739ea7a8
commit be4e754984
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
4 changed files with 8 additions and 11 deletions

View file

@ -599,7 +599,7 @@ class MachineManager(QObject):
def activeStack(self) -> Optional["ExtruderStack"]: def activeStack(self) -> Optional["ExtruderStack"]:
return self._active_container_stack return self._active_container_stack
@pyqtProperty(str, notify=activeMaterialChanged) @pyqtProperty(str, notify = activeMaterialChanged)
def activeMaterialId(self) -> str: def activeMaterialId(self) -> str:
if self._active_container_stack: if self._active_container_stack:
material = self._active_container_stack.material material = self._active_container_stack.material

View file

@ -13,7 +13,6 @@ Item
{ {
id: base id: base
property QtObject materialManager: CuraApplication.getMaterialManager()
// Keep PreferencesDialog happy // Keep PreferencesDialog happy
property var resetEnabled: false property var resetEnabled: false
property var currentItem: null property var currentItem: null
@ -119,7 +118,7 @@ Item
onClicked: onClicked:
{ {
forceActiveFocus(); forceActiveFocus();
base.newRootMaterialIdToSwitchTo = base.materialManager.createMaterial(); base.newRootMaterialIdToSwitchTo = CuraApplication.getMaterialManager().createMaterial();
base.toActivateNewMaterial = true; base.toActivateNewMaterial = true;
} }
} }
@ -134,7 +133,7 @@ Item
onClicked: onClicked:
{ {
forceActiveFocus(); forceActiveFocus();
base.newRootMaterialIdToSwitchTo = base.materialManager.duplicateMaterial(base.currentItem.container_node); base.newRootMaterialIdToSwitchTo = CuraApplication.getMaterialManager().duplicateMaterial(base.currentItem.container_node);
base.toActivateNewMaterial = true; base.toActivateNewMaterial = true;
} }
} }
@ -145,7 +144,7 @@ Item
id: removeMenuButton id: removeMenuButton
text: catalog.i18nc("@action:button", "Remove") text: catalog.i18nc("@action:button", "Remove")
iconName: "list-remove" iconName: "list-remove"
enabled: base.hasCurrentItem && !base.currentItem.is_read_only && !base.isCurrentItemActivated && base.materialManager.canMaterialBeRemoved(base.currentItem.container_node) enabled: base.hasCurrentItem && !base.currentItem.is_read_only && !base.isCurrentItemActivated && CuraApplication.getMaterialManager().canMaterialBeRemoved(base.currentItem.container_node)
onClicked: onClicked:
{ {
forceActiveFocus(); forceActiveFocus();
@ -294,7 +293,7 @@ Item
{ {
// Set the active material as the fallback. It will be selected when the current material is deleted // Set the active material as the fallback. It will be selected when the current material is deleted
base.newRootMaterialIdToSwitchTo = base.active_root_material_id base.newRootMaterialIdToSwitchTo = base.active_root_material_id
base.materialManager.removeMaterial(base.currentItem.container_node); CuraApplication.getMaterialManager().removeMaterial(base.currentItem.container_node);
} }
} }

View file

@ -82,10 +82,10 @@ Rectangle
{ {
if (materialSlot.is_favorite) if (materialSlot.is_favorite)
{ {
base.materialManager.removeFavorite(material.root_material_id) CuraApplication.getMaterialManager().removeFavorite(material.root_material_id)
return return
} }
base.materialManager.addFavorite(material.root_material_id) CuraApplication.getMaterialManager().addFavorite(material.root_material_id)
return return
} }
style: ButtonStyle style: ButtonStyle

View file

@ -14,8 +14,6 @@ TabView
{ {
id: base id: base
property QtObject materialManager: CuraApplication.getMaterialManager()
property QtObject properties property QtObject properties
property var currentMaterialNode: null property var currentMaterialNode: null
@ -567,7 +565,7 @@ TabView
} }
// update the values // update the values
base.materialManager.setMaterialName(base.currentMaterialNode, new_name) CuraApplication.getMaterialManager().setMaterialName(base.currentMaterialNode, new_name)
properties.name = new_name properties.name = new_name
} }