mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-01 00:04:27 +08:00
Resolve circular imports
Can't import CuraApplication because we create instances of IntentManager from the IntentsModel which is created in CuraApplication. Contributes to issue CURA-6597.
This commit is contained in:
parent
36971f0058
commit
c75b83be21
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from PyQt5.QtCore import QObject, pyqtSignal
|
from PyQt5.QtCore import QObject, pyqtSignal
|
||||||
from typing import Any, Dict, List, Set, Tuple, TYPE_CHECKING
|
from typing import Any, Dict, List, Set, Tuple, TYPE_CHECKING
|
||||||
from cura.CuraApplication import CuraApplication
|
import cura.CuraApplication
|
||||||
from cura.Settings.ExtruderManager import ExtruderManager
|
from cura.Settings.ExtruderManager import ExtruderManager
|
||||||
from UM.Settings.InstanceContainer import InstanceContainer
|
from UM.Settings.InstanceContainer import InstanceContainer
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ class IntentManager(QObject):
|
|||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
CuraApplication.getInstance().getMachineManager().activeStackChanged.connect(self.configurationChanged)
|
cura.CuraApplication.CuraApplication.getInstance().getMachineManager().activeStackChanged.connect(self.configurationChanged)
|
||||||
self.configurationChanged.connect(self.selectDefaultIntent)
|
self.configurationChanged.connect(self.selectDefaultIntent)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class IntentManager(QObject):
|
|||||||
# \return A list of metadata dictionaries matching the search criteria, or
|
# \return A list of metadata dictionaries matching the search criteria, or
|
||||||
# an empty list if nothing was found.
|
# an empty list if nothing was found.
|
||||||
def intentMetadatas(self, definition_id: str, nozzle_name: str, material_id: str) -> List[Dict[str, Any]]:
|
def intentMetadatas(self, definition_id: str, nozzle_name: str, material_id: str) -> List[Dict[str, Any]]:
|
||||||
registry = CuraApplication.getInstance().getContainerRegistry()
|
registry = cura.CuraApplication.CuraApplication.getInstance().getContainerRegistry()
|
||||||
return registry.findContainersMetadata(definition = definition_id, variant = nozzle_name, material_id = material_id)
|
return registry.findContainersMetadata(definition = definition_id, variant = nozzle_name, material_id = material_id)
|
||||||
|
|
||||||
## Collects and returns all intent categories available for the given
|
## Collects and returns all intent categories available for the given
|
||||||
@ -67,7 +67,7 @@ class IntentManager(QObject):
|
|||||||
# \return A list of tuples of intent_category and quality_type. The actual
|
# \return A list of tuples of intent_category and quality_type. The actual
|
||||||
# instance may vary per extruder.
|
# instance may vary per extruder.
|
||||||
def currentAvailableIntents(self) -> List[Tuple[str, str]]:
|
def currentAvailableIntents(self) -> List[Tuple[str, str]]:
|
||||||
application = CuraApplication.getInstance()
|
application = cura.CuraApplication.CuraApplication.getInstance()
|
||||||
global_stack = application.getGlobalContainerStack()
|
global_stack = application.getGlobalContainerStack()
|
||||||
if global_stack is None:
|
if global_stack is None:
|
||||||
return [("default", "normal")]
|
return [("default", "normal")]
|
||||||
@ -100,7 +100,7 @@ class IntentManager(QObject):
|
|||||||
# \return List of all categories in the current configurations of all
|
# \return List of all categories in the current configurations of all
|
||||||
# extruders.
|
# extruders.
|
||||||
def currentAvailableIntentCategories(self) -> List[str]:
|
def currentAvailableIntentCategories(self) -> List[str]:
|
||||||
global_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
|
||||||
if global_stack is None:
|
if global_stack is None:
|
||||||
return ["default"]
|
return ["default"]
|
||||||
current_definition_id = global_stack.definition.getMetaDataEntry("id")
|
current_definition_id = global_stack.definition.getMetaDataEntry("id")
|
||||||
@ -115,11 +115,11 @@ class IntentManager(QObject):
|
|||||||
# the configuration, an extruder can't match the intent that the user
|
# the configuration, an extruder can't match the intent that the user
|
||||||
# selects, or just when creating a new printer.
|
# selects, or just when creating a new printer.
|
||||||
def getDefaultIntent(self) -> InstanceContainer:
|
def getDefaultIntent(self) -> InstanceContainer:
|
||||||
return CuraApplication.getInstance().empty_intent_container
|
return cura.CuraApplication.CuraApplication.getInstance().empty_intent_container
|
||||||
|
|
||||||
## Apply intent on the stacks.
|
## Apply intent on the stacks.
|
||||||
def selectIntent(self, intent_category: str, quality_type: str) -> None:
|
def selectIntent(self, intent_category: str, quality_type: str) -> None:
|
||||||
application = CuraApplication.getInstance()
|
application = cura.CuraApplication.CuraApplication.getInstance()
|
||||||
global_stack = application.getGlobalContainerStack()
|
global_stack = application.getGlobalContainerStack()
|
||||||
if global_stack is None:
|
if global_stack is None:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user