Skip to content

Commit

Permalink
Merge branch '5.7' into CURA-11465-addprinter-window-jumps-to-cloud-p…
Browse files Browse the repository at this point in the history
…rinter
  • Loading branch information
saumyaj3 authored Mar 28, 2024
2 parents c3b0fa5 + ba10318 commit 3e5edaa
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 52 deletions.
2 changes: 1 addition & 1 deletion cura/Machines/MachineErrorChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, parent: Optional[QObject] = None) -> None:

self._keys_to_check = set() # type: Set[str]

self._num_keys_to_check_per_update = 10
self._num_keys_to_check_per_update = 1

def initialize(self) -> None:
self._error_check_timer.timeout.connect(self._rescheduleCheck)
Expand Down
53 changes: 30 additions & 23 deletions cura/Settings/SettingInheritanceManager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2017 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from typing import List, Optional, TYPE_CHECKING
from typing import List, Optional, Set, TYPE_CHECKING

from PyQt6.QtCore import QObject, QTimer, pyqtProperty, pyqtSignal
from UM.FlameProfiler import pyqtSlot
Expand Down Expand Up @@ -168,37 +168,26 @@ def _recursiveCheck(self, definition: "SettingDefinition") -> bool:
def settingsWithInheritanceWarning(self) -> List[str]:
return self._settings_with_inheritance_warning

def _settingIsOverwritingInheritance(self, key: str, stack: ContainerStack = None) -> bool:
"""Check if a setting has an inheritance function that is overwritten"""
def _userSettingIsOverwritingInheritance(self, key: str, stack: ContainerStack, all_keys: Set[str] = set()) -> bool:
"""Check if a setting known as having a User state has an inheritance function that is overwritten"""

has_setting_function = False
if not stack:
stack = self._active_container_stack
if not stack: # No active container stack yet!
return False

if self._active_container_stack is None:
return False
all_keys = self._active_container_stack.getAllKeys()

containers = [] # type: List[ContainerInterface]

has_user_state = stack.getProperty(key, "state") == InstanceState.User
"""Check if the setting has a user state. If not, it is never overwritten."""

if not has_user_state:
return False

# If a setting is not enabled, don't label it as overwritten (It's never visible anyway).
if not stack.getProperty(key, "enabled"):
return False

user_container = stack.getTop()
"""Also check if the top container is not a setting function (this happens if the inheritance is restored)."""
# Also check if the top container is not a setting function (this happens if the inheritance is restored).

if user_container and isinstance(user_container.getProperty(key, "value"), SettingFunction):
return False

if not all_keys:
all_keys = self._active_container_stack.getAllKeys()

## Mash all containers for all the stacks together.
while stack:
containers.extend(stack.getContainers())
Expand Down Expand Up @@ -229,17 +218,35 @@ def _settingIsOverwritingInheritance(self, key: str, stack: ContainerStack = Non
break # There is a setting function somewhere, stop looking deeper.
return has_setting_function and has_non_function_value

def _settingIsOverwritingInheritance(self, key: str, stack: ContainerStack = None) -> bool:
"""Check if a setting has an inheritance function that is overwritten"""

if not stack:
stack = self._active_container_stack
if not stack: # No active container stack yet!
return False

if self._active_container_stack is None:
return False

has_user_state = stack.getProperty(key, "state") == InstanceState.User

if not has_user_state:
return False

return self._userSettingIsOverwritingInheritance(key, stack)

def _update(self) -> None:
self._settings_with_inheritance_warning = [] # Reset previous data.

# Make sure that the GlobalStack is not None. sometimes the globalContainerChanged signal gets here late.
if self._global_container_stack is None:
if self._global_container_stack is None or self._active_container_stack is None:
return

# Check all setting keys that we know of and see if they are overridden.
for setting_key in self._global_container_stack.getAllKeys():
override = self._settingIsOverwritingInheritance(setting_key)
if override:
# Check all user setting keys that we know of and see if they are overridden.
all_keys = self._active_container_stack.getAllKeys()
for setting_key in self._active_container_stack.getAllKeysWithUserState():
if self._userSettingIsOverwritingInheritance(setting_key, self._active_container_stack, all_keys):
self._settings_with_inheritance_warning.append(setting_key)

# Check all the categories if any of their children have their inheritance overwritten.
Expand Down
Loading

0 comments on commit 3e5edaa

Please sign in to comment.