mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-15 18:57:52 -06:00
Efficiency: Don't update model if adding different container types
In fact we might want to delay updating until after the program has started up. Contributes to issue CURA-6597.
This commit is contained in:
parent
cf68157508
commit
a6e3828eaa
1 changed files with 11 additions and 2 deletions
|
@ -3,11 +3,15 @@
|
|||
|
||||
from PyQt5.QtCore import Qt
|
||||
import collections
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
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.
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from UM.Settings.ContainerRegistry import ContainerInterface
|
||||
|
||||
from UM.i18n import i18nCatalog
|
||||
catalog = i18nCatalog("cura")
|
||||
|
||||
|
@ -35,12 +39,17 @@ class IntentCategoryModel(ListModel):
|
|||
self.addRoleName(self.IntentCategoryRole, "intent_category")
|
||||
self.addRoleName(self.WeightRole, "weight")
|
||||
|
||||
ContainerRegistry.getInstance().containerAdded.connect(self.update)
|
||||
ContainerRegistry.getInstance().containerRemoved.connect(self.update)
|
||||
ContainerRegistry.getInstance().containerAdded.connect(self._onContainerChange)
|
||||
ContainerRegistry.getInstance().containerRemoved.connect(self._onContainerChange)
|
||||
IntentManager.getInstance().configurationChanged.connect(self.update)
|
||||
|
||||
self.update()
|
||||
|
||||
## Updates the list of intents if an intent profile was added or removed.
|
||||
def _onContainerChange(self, container: "ContainerInterface") -> None:
|
||||
if container.getMetaDataEntry("type") == "intent":
|
||||
self.update()
|
||||
|
||||
## Updates the list of intents.
|
||||
def update(self) -> None:
|
||||
available_categories = IntentManager.getInstance().currentAvailableIntentCategories()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue