mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge branch 'develop' into feature/1229-ay-1284_show-application-used-on-task
This commit is contained in:
commit
7a097e378e
17 changed files with 257 additions and 145 deletions
18
.github/workflows/deploy_mkdocs.yml
vendored
Normal file
18
.github/workflows/deploy_mkdocs.yml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
name: Deploy MkDocs
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-mk-docs:
|
||||
# FIXME: Update @develop to @main after `ops-repo-automation` release.
|
||||
uses: ynput/ops-repo-automation/.github/workflows/deploy_mkdocs.yml@develop
|
||||
with:
|
||||
repo: ${{ github.repository }}
|
||||
secrets:
|
||||
YNPUT_BOT_TOKEN: ${{ secrets.YNPUT_BOT_TOKEN }}
|
||||
CI_USER: ${{ secrets.CI_USER }}
|
||||
CI_EMAIL: ${{ secrets.CI_EMAIL }}
|
||||
|
|
@ -10,6 +10,7 @@ from .projects import (
|
|||
PROJECTS_MODEL_SENDER,
|
||||
FolderTypeItem,
|
||||
TaskTypeItem,
|
||||
ProductTypeIconMapping,
|
||||
)
|
||||
from .hierarchy import (
|
||||
FolderItem,
|
||||
|
|
@ -34,6 +35,7 @@ __all__ = (
|
|||
"PROJECTS_MODEL_SENDER",
|
||||
"FolderTypeItem",
|
||||
"TaskTypeItem",
|
||||
"ProductTypeIconMapping",
|
||||
|
||||
"FolderItem",
|
||||
"TaskItem",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import contextlib
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, Any
|
||||
from typing import Any, Optional
|
||||
from dataclasses import dataclass
|
||||
|
||||
import ayon_api
|
||||
|
|
@ -51,7 +51,7 @@ class StatusItem:
|
|||
self.icon: str = icon
|
||||
self.state: str = state
|
||||
|
||||
def to_data(self) -> Dict[str, Any]:
|
||||
def to_data(self) -> dict[str, Any]:
|
||||
return {
|
||||
"name": self.name,
|
||||
"color": self.color,
|
||||
|
|
@ -125,16 +125,24 @@ class TaskTypeItem:
|
|||
icon (str): Icon name in MaterialIcons ("fiber_new").
|
||||
|
||||
"""
|
||||
def __init__(self, name, short, icon):
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
short: str,
|
||||
icon: str,
|
||||
color: Optional[str],
|
||||
):
|
||||
self.name = name
|
||||
self.short = short
|
||||
self.icon = icon
|
||||
self.color = color
|
||||
|
||||
def to_data(self):
|
||||
return {
|
||||
"name": self.name,
|
||||
"short": self.short,
|
||||
"icon": self.icon,
|
||||
"color": self.color,
|
||||
}
|
||||
|
||||
@classmethod
|
||||
|
|
@ -147,6 +155,7 @@ class TaskTypeItem:
|
|||
name=task_type_data["name"],
|
||||
short=task_type_data["shortName"],
|
||||
icon=task_type_data["icon"],
|
||||
color=task_type_data.get("color"),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -218,6 +227,54 @@ class ProjectItem:
|
|||
return cls(**data)
|
||||
|
||||
|
||||
class ProductTypeIconMapping:
|
||||
def __init__(
|
||||
self,
|
||||
default: Optional[dict[str, str]] = None,
|
||||
definitions: Optional[list[dict[str, str]]] = None,
|
||||
):
|
||||
self._default = default or {}
|
||||
self._definitions = definitions or []
|
||||
|
||||
self._default_def = None
|
||||
self._definitions_by_name = None
|
||||
|
||||
def get_icon(
|
||||
self,
|
||||
product_base_type: Optional[str] = None,
|
||||
product_type: Optional[str] = None,
|
||||
) -> dict[str, str]:
|
||||
defs = self._get_defs_by_name()
|
||||
icon = defs.get(product_type)
|
||||
if icon is None:
|
||||
icon = defs.get(product_base_type)
|
||||
if icon is None:
|
||||
icon = self._get_default_def()
|
||||
return icon.copy()
|
||||
|
||||
def _get_default_def(self) -> dict[str, str]:
|
||||
if self._default_def is None:
|
||||
self._default_def = {
|
||||
"type": "material-symbols",
|
||||
"name": self._default.get("icon", "deployed_code"),
|
||||
"color": self._default.get("color", "#cccccc"),
|
||||
}
|
||||
|
||||
return self._default_def
|
||||
|
||||
def _get_defs_by_name(self) -> dict[str, dict[str, str]]:
|
||||
if self._definitions_by_name is None:
|
||||
self._definitions_by_name = {
|
||||
product_base_type_def["name"]: {
|
||||
"type": "material-symbols",
|
||||
"name": product_base_type_def.get("icon", "deployed_code"),
|
||||
"color": product_base_type_def.get("color", "#cccccc"),
|
||||
}
|
||||
for product_base_type_def in self._definitions
|
||||
}
|
||||
return self._definitions_by_name
|
||||
|
||||
|
||||
def _get_project_items_from_entitiy(
|
||||
projects: list[dict[str, Any]]
|
||||
) -> list[ProjectItem]:
|
||||
|
|
@ -242,6 +299,9 @@ class ProjectsModel(object):
|
|||
self._projects_by_name = NestedCacheItem(
|
||||
levels=1, default_factory=list
|
||||
)
|
||||
self._product_type_icons_mapping = NestedCacheItem(
|
||||
levels=1, default_factory=ProductTypeIconMapping
|
||||
)
|
||||
self._project_statuses_cache = {}
|
||||
self._folder_types_cache = {}
|
||||
self._task_types_cache = {}
|
||||
|
|
@ -255,6 +315,7 @@ class ProjectsModel(object):
|
|||
self._task_types_cache = {}
|
||||
self._projects_cache.reset()
|
||||
self._projects_by_name.reset()
|
||||
self._product_type_icons_mapping.reset()
|
||||
|
||||
def refresh(self):
|
||||
"""Refresh project items.
|
||||
|
|
@ -390,6 +451,27 @@ class ProjectsModel(object):
|
|||
self._task_type_items_getter,
|
||||
)
|
||||
|
||||
def get_product_type_icons_mapping(
|
||||
self, project_name: Optional[str]
|
||||
) -> ProductTypeIconMapping:
|
||||
cache = self._product_type_icons_mapping[project_name]
|
||||
if cache.is_valid:
|
||||
return cache.get_data()
|
||||
|
||||
project_entity = self.get_project_entity(project_name)
|
||||
icons_mapping = ProductTypeIconMapping()
|
||||
if project_entity:
|
||||
product_base_types = (
|
||||
project_entity["config"].get("productBaseTypes", {})
|
||||
)
|
||||
icons_mapping = ProductTypeIconMapping(
|
||||
product_base_types.get("default"),
|
||||
product_base_types.get("definitions")
|
||||
)
|
||||
|
||||
cache.update_data(icons_mapping)
|
||||
return icons_mapping
|
||||
|
||||
def _get_project_items(
|
||||
self, project_name, sender, item_type, cache_obj, getter
|
||||
):
|
||||
|
|
|
|||
|
|
@ -9,7 +9,11 @@ from ayon_core.lib.attribute_definitions import (
|
|||
deserialize_attr_defs,
|
||||
serialize_attr_defs,
|
||||
)
|
||||
from ayon_core.tools.common_models import TaskItem, TagItem
|
||||
from ayon_core.tools.common_models import (
|
||||
TaskItem,
|
||||
TagItem,
|
||||
ProductTypeIconMapping,
|
||||
)
|
||||
|
||||
|
||||
class ProductTypeItem:
|
||||
|
|
@ -78,7 +82,6 @@ class ProductItem:
|
|||
product_type (str): Product type.
|
||||
product_name (str): Product name.
|
||||
product_icon (dict[str, Any]): Product icon definition.
|
||||
product_type_icon (dict[str, Any]): Product type icon definition.
|
||||
product_in_scene (bool): Is product in scene (only when used in DCC).
|
||||
group_name (str): Group name.
|
||||
folder_id (str): Folder id.
|
||||
|
|
@ -93,8 +96,6 @@ class ProductItem:
|
|||
product_base_type: str,
|
||||
product_name: str,
|
||||
product_icon: dict[str, Any],
|
||||
product_type_icon: dict[str, Any],
|
||||
product_base_type_icon: dict[str, Any],
|
||||
group_name: str,
|
||||
folder_id: str,
|
||||
folder_label: str,
|
||||
|
|
@ -106,8 +107,6 @@ class ProductItem:
|
|||
self.product_base_type = product_base_type
|
||||
self.product_name = product_name
|
||||
self.product_icon = product_icon
|
||||
self.product_type_icon = product_type_icon
|
||||
self.product_base_type_icon = product_base_type_icon
|
||||
self.product_in_scene = product_in_scene
|
||||
self.group_name = group_name
|
||||
self.folder_id = folder_id
|
||||
|
|
@ -121,8 +120,6 @@ class ProductItem:
|
|||
"product_base_type": self.product_base_type,
|
||||
"product_name": self.product_name,
|
||||
"product_icon": self.product_icon,
|
||||
"product_type_icon": self.product_type_icon,
|
||||
"product_base_type_icon": self.product_base_type_icon,
|
||||
"product_in_scene": self.product_in_scene,
|
||||
"group_name": self.group_name,
|
||||
"folder_id": self.folder_id,
|
||||
|
|
@ -499,8 +496,8 @@ class BackendLoaderController(_BaseLoaderController):
|
|||
topic (str): Event topic name.
|
||||
data (Optional[dict[str, Any]]): Event data.
|
||||
source (Optional[str]): Event source.
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
|
|
@ -509,8 +506,20 @@ class BackendLoaderController(_BaseLoaderController):
|
|||
|
||||
Returns:
|
||||
set[str]: Set of loaded product ids.
|
||||
"""
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_product_type_icons_mapping(
|
||||
self, project_name: Optional[str]
|
||||
) -> ProductTypeIconMapping:
|
||||
"""Product type icons mapping.
|
||||
|
||||
Returns:
|
||||
ProductTypeIconMapping: Product type icons mapping.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import logging
|
||||
import uuid
|
||||
from typing import Optional
|
||||
|
||||
import ayon_api
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ from ayon_core.tools.common_models import (
|
|||
HierarchyModel,
|
||||
ThumbnailsModel,
|
||||
TagItem,
|
||||
ProductTypeIconMapping,
|
||||
)
|
||||
|
||||
from .abstract import (
|
||||
|
|
@ -198,6 +200,13 @@ class LoaderController(BackendLoaderController, FrontendLoaderController):
|
|||
project_name, sender
|
||||
)
|
||||
|
||||
def get_product_type_icons_mapping(
|
||||
self, project_name: Optional[str]
|
||||
) -> ProductTypeIconMapping:
|
||||
return self._projects_model.get_product_type_icons_mapping(
|
||||
project_name
|
||||
)
|
||||
|
||||
def get_folder_items(self, project_name, sender=None):
|
||||
return self._hierarchy_model.get_folder_items(project_name, sender)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import arrow
|
|||
import ayon_api
|
||||
from ayon_api.operations import OperationsSession
|
||||
|
||||
|
||||
from ayon_core.lib import NestedCacheItem
|
||||
from ayon_core.style import get_default_entity_icon_color
|
||||
from ayon_core.tools.common_models import ProductTypeIconMapping
|
||||
from ayon_core.tools.loader.abstract import (
|
||||
ProductTypeItem,
|
||||
ProductBaseTypeItem,
|
||||
|
|
@ -21,8 +21,11 @@ from ayon_core.tools.loader.abstract import (
|
|||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ayon_api.typing import ProductBaseTypeDict, ProductDict, VersionDict
|
||||
|
||||
from ayon_api.typing import (
|
||||
ProductBaseTypeDict,
|
||||
ProductDict,
|
||||
VersionDict,
|
||||
)
|
||||
|
||||
PRODUCTS_MODEL_SENDER = "products.model"
|
||||
|
||||
|
|
@ -84,42 +87,18 @@ def version_item_from_entity(version):
|
|||
def product_item_from_entity(
|
||||
product_entity: ProductDict,
|
||||
version_entities,
|
||||
product_type_items_by_name: dict[str, ProductTypeItem],
|
||||
product_base_type_items_by_name: dict[str, ProductBaseTypeItem],
|
||||
folder_label,
|
||||
icons_mapping,
|
||||
product_in_scene,
|
||||
):
|
||||
product_attribs = product_entity["attrib"]
|
||||
group = product_attribs.get("productGroup")
|
||||
product_type = product_entity["productType"]
|
||||
product_type_item = product_type_items_by_name.get(product_type)
|
||||
# NOTE This is needed for cases when products were not created on server
|
||||
# using api functions. In that case product type item may not be
|
||||
# available and we need to create a default.
|
||||
if product_type_item is None:
|
||||
product_type_item = create_default_product_type_item(product_type)
|
||||
# Cache the item for future use
|
||||
product_type_items_by_name[product_type] = product_type_item
|
||||
|
||||
product_base_type = product_entity.get("productBaseType")
|
||||
product_base_type_item = product_base_type_items_by_name.get(
|
||||
product_base_type)
|
||||
# Same as for product type item above. Not sure if this is still needed
|
||||
# though.
|
||||
if product_base_type_item is None:
|
||||
product_base_type_item = create_default_product_base_type_item(
|
||||
product_base_type)
|
||||
# Cache the item for future use
|
||||
product_base_type_items_by_name[product_base_type] = (
|
||||
product_base_type_item)
|
||||
|
||||
product_type_icon = product_type_item.icon
|
||||
product_base_type_icon = product_base_type_item.icon
|
||||
product_icon = {
|
||||
"type": "awesome-font",
|
||||
"name": "fa.file-o",
|
||||
"color": get_default_entity_icon_color(),
|
||||
}
|
||||
product_icon = icons_mapping.get_icon(
|
||||
product_base_type, product_type
|
||||
)
|
||||
version_items = {
|
||||
version_entity["id"]: version_item_from_entity(version_entity)
|
||||
for version_entity in version_entities
|
||||
|
|
@ -131,8 +110,6 @@ def product_item_from_entity(
|
|||
product_base_type=product_base_type,
|
||||
product_name=product_entity["name"],
|
||||
product_icon=product_icon,
|
||||
product_type_icon=product_type_icon,
|
||||
product_base_type_icon=product_base_type_icon,
|
||||
product_in_scene=product_in_scene,
|
||||
group_name=group,
|
||||
folder_id=product_entity["folderId"],
|
||||
|
|
@ -141,22 +118,8 @@ def product_item_from_entity(
|
|||
)
|
||||
|
||||
|
||||
def product_type_item_from_data(
|
||||
product_type_data: ProductDict) -> ProductTypeItem:
|
||||
# TODO implement icon implementation
|
||||
# icon = product_type_data["icon"]
|
||||
# color = product_type_data["color"]
|
||||
icon = {
|
||||
"type": "awesome-font",
|
||||
"name": "fa.folder",
|
||||
"color": "#0091B2",
|
||||
}
|
||||
# TODO implement checked logic
|
||||
return ProductTypeItem(product_type_data["name"], icon)
|
||||
|
||||
|
||||
def product_base_type_item_from_data(
|
||||
product_base_type_data: ProductBaseTypeDict
|
||||
product_base_type_data: ProductBaseTypeDict
|
||||
) -> ProductBaseTypeItem:
|
||||
"""Create product base type item from data.
|
||||
|
||||
|
|
@ -174,34 +137,8 @@ def product_base_type_item_from_data(
|
|||
}
|
||||
return ProductBaseTypeItem(
|
||||
name=product_base_type_data["name"],
|
||||
icon=icon)
|
||||
|
||||
|
||||
def create_default_product_type_item(product_type: str) -> ProductTypeItem:
|
||||
icon = {
|
||||
"type": "awesome-font",
|
||||
"name": "fa.folder",
|
||||
"color": "#0091B2",
|
||||
}
|
||||
return ProductTypeItem(product_type, icon)
|
||||
|
||||
|
||||
def create_default_product_base_type_item(
|
||||
product_base_type: str) -> ProductBaseTypeItem:
|
||||
"""Create default product base type item.
|
||||
|
||||
Args:
|
||||
product_base_type (str): Product base type name.
|
||||
|
||||
Returns:
|
||||
ProductBaseTypeItem: Default product base type item.
|
||||
"""
|
||||
icon = {
|
||||
"type": "awesome-font",
|
||||
"name": "fa.folder",
|
||||
"color": "#0091B2",
|
||||
}
|
||||
return ProductBaseTypeItem(product_base_type, icon)
|
||||
icon=icon
|
||||
)
|
||||
|
||||
|
||||
class ProductsModel:
|
||||
|
|
@ -247,7 +184,9 @@ class ProductsModel:
|
|||
self._product_items_cache.reset()
|
||||
self._repre_items_cache.reset()
|
||||
|
||||
def get_product_type_items(self, project_name):
|
||||
def get_product_type_items(
|
||||
self, project_name: Optional[str]
|
||||
) -> list[ProductTypeItem]:
|
||||
"""Product type items for project.
|
||||
|
||||
Args:
|
||||
|
|
@ -255,25 +194,33 @@ class ProductsModel:
|
|||
|
||||
Returns:
|
||||
list[ProductTypeItem]: Product type items.
|
||||
"""
|
||||
|
||||
"""
|
||||
if not project_name:
|
||||
return []
|
||||
|
||||
cache = self._product_type_items_cache[project_name]
|
||||
if not cache.is_valid:
|
||||
icons_mapping = self._get_product_type_icons(project_name)
|
||||
product_types = ayon_api.get_project_product_types(project_name)
|
||||
cache.update_data([
|
||||
product_type_item_from_data(product_type)
|
||||
ProductTypeItem(
|
||||
product_type["name"],
|
||||
icons_mapping.get_icon(product_type=product_type["name"]),
|
||||
)
|
||||
for product_type in product_types
|
||||
])
|
||||
return cache.get_data()
|
||||
|
||||
def get_product_base_type_items(
|
||||
self,
|
||||
project_name: Optional[str]) -> list[ProductBaseTypeItem]:
|
||||
self, project_name: Optional[str]
|
||||
) -> list[ProductBaseTypeItem]:
|
||||
"""Product base type items for the project.
|
||||
|
||||
Notes:
|
||||
This will be used for filtering product types in UI when
|
||||
product base types are fully implemented.
|
||||
|
||||
Args:
|
||||
project_name (optional, str): Project name.
|
||||
|
||||
|
|
@ -286,6 +233,7 @@ class ProductsModel:
|
|||
|
||||
cache = self._product_base_type_items_cache[project_name]
|
||||
if not cache.is_valid:
|
||||
icons_mapping = self._get_product_type_icons(project_name)
|
||||
product_base_types = []
|
||||
# TODO add temp implementation here when it is actually
|
||||
# implemented and available on server.
|
||||
|
|
@ -294,7 +242,10 @@ class ProductsModel:
|
|||
project_name
|
||||
)
|
||||
cache.update_data([
|
||||
product_base_type_item_from_data(product_base_type)
|
||||
ProductBaseTypeItem(
|
||||
product_base_type["name"],
|
||||
icons_mapping.get_icon(product_base_type["name"]),
|
||||
)
|
||||
for product_base_type in product_base_types
|
||||
])
|
||||
return cache.get_data()
|
||||
|
|
@ -511,6 +462,11 @@ class ProductsModel:
|
|||
PRODUCTS_MODEL_SENDER
|
||||
)
|
||||
|
||||
def _get_product_type_icons(
|
||||
self, project_name: Optional[str]
|
||||
) -> ProductTypeIconMapping:
|
||||
return self._controller.get_product_type_icons_mapping(project_name)
|
||||
|
||||
def _get_product_items_by_id(self, project_name, product_ids):
|
||||
product_item_by_id = self._product_item_by_id[project_name]
|
||||
missing_product_ids = set()
|
||||
|
|
@ -524,7 +480,7 @@ class ProductsModel:
|
|||
|
||||
output.update(
|
||||
self._query_product_items_by_ids(
|
||||
project_name, missing_product_ids
|
||||
project_name, product_ids=missing_product_ids
|
||||
)
|
||||
)
|
||||
return output
|
||||
|
|
@ -553,36 +509,18 @@ class ProductsModel:
|
|||
products: Iterable[ProductDict],
|
||||
versions: Iterable[VersionDict],
|
||||
folder_items=None,
|
||||
product_type_items=None,
|
||||
product_base_type_items: Optional[Iterable[ProductBaseTypeItem]] = None
|
||||
):
|
||||
if folder_items is None:
|
||||
folder_items = self._controller.get_folder_items(project_name)
|
||||
|
||||
if product_type_items is None:
|
||||
product_type_items = self.get_product_type_items(project_name)
|
||||
|
||||
if product_base_type_items is None:
|
||||
product_base_type_items = self.get_product_base_type_items(
|
||||
project_name
|
||||
)
|
||||
|
||||
loaded_product_ids = self._controller.get_loaded_product_ids()
|
||||
|
||||
versions_by_product_id = collections.defaultdict(list)
|
||||
for version in versions:
|
||||
versions_by_product_id[version["productId"]].append(version)
|
||||
product_type_items_by_name = {
|
||||
product_type_item.name: product_type_item
|
||||
for product_type_item in product_type_items
|
||||
}
|
||||
|
||||
product_base_type_items_by_name: dict[str, ProductBaseTypeItem] = {
|
||||
product_base_type_item.name: product_base_type_item
|
||||
for product_base_type_item in product_base_type_items
|
||||
}
|
||||
|
||||
output: dict[str, ProductItem] = {}
|
||||
icons_mapping = self._get_product_type_icons(project_name)
|
||||
for product in products:
|
||||
product_id = product["id"]
|
||||
folder_id = product["folderId"]
|
||||
|
|
@ -595,9 +533,8 @@ class ProductsModel:
|
|||
product_item = product_item_from_entity(
|
||||
product,
|
||||
versions,
|
||||
product_type_items_by_name,
|
||||
product_base_type_items_by_name,
|
||||
folder_item.label,
|
||||
icons_mapping,
|
||||
product_id in loaded_product_ids,
|
||||
)
|
||||
output[product_id] = product_item
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ PRODUCT_ID_ROLE = QtCore.Qt.UserRole + 6
|
|||
PRODUCT_NAME_ROLE = QtCore.Qt.UserRole + 7
|
||||
PRODUCT_TYPE_ROLE = QtCore.Qt.UserRole + 8
|
||||
PRODUCT_BASE_TYPE_ROLE = QtCore.Qt.UserRole + 9
|
||||
PRODUCT_TYPE_ICON_ROLE = QtCore.Qt.UserRole + 10
|
||||
PRODUCT_IN_SCENE_ROLE = QtCore.Qt.UserRole + 11
|
||||
VERSION_ID_ROLE = QtCore.Qt.UserRole + 12
|
||||
VERSION_HERO_ROLE = QtCore.Qt.UserRole + 13
|
||||
|
|
@ -228,10 +227,7 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
return super().data(index, role)
|
||||
|
||||
if role == QtCore.Qt.DecorationRole:
|
||||
if col == 1:
|
||||
role = PRODUCT_TYPE_ICON_ROLE
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
if (
|
||||
role == VERSION_NAME_EDIT_ROLE
|
||||
|
|
@ -455,7 +451,6 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
model_item = QtGui.QStandardItem(product_item.product_name)
|
||||
model_item.setEditable(False)
|
||||
icon = get_qt_icon(product_item.product_icon)
|
||||
product_type_icon = get_qt_icon(product_item.product_type_icon)
|
||||
model_item.setColumnCount(self.columnCount())
|
||||
model_item.setData(icon, QtCore.Qt.DecorationRole)
|
||||
model_item.setData(product_id, PRODUCT_ID_ROLE)
|
||||
|
|
@ -464,7 +459,6 @@ class ProductsModel(QtGui.QStandardItemModel):
|
|||
product_item.product_base_type, PRODUCT_BASE_TYPE_ROLE
|
||||
)
|
||||
model_item.setData(product_item.product_type, PRODUCT_TYPE_ROLE)
|
||||
model_item.setData(product_type_icon, PRODUCT_TYPE_ICON_ROLE)
|
||||
model_item.setData(product_item.folder_id, FOLDER_ID_ROLE)
|
||||
|
||||
self._product_items_by_id[product_id] = product_item
|
||||
|
|
|
|||
|
|
@ -1147,6 +1147,8 @@ class LogItemMessage(QtWidgets.QTextEdit):
|
|||
QtWidgets.QSizePolicy.Preferred,
|
||||
QtWidgets.QSizePolicy.Maximum
|
||||
)
|
||||
self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
||||
document = self.document()
|
||||
document.documentLayout().documentSizeChanged.connect(
|
||||
self._adjust_minimum_size
|
||||
|
|
|
|||
|
|
@ -146,19 +146,19 @@ class TasksModel(QtGui.QStandardItemModel):
|
|||
self._controller.get_current_project_name()
|
||||
)
|
||||
}
|
||||
icon_name_by_task_name = {}
|
||||
type_item_by_task_name = {}
|
||||
for task_items in task_items_by_folder_path.values():
|
||||
for task_item in task_items:
|
||||
task_name = task_item.name
|
||||
if (
|
||||
task_name not in new_task_names
|
||||
or task_name in icon_name_by_task_name
|
||||
or task_name in type_item_by_task_name
|
||||
):
|
||||
continue
|
||||
task_type_name = task_item.task_type
|
||||
task_type_item = task_type_items.get(task_type_name)
|
||||
if task_type_item:
|
||||
icon_name_by_task_name[task_name] = task_type_item.icon
|
||||
type_item_by_task_name[task_name] = task_type_item
|
||||
|
||||
for task_name in new_task_names:
|
||||
item = self._items_by_name.get(task_name)
|
||||
|
|
@ -171,13 +171,18 @@ class TasksModel(QtGui.QStandardItemModel):
|
|||
if not task_name:
|
||||
continue
|
||||
|
||||
icon_name = icon_name_by_task_name.get(task_name)
|
||||
icon = None
|
||||
icon = icon_name = icon_color = None
|
||||
task_type_item = type_item_by_task_name.get(task_name)
|
||||
if task_type_item is not None:
|
||||
icon_name = task_type_item.icon
|
||||
icon_color = task_type_item.color
|
||||
if icon_name:
|
||||
if not icon_color:
|
||||
icon_color = get_default_entity_icon_color()
|
||||
icon = get_qt_icon({
|
||||
"type": "material-symbols",
|
||||
"name": icon_name,
|
||||
"color": get_default_entity_icon_color(),
|
||||
"color": icon_color,
|
||||
})
|
||||
if icon is None:
|
||||
icon = default_icon
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from typing import Optional
|
||||
|
||||
import ayon_api
|
||||
|
||||
from ayon_core.lib.events import QueuedEventSystem
|
||||
|
|
@ -6,7 +8,11 @@ from ayon_core.pipeline import (
|
|||
registered_host,
|
||||
get_current_context,
|
||||
)
|
||||
from ayon_core.tools.common_models import HierarchyModel, ProjectsModel
|
||||
from ayon_core.tools.common_models import (
|
||||
HierarchyModel,
|
||||
ProjectsModel,
|
||||
ProductTypeIconMapping,
|
||||
)
|
||||
|
||||
from .models import SiteSyncModel, ContainersModel
|
||||
|
||||
|
|
@ -93,6 +99,13 @@ class SceneInventoryController:
|
|||
project_name, None
|
||||
)
|
||||
|
||||
def get_product_type_icons_mapping(
|
||||
self, project_name: Optional[str]
|
||||
) -> ProductTypeIconMapping:
|
||||
return self._projects_model.get_product_type_icons_mapping(
|
||||
project_name
|
||||
)
|
||||
|
||||
# Containers methods
|
||||
def get_containers(self):
|
||||
return self._containers_model.get_containers()
|
||||
|
|
|
|||
|
|
@ -214,9 +214,6 @@ class InventoryModel(QtGui.QStandardItemModel):
|
|||
group_icon = qtawesome.icon(
|
||||
"fa.object-group", color=self._default_icon_color
|
||||
)
|
||||
product_type_icon = qtawesome.icon(
|
||||
"fa.folder", color="#0091B2"
|
||||
)
|
||||
group_item_font = QtGui.QFont()
|
||||
group_item_font.setBold(True)
|
||||
|
||||
|
|
@ -303,7 +300,7 @@ class InventoryModel(QtGui.QStandardItemModel):
|
|||
remote_site_progress = "{}%".format(
|
||||
max(progress["remote_site"], 0) * 100
|
||||
)
|
||||
|
||||
product_type_icon = get_qt_icon(repre_info.product_type_icon)
|
||||
group_item = QtGui.QStandardItem()
|
||||
group_item.setColumnCount(root_item.columnCount())
|
||||
group_item.setData(group_name, QtCore.Qt.DisplayRole)
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ class RepresentationInfo:
|
|||
product_id,
|
||||
product_name,
|
||||
product_type,
|
||||
product_type_icon,
|
||||
product_group,
|
||||
version_id,
|
||||
representation_name,
|
||||
|
|
@ -135,6 +136,7 @@ class RepresentationInfo:
|
|||
self.product_id = product_id
|
||||
self.product_name = product_name
|
||||
self.product_type = product_type
|
||||
self.product_type_icon = product_type_icon
|
||||
self.product_group = product_group
|
||||
self.version_id = version_id
|
||||
self.representation_name = representation_name
|
||||
|
|
@ -153,7 +155,17 @@ class RepresentationInfo:
|
|||
|
||||
@classmethod
|
||||
def new_invalid(cls):
|
||||
return cls(None, None, None, None, None, None, None, None)
|
||||
return cls(
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
|
||||
|
||||
class VersionItem:
|
||||
|
|
@ -229,6 +241,9 @@ class ContainersModel:
|
|||
def get_representation_info_items(self, project_name, representation_ids):
|
||||
output = {}
|
||||
missing_repre_ids = set()
|
||||
icons_mapping = self._controller.get_product_type_icons_mapping(
|
||||
project_name
|
||||
)
|
||||
for repre_id in representation_ids:
|
||||
try:
|
||||
uuid.UUID(repre_id)
|
||||
|
|
@ -253,6 +268,7 @@ class ContainersModel:
|
|||
"product_id": None,
|
||||
"product_name": None,
|
||||
"product_type": None,
|
||||
"product_type_icon": None,
|
||||
"product_group": None,
|
||||
"version_id": None,
|
||||
"representation_name": None,
|
||||
|
|
@ -265,10 +281,17 @@ class ContainersModel:
|
|||
kwargs["folder_id"] = folder["id"]
|
||||
kwargs["folder_path"] = folder["path"]
|
||||
if product:
|
||||
product_type = product["productType"]
|
||||
product_base_type = product.get("productBaseType")
|
||||
icon = icons_mapping.get_icon(
|
||||
product_base_type=product_base_type,
|
||||
product_type=product_type,
|
||||
)
|
||||
group = product["attrib"]["productGroup"]
|
||||
kwargs["product_id"] = product["id"]
|
||||
kwargs["product_name"] = product["name"]
|
||||
kwargs["product_type"] = product["productType"]
|
||||
kwargs["product_type_icon"] = icon
|
||||
kwargs["product_group"] = group
|
||||
if version:
|
||||
kwargs["version_id"] = version["id"]
|
||||
|
|
|
|||
|
|
@ -186,8 +186,15 @@ class StatusDelegate(QtWidgets.QStyledItemDelegate):
|
|||
)
|
||||
fm = QtGui.QFontMetrics(option.font)
|
||||
if text_rect.width() < fm.width(text):
|
||||
text = self._get_status_short_name(index)
|
||||
if text_rect.width() < fm.width(text):
|
||||
short_text = self._get_status_short_name(index)
|
||||
if short_text:
|
||||
text = short_text
|
||||
|
||||
text = fm.elidedText(
|
||||
text, QtCore.Qt.ElideRight, text_rect.width()
|
||||
)
|
||||
# Allow at least one character
|
||||
if len(text) < 2:
|
||||
text = ""
|
||||
|
||||
fg_color = self._get_status_color(index)
|
||||
|
|
|
|||
|
|
@ -234,10 +234,11 @@ class TasksQtModel(QtGui.QStandardItemModel):
|
|||
)
|
||||
icon = None
|
||||
if task_type_item is not None:
|
||||
color = task_type_item.color or get_default_entity_icon_color()
|
||||
icon = get_qt_icon({
|
||||
"type": "material-symbols",
|
||||
"name": task_type_item.icon,
|
||||
"color": get_default_entity_icon_color()
|
||||
"color": color,
|
||||
})
|
||||
|
||||
if icon is None:
|
||||
|
|
|
|||
|
|
@ -418,7 +418,7 @@ class ExpandingTextEdit(QtWidgets.QTextEdit):
|
|||
"""QTextEdit which does not have sroll area but expands height."""
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(ExpandingTextEdit, self).__init__(parent)
|
||||
super().__init__(parent)
|
||||
|
||||
size_policy = self.sizePolicy()
|
||||
size_policy.setHeightForWidth(True)
|
||||
|
|
@ -441,14 +441,18 @@ class ExpandingTextEdit(QtWidgets.QTextEdit):
|
|||
margins = self.contentsMargins()
|
||||
|
||||
document_width = 0
|
||||
if width >= margins.left() + margins.right():
|
||||
document_width = width - margins.left() - margins.right()
|
||||
margins_size = margins.left() + margins.right()
|
||||
if width >= margins_size:
|
||||
document_width = width - margins_size
|
||||
|
||||
document = self.document().clone()
|
||||
document.setTextWidth(document_width)
|
||||
|
||||
return math.ceil(
|
||||
margins.top() + document.size().height() + margins.bottom()
|
||||
margins.top()
|
||||
+ document.size().height()
|
||||
+ margins.bottom()
|
||||
+ 2
|
||||
)
|
||||
|
||||
def sizeHint(self):
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ theme:
|
|||
- media: "(prefers-color-scheme: dark)"
|
||||
scheme: slate
|
||||
toggle:
|
||||
icon: material/toggle-switch-off-outline
|
||||
icon: material/weather-sunny
|
||||
name: Switch to light mode
|
||||
- media: "(prefers-color-scheme: light)"
|
||||
scheme: default
|
||||
toggle:
|
||||
icon: material/toggle-switch
|
||||
icon: material/weather-night
|
||||
name: Switch to dark mode
|
||||
logo: img/ay-symbol-blackw-full.png
|
||||
favicon: img/favicon.ico
|
||||
|
|
|
|||
9
mkdocs_requirements.txt
Normal file
9
mkdocs_requirements.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
mkdocs-material >= 9.6.7
|
||||
mkdocs-autoapi >= 0.4.0
|
||||
mkdocstrings-python >= 1.16.2
|
||||
mkdocs-minify-plugin >= 0.8.0
|
||||
markdown-checklist >= 0.4.4
|
||||
mdx-gh-links >= 0.4
|
||||
pymdown-extensions >= 10.14.3
|
||||
mike >= 2.1.3
|
||||
mkdocstrings-shell >= 1.0.2
|
||||
Loading…
Add table
Add a link
Reference in a new issue