mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Changes to make um2 upgrade work with new stack changes
CURA-3742
This commit is contained in:
parent
293f1ac029
commit
bd25448021
2 changed files with 9 additions and 9 deletions
|
@ -773,9 +773,8 @@ class MachineManager(QObject):
|
||||||
old_material = self._active_container_stack.material
|
old_material = self._active_container_stack.material
|
||||||
if old_variant:
|
if old_variant:
|
||||||
self.blurSettings.emit()
|
self.blurSettings.emit()
|
||||||
variant_index = self._active_container_stack.getContainerIndex(old_variant)
|
self._active_container_stack.variant = containers[0]
|
||||||
self._active_container_stack.replaceContainer(variant_index, containers[0])
|
Logger.log("d", "Active variant changed to {active_variant_id}".format(active_variant_id = containers[0].getId()))
|
||||||
Logger.log("d", "Active variant changed")
|
|
||||||
preferred_material = None
|
preferred_material = None
|
||||||
if old_material:
|
if old_material:
|
||||||
preferred_material_name = old_material.getName()
|
preferred_material_name = old_material.getName()
|
||||||
|
|
|
@ -8,6 +8,7 @@ from PyQt5.QtCore import pyqtSlot, pyqtSignal, pyqtProperty
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
from UM.Application import Application
|
from UM.Application import Application
|
||||||
|
from UM.Util import parseBool
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
import UM.Settings.InstanceContainer
|
import UM.Settings.InstanceContainer
|
||||||
|
@ -30,13 +31,13 @@ class UM2UpgradeSelection(MachineAction):
|
||||||
def hasVariants(self):
|
def hasVariants(self):
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
return global_container_stack.getMetaDataEntry("has_variants", "false") == "True"
|
return parseBool(global_container_stack.getMetaDataEntry("has_variants", "false"))
|
||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def setHasVariants(self, has_variants = True):
|
def setHasVariants(self, has_variants = True):
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
variant_container = global_container_stack.findContainer({"type": "variant"})
|
variant_container = global_container_stack.variant
|
||||||
variant_index = global_container_stack.getContainerIndex(variant_container)
|
variant_index = global_container_stack.getContainerIndex(variant_container)
|
||||||
|
|
||||||
if has_variants:
|
if has_variants:
|
||||||
|
@ -46,11 +47,12 @@ class UM2UpgradeSelection(MachineAction):
|
||||||
global_container_stack.addMetaDataEntry("has_variants", True)
|
global_container_stack.addMetaDataEntry("has_variants", True)
|
||||||
|
|
||||||
# Set the variant container to a sane default
|
# Set the variant container to a sane default
|
||||||
if variant_container.getId() == "empty_variant":
|
empty_container = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
||||||
|
if type(variant_container) == type(empty_container):
|
||||||
search_criteria = { "type": "variant", "definition": "ultimaker2", "id": "*0.4*" }
|
search_criteria = { "type": "variant", "definition": "ultimaker2", "id": "*0.4*" }
|
||||||
containers = self._container_registry.findInstanceContainers(**search_criteria)
|
containers = self._container_registry.findInstanceContainers(**search_criteria)
|
||||||
if containers:
|
if containers:
|
||||||
global_container_stack.replaceContainer(variant_index, containers[0])
|
global_container_stack.variant = containers[0]
|
||||||
else:
|
else:
|
||||||
# The metadata entry is stored in an ini, and ini files are parsed as strings only.
|
# The metadata entry is stored in an ini, and ini files are parsed as strings only.
|
||||||
# Because any non-empty string evaluates to a boolean True, we have to remove the entry to make it False.
|
# Because any non-empty string evaluates to a boolean True, we have to remove the entry to make it False.
|
||||||
|
@ -58,7 +60,6 @@ class UM2UpgradeSelection(MachineAction):
|
||||||
global_container_stack.removeMetaDataEntry("has_variants")
|
global_container_stack.removeMetaDataEntry("has_variants")
|
||||||
|
|
||||||
# Set the variant container to an empty variant
|
# Set the variant container to an empty variant
|
||||||
if variant_container.getId() == "empty_variant":
|
global_container_stack.variant = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
||||||
global_container_stack.replaceContainer(variant_index, self._container_registry.findInstanceContainers(id="empty_variant")[0])
|
|
||||||
|
|
||||||
Application.getInstance().globalContainerStackChanged.emit()
|
Application.getInstance().globalContainerStackChanged.emit()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue