Update intent categories upon adding containers or changing configuration

Also upon start-up.

Contributes to issue CURA-6597.
This commit is contained in:
Ghostkeeper 2019-07-04 11:31:59 +02:00
parent d2daa15a13
commit bd2237dc45
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -6,6 +6,7 @@ import collections
from cura.Settings.IntentManager import IntentManager
from UM.Qt.ListModel import ListModel
from UM.Settings.ContainerRegistry import ContainerRegistry #To update the list if anything changes.
from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
@ -34,6 +35,12 @@ class IntentCategoryModel(ListModel):
self.addRoleName(self.IntentCategoryRole, "intent_category")
self.addRoleName(self.WeightRole, "weight")
ContainerRegistry.getInstance().containerAdded.connect(self._onChanged)
ContainerRegistry.getInstance().containerRemoved.connect(self._onChanged)
IntentManager.getInstance().configurationChanged.connect(self._onChanged)
self.update()
## Updates the list of intents.
def update(self) -> None:
available_categories = IntentManager.getInstance().currentAvailableIntentCategories()