mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Lots of import fixes. Eliminated the import hacks such as those used inside UM/Settings/__init__.py.
CURA-2917
This commit is contained in:
parent
5884509af1
commit
74e5798509
20 changed files with 134 additions and 128 deletions
|
@ -2,9 +2,7 @@
|
|||
# Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
|
||||
import UM.Settings
|
||||
from UM.Application import Application
|
||||
import cura.Settings
|
||||
from UM.Logger import Logger
|
||||
|
||||
|
||||
|
@ -13,6 +11,12 @@ from UM.Logger import Logger
|
|||
# because some profiles tend to have 'hardcoded' values that break our inheritance. A good example of that are the
|
||||
# speed settings. If all the children of print_speed have a single value override, changing the speed won't
|
||||
# actually do anything, as only the 'leaf' settings are used by the engine.
|
||||
from UM.Settings.ContainerStack import ContainerStack
|
||||
from UM.Settings.SettingFunction import SettingFunction
|
||||
from UM.Settings.SettingInstance import InstanceState
|
||||
|
||||
from cura.Settings.ExtruderManager import ExtruderManager
|
||||
|
||||
class SettingInheritanceManager(QObject):
|
||||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
|
@ -22,7 +26,7 @@ class SettingInheritanceManager(QObject):
|
|||
self._active_container_stack = None
|
||||
self._onGlobalContainerChanged()
|
||||
|
||||
cura.Settings.ExtruderManager.getInstance().activeExtruderChanged.connect(self._onActiveExtruderChanged)
|
||||
ExtruderManager.getInstance().activeExtruderChanged.connect(self._onActiveExtruderChanged)
|
||||
self._onActiveExtruderChanged()
|
||||
|
||||
settingsWithIntheritanceChanged = pyqtSignal()
|
||||
|
@ -44,7 +48,7 @@ class SettingInheritanceManager(QObject):
|
|||
multi_extrusion = self._global_container_stack.getProperty("machine_extruder_count", "value") > 1
|
||||
if not multi_extrusion:
|
||||
return self._settings_with_inheritance_warning
|
||||
extruder = cura.Settings.ExtruderManager.getInstance().getExtruderStack(extruder_index)
|
||||
extruder = ExtruderManager.getInstance().getExtruderStack(extruder_index)
|
||||
if not extruder:
|
||||
Logger.log("w", "Unable to find extruder for current machine with index %s", extruder_index)
|
||||
return []
|
||||
|
@ -70,7 +74,7 @@ class SettingInheritanceManager(QObject):
|
|||
self._update()
|
||||
|
||||
def _onActiveExtruderChanged(self):
|
||||
new_active_stack = cura.Settings.ExtruderManager.getInstance().getActiveExtruderStack()
|
||||
new_active_stack = ExtruderManager.getInstance().getActiveExtruderStack()
|
||||
if not new_active_stack:
|
||||
new_active_stack = self._global_container_stack
|
||||
|
||||
|
@ -136,14 +140,14 @@ class SettingInheritanceManager(QObject):
|
|||
return self._settings_with_inheritance_warning
|
||||
|
||||
## Check if a setting has an inheritance function that is overwritten
|
||||
def _settingIsOverwritingInheritance(self, key, stack = None):
|
||||
def _settingIsOverwritingInheritance(self, key: str, stack: ContainerStack = None) -> bool:
|
||||
has_setting_function = False
|
||||
if not stack:
|
||||
stack = self._active_container_stack
|
||||
containers = []
|
||||
|
||||
## Check if the setting has a user state. If not, it is never overwritten.
|
||||
has_user_state = stack.getProperty(key, "state") == UM.Settings.InstanceState.User
|
||||
has_user_state = stack.getProperty(key, "state") == InstanceState.User
|
||||
if not has_user_state:
|
||||
return False
|
||||
|
||||
|
@ -152,7 +156,7 @@ class SettingInheritanceManager(QObject):
|
|||
return False
|
||||
|
||||
## Also check if the top container is not a setting function (this happens if the inheritance is restored).
|
||||
if isinstance(stack.getTop().getProperty(key, "value"), UM.Settings.SettingFunction):
|
||||
if isinstance(stack.getTop().getProperty(key, "value"), SettingFunction):
|
||||
return False
|
||||
|
||||
## Mash all containers for all the stacks together.
|
||||
|
@ -167,7 +171,7 @@ class SettingInheritanceManager(QObject):
|
|||
continue
|
||||
if value is not None:
|
||||
# If a setting doesn't use any keys, it won't change it's value, so treat it as if it's a fixed value
|
||||
has_setting_function = isinstance(value, UM.Settings.SettingFunction) and len(value.getUsedSettingKeys()) > 0
|
||||
has_setting_function = isinstance(value, SettingFunction) and len(value.getUsedSettingKeys()) > 0
|
||||
if has_setting_function is False:
|
||||
has_non_function_value = True
|
||||
continue
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue