Просмотр исходного кода

Fix updating intents list when printer changes

Contributes to issue CURA-6600.
Ghostkeeper 5 лет назад
Родитель
Сommit
c9191beb61
1 измененных файлов с 3 добавлено и 8 удалено
  1. 3 8
      cura/Machines/Models/IntentModel.py

+ 3 - 8
cura/Machines/Models/IntentModel.py

@@ -6,7 +6,6 @@ from typing import Optional, List, Dict, Any
 from PyQt5.QtCore import Qt, QObject, pyqtProperty, pyqtSignal
 from PyQt5.QtCore import Qt, QObject, pyqtProperty, pyqtSignal
 
 
 from UM.Qt.ListModel import ListModel
 from UM.Qt.ListModel import ListModel
-from UM.Settings.ContainerRegistry import ContainerRegistry
 
 
 from cura.Machines.ContainerTree import ContainerTree
 from cura.Machines.ContainerTree import ContainerTree
 from cura.Settings.IntentManager import IntentManager
 from cura.Settings.IntentManager import IntentManager
@@ -25,9 +24,9 @@ class IntentModel(ListModel):
 
 
         self._intent_category = "engineering"
         self._intent_category = "engineering"
 
 
-        ContainerRegistry.getInstance().containerAdded.connect(self._onChanged)
-        ContainerRegistry.getInstance().containerRemoved.connect(self._onChanged)
-
+        machine_manager = cura.CuraApplication.CuraApplication.getInstance().getMachineManager()
+        machine_manager.globalContainerChanged.connect(self._update)
+        machine_manager.activeStackChanged.connect(self._update)
         self._update()
         self._update()
 
 
     intentCategoryChanged = pyqtSignal()
     intentCategoryChanged = pyqtSignal()
@@ -42,10 +41,6 @@ class IntentModel(ListModel):
     def intentCategory(self) -> str:
     def intentCategory(self) -> str:
         return self._intent_category
         return self._intent_category
 
 
-    def _onChanged(self, container):
-        if container.getMetaDataEntry("type") == "intent":
-            self._update()
-
     def _update(self) -> None:
     def _update(self) -> None:
         new_items = []  # type: List[Dict[str, Any]]
         new_items = []  # type: List[Dict[str, Any]]
         global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
         global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()