Skip to content

Commit

Permalink
Loader tool: Refactor loader tool (for AYON) (#5729)
Browse files Browse the repository at this point in the history
* initial commitof ayon loader

* tweaks in ayon utils

* implemented product type filtering

* products have icons and proper style

* fix refresh of products

* added enable grouping checkbox

* added icons and sorting of grouped items

* fix version delegate

* add splitter between context and product type filtering

* fix products filtering by name

* implemented 'filter_repre_contexts_by_loader'

* implemented base of action items

* implemented folder underline colors

* changed version items to dictionary

* use 'product_id' instead of 'subset_id'

* base implementation of info widget

* require less to trigger action

* set selection of version ids in controller

* added representation widget and related logic changes

* implemented actions in representations widget

* handle load error

* use versions for subset loader

* fix representations widget

* implemente "in scene" logic properly

* use ayon loader in host tools

* fix used function to get tasks

* show actions per representation name

* center window

* add window flag to loader window

* added 'ThumbnailPainterWidget' to tool utils

* implemented thumbnails model

* implement thumbnail widget

* fix FolderItem args docstring

* bypass bug in ayon_api

* fix sorting of folders

* added refresh button

* added expected selection and go to current context

* added information if project item is library project

* added more filtering options to projects widget

* added missing information abou is library to model items

* remove select project item on selection change

* filter out non library projects

* set current context project to project combobox

* change window title

* fix hero version queries

* move current project to the top

* fix reset

* change icon for library projects

* added libraries separator to project widget

* show libraries separator in loader

* ise single line expression

* library loader tool is loader tool in AYON mode

* fixes in grouping model

* implemented grouping logic

* use loader in tray action

* better initial sizes

* moved 'ActionItem' to abstract

* filter loaders by tool name based on current context project

* formatting fixes

* separate abstract classes into frontend and backend abstractions

* added docstrings to abstractions

* implemented 'to_data' and 'from_data' for action item options

* added more docstrings

* first filter representation contexts and then create action items

* implemented 'refresh' method

* do not reset controller in '_on_first_show'

Method '_on_show_timer' will take about the reset.

* 'ThumbnailPainterWidget' have more options of bg painting

* do not use checkerboard in loader thumbnail

* fix condition

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>

---------

Co-authored-by: Roy Nieterau <roy_nieterau@hotmail.com>
  • Loading branch information
iLLiCiTiT and BigRoy committed Oct 11, 2023
1 parent df431b6 commit 0498a40
Show file tree
Hide file tree
Showing 35 changed files with 6,843 additions and 74 deletions.
40 changes: 27 additions & 13 deletions openpype/modules/avalon_apps/avalon_app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os

from openpype import AYON_SERVER_ENABLED
from openpype.modules import OpenPypeModule, ITrayModule


Expand Down Expand Up @@ -75,20 +76,11 @@ def tray_exit(self, *_a, **_kw):

def show_library_loader(self):
if self._library_loader_window is None:
from qtpy import QtCore
from openpype.tools.libraryloader import LibraryLoaderWindow
from openpype.pipeline import install_openpype_plugins

libraryloader = LibraryLoaderWindow(
show_projects=True,
show_libraries=True
)
# Remove always on top flag for tray
window_flags = libraryloader.windowFlags()
if window_flags | QtCore.Qt.WindowStaysOnTopHint:
window_flags ^= QtCore.Qt.WindowStaysOnTopHint
libraryloader.setWindowFlags(window_flags)
self._library_loader_window = libraryloader
if AYON_SERVER_ENABLED:
self._init_ayon_loader()
else:
self._init_library_loader()

install_openpype_plugins()

Expand All @@ -106,3 +98,25 @@ def webserver_initialization(self, server_manager):
if self.tray_initialized:
from .rest_api import AvalonRestApiResource
self.rest_api_obj = AvalonRestApiResource(self, server_manager)

def _init_library_loader(self):
from qtpy import QtCore
from openpype.tools.libraryloader import LibraryLoaderWindow

libraryloader = LibraryLoaderWindow(
show_projects=True,
show_libraries=True
)
# Remove always on top flag for tray
window_flags = libraryloader.windowFlags()
if window_flags | QtCore.Qt.WindowStaysOnTopHint:
window_flags ^= QtCore.Qt.WindowStaysOnTopHint
libraryloader.setWindowFlags(window_flags)
self._library_loader_window = libraryloader

def _init_ayon_loader(self):
from openpype.tools.ayon_loader.ui import LoaderWindow

libraryloader = LoaderWindow()

self._library_loader_window = libraryloader
2 changes: 2 additions & 0 deletions openpype/pipeline/load/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

loaders_from_repre_context,
loaders_from_representation,
filter_repre_contexts_by_loader,

any_outdated_containers,
get_outdated_containers,
Expand Down Expand Up @@ -85,6 +86,7 @@

"loaders_from_repre_context",
"loaders_from_representation",
"filter_repre_contexts_by_loader",

"any_outdated_containers",
"get_outdated_containers",
Expand Down
18 changes: 18 additions & 0 deletions openpype/pipeline/load/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,24 @@ def loaders_from_repre_context(loaders, repre_context):
]


def filter_repre_contexts_by_loader(repre_contexts, loader):
"""Filter representation contexts for loader.
Args:
repre_contexts (list[dict[str, Ant]]): Representation context.
loader (LoaderPlugin): Loader plugin to filter contexts for.
Returns:
list[dict[str, Any]]: Filtered representation contexts.
"""

return [
repre_context
for repre_context in repre_contexts
if is_compatible_loader(loader, repre_context)
]


def loaders_from_representation(loaders, representation):
"""Return all compatible loaders for a representation."""

Expand Down
10 changes: 7 additions & 3 deletions openpype/pipeline/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ def process(self, thumbnail_entity, thumbnail_type):

# This is new way how thumbnails can be received from server
# - output is 'ThumbnailContent' object
if hasattr(ayon_api, "get_thumbnail_by_id"):
result = ayon_api.get_thumbnail_by_id(thumbnail_id)
# NOTE Use 'get_server_api_connection' because public function
# 'get_thumbnail_by_id' does not return output of 'ServerAPI'
# method.
con = ayon_api.get_server_api_connection()
if hasattr(con, "get_thumbnail_by_id"):
result = con.get_thumbnail_by_id(thumbnail_id)
if result.is_valid:
filepath = cache.store_thumbnail(
project_name,
Expand All @@ -178,7 +182,7 @@ def process(self, thumbnail_entity, thumbnail_type):
else:
# Backwards compatibility for ayon api where 'get_thumbnail_by_id'
# is not implemented and output is filepath
filepath = ayon_api.get_thumbnail(
filepath = con.get_thumbnail(
project_name, entity_type, entity_id, thumbnail_id
)

Expand Down
6 changes: 6 additions & 0 deletions openpype/tools/ayon_loader/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .control import LoaderController


__all__ = (
"LoaderController",
)
Loading

0 comments on commit 0498a40

Please sign in to comment.