mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 07:27:29 -06:00
List intents per category
This is the naive one. We want to list the default intents multiple times, once for every quality level. Contributes to issue CURA-6597.
This commit is contained in:
parent
5620ee811f
commit
3f29bce263
1 changed files with 15 additions and 3 deletions
|
@ -4,11 +4,10 @@
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from PyQt5.QtCore import QObject
|
from PyQt5.QtCore import QObject
|
||||||
from UM.Qt.ListModel import ListModel
|
from UM.Qt.ListModel import ListModel
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt, pyqtProperty, pyqtSignal
|
||||||
|
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
|
|
||||||
|
|
||||||
class IntentModel(ListModel):
|
class IntentModel(ListModel):
|
||||||
NameRole = Qt.UserRole + 1
|
NameRole = Qt.UserRole + 1
|
||||||
IdRole = Qt.UserRole + 2
|
IdRole = Qt.UserRole + 2
|
||||||
|
@ -21,18 +20,31 @@ class IntentModel(ListModel):
|
||||||
self.addRoleName(self.IdRole, "id")
|
self.addRoleName(self.IdRole, "id")
|
||||||
self.addRoleName(self.ContainerRole, "container")
|
self.addRoleName(self.ContainerRole, "container")
|
||||||
|
|
||||||
|
self._intent_category = "engineering"
|
||||||
|
|
||||||
ContainerRegistry.getInstance().containerAdded.connect(self._onChanged)
|
ContainerRegistry.getInstance().containerAdded.connect(self._onChanged)
|
||||||
ContainerRegistry.getInstance().containerRemoved.connect(self._onChanged)
|
ContainerRegistry.getInstance().containerRemoved.connect(self._onChanged)
|
||||||
|
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
|
_intent_category_changed = pyqtSignal()
|
||||||
|
|
||||||
|
def setIntentCategory(self, new_category: str) -> None:
|
||||||
|
if self._intent_category != new_category:
|
||||||
|
self._intent_category = new_category
|
||||||
|
self._intent_category_changed.emit()
|
||||||
|
|
||||||
|
@pyqtProperty(str, fset=setIntentCategory, notify=_intent_category_changed)
|
||||||
|
def intentCategory(self) -> str:
|
||||||
|
return self._intent_category
|
||||||
|
|
||||||
def _onChanged(self, container):
|
def _onChanged(self, container):
|
||||||
if container.getMetaDataEntry("type") == "intent":
|
if container.getMetaDataEntry("type") == "intent":
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
def _update(self) -> None:
|
def _update(self) -> None:
|
||||||
new_items = []
|
new_items = []
|
||||||
for container in ContainerRegistry.getInstance().findInstanceContainers(type="intent"):
|
for container in ContainerRegistry.getInstance().findInstanceContainers(type = "intent", intent_category = self._intent_category):
|
||||||
new_items.append({"name": container.getName(), "id": container.getId(), "container": container})
|
new_items.append({"name": container.getName(), "id": container.getId(), "container": container})
|
||||||
|
|
||||||
self.setItems(new_items)
|
self.setItems(new_items)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue