mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-22 05:39:37 +08:00
Fix imports and references to managers
Use getInstance() where applicable. Contributes to issue CURA-6600.
This commit is contained in:
parent
91e14a90b2
commit
fff26bb021
@ -1,9 +1,11 @@
|
|||||||
# Copyright (c) 2018 Ultimaker B.V.
|
# Copyright (c) 2019 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
|
|
||||||
|
import cura.CuraApplication # Imported this way to prevent circular references.
|
||||||
from cura.Machines.Models.QualityProfilesDropDownMenuModel import QualityProfilesDropDownMenuModel
|
from cura.Machines.Models.QualityProfilesDropDownMenuModel import QualityProfilesDropDownMenuModel
|
||||||
|
from cura.Machines.QualityManager import QualityManager
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -14,13 +16,13 @@ class CustomQualityProfilesDropDownMenuModel(QualityProfilesDropDownMenuModel):
|
|||||||
def _update(self):
|
def _update(self):
|
||||||
Logger.log("d", "Updating {model_class_name}.".format(model_class_name = self.__class__.__name__))
|
Logger.log("d", "Updating {model_class_name}.".format(model_class_name = self.__class__.__name__))
|
||||||
|
|
||||||
active_global_stack = self._machine_manager.activeMachine
|
active_global_stack = cura.CuraApplication.CuraApplication.getInstance().getMachineManager().activeMachine
|
||||||
if active_global_stack is None:
|
if active_global_stack is None:
|
||||||
self.setItems([])
|
self.setItems([])
|
||||||
Logger.log("d", "No active GlobalStack, set %s as empty.", self.__class__.__name__)
|
Logger.log("d", "No active GlobalStack, set %s as empty.", self.__class__.__name__)
|
||||||
return
|
return
|
||||||
|
|
||||||
quality_changes_group_dict = self._quality_manager.getQualityChangesGroups(active_global_stack)
|
quality_changes_group_dict = QualityManager.getInstance().getQualityChangesGroups(active_global_stack)
|
||||||
|
|
||||||
item_list = []
|
item_list = []
|
||||||
for key in sorted(quality_changes_group_dict, key = lambda name: name.upper()):
|
for key in sorted(quality_changes_group_dict, key = lambda name: name.upper()):
|
||||||
|
@ -7,8 +7,8 @@ from UM.Logger import Logger
|
|||||||
from UM.Qt.ListModel import ListModel
|
from UM.Qt.ListModel import ListModel
|
||||||
from UM.Settings.SettingFunction import SettingFunction
|
from UM.Settings.SettingFunction import SettingFunction
|
||||||
|
|
||||||
from cura.CuraApplication import CuraApplication
|
import cura.CuraApplication # Imported this way to prevent circular dependencies.
|
||||||
from cura.Machines.QualityManager import QualityGroup
|
from cura.Machines.QualityManager import QualityGroup, QualityManager
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -36,7 +36,7 @@ class QualityProfilesDropDownMenuModel(ListModel):
|
|||||||
self.addRoleName(self.QualityChangesGroupRole, "quality_changes_group")
|
self.addRoleName(self.QualityChangesGroupRole, "quality_changes_group")
|
||||||
self.addRoleName(self.IsExperimentalRole, "is_experimental")
|
self.addRoleName(self.IsExperimentalRole, "is_experimental")
|
||||||
|
|
||||||
application = CuraApplication.getInstance()
|
application = cura.CuraApplication.CuraApplication.getInstance()
|
||||||
machine_manager = application.getMachineManager()
|
machine_manager = application.getMachineManager()
|
||||||
|
|
||||||
application.globalContainerStackChanged.connect(self._onChange)
|
application.globalContainerStackChanged.connect(self._onChange)
|
||||||
@ -58,19 +58,19 @@ class QualityProfilesDropDownMenuModel(ListModel):
|
|||||||
def _update(self):
|
def _update(self):
|
||||||
Logger.log("d", "Updating {model_class_name}.".format(model_class_name = self.__class__.__name__))
|
Logger.log("d", "Updating {model_class_name}.".format(model_class_name = self.__class__.__name__))
|
||||||
|
|
||||||
global_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
|
||||||
if global_stack is None:
|
if global_stack is None:
|
||||||
self.setItems([])
|
self.setItems([])
|
||||||
Logger.log("d", "No active GlobalStack, set quality profile model as empty.")
|
Logger.log("d", "No active GlobalStack, set quality profile model as empty.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check for material compatibility
|
# Check for material compatibility
|
||||||
if not CuraApplication.getInstance().getMachineManager().activeMaterialsCompatible():
|
if not cura.CuraApplication.CuraApplication.getInstance().getMachineManager().activeMaterialsCompatible():
|
||||||
Logger.log("d", "No active material compatibility, set quality profile model as empty.")
|
Logger.log("d", "No active material compatibility, set quality profile model as empty.")
|
||||||
self.setItems([])
|
self.setItems([])
|
||||||
return
|
return
|
||||||
|
|
||||||
quality_group_dict = self._quality_manager.getQualityGroups(global_stack)
|
quality_group_dict = QualityManager.getInstance().getQualityGroups(global_stack)
|
||||||
|
|
||||||
item_list = []
|
item_list = []
|
||||||
for key in sorted(quality_group_dict):
|
for key in sorted(quality_group_dict):
|
||||||
@ -94,7 +94,7 @@ class QualityProfilesDropDownMenuModel(ListModel):
|
|||||||
self.setItems(item_list)
|
self.setItems(item_list)
|
||||||
|
|
||||||
def _fetchLayerHeight(self, quality_group: "QualityGroup") -> float:
|
def _fetchLayerHeight(self, quality_group: "QualityGroup") -> float:
|
||||||
global_stack = CuraApplication.getInstance().getMachineManager().activeMachine
|
global_stack = cura.CuraApplication.CuraApplication.getInstance().getMachineManager().activeMachine
|
||||||
if not self._layer_height_unit:
|
if not self._layer_height_unit:
|
||||||
unit = global_stack.definition.getProperty("layer_height", "unit")
|
unit = global_stack.definition.getProperty("layer_height", "unit")
|
||||||
if not unit:
|
if not unit:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user