ynput / ayon-core

Apache License 2.0
18 stars 29 forks source link

Loader: Fix support for product_type_filter_profiles #680

Open BigRoy opened 1 week ago

BigRoy commented 1 week ago

Is there an existing issue for this?

Current Behavior:

The ayon core addon has settings for ayon+settings://core/tools/loader/product_type_filter_profiles which allows to define the default "filter" state for product types when showing the Loader.

It seems however since some recent changes in the UIs and refactoring this does nothing anymore. It seems the product_type_filter_profiles setting is currently completely unused.

Expected Behavior:

Fix the feature again so we provide default "filters" set for the loader based on hosts, etc. (So actually use ayon+settings://core/tools/loader/product_type_filter_profiles)

Version

1.0.0

What platform you are running on?

Windows

Steps To Reproduce:

  1. Configure setting ayon+settings://core/tools/loader/product_type_filter_profiles, for example:
    [
    {
    "hosts": [
      "maya"
    ],
    "task_types": [],
    "is_include": true,
    "filter_product_types": [
      "animation",
      "camera",
      "layout",
      "look",
      "model",
      "plate",
      "pointcache",
      "reference",
      "rig",
      "usd",
      "vdbcache",
      "yetiRig",
      "yeticache"
    ]
    },
    {
    "hosts": [
      "houdini"
    ],
    "task_types": [],
    "is_include": true,
    "filter_product_types": [
      "animation",
      "camera",
      "model",
      "plate",
      "pointcache",
      "usd",
      "vdbcache"
    ]
    },
    {
    "hosts": [
      "fusion"
    ],
    "task_types": [],
    "is_include": true,
    "filter_product_types": [
      "camera",
      "image",
      "matchmove",
      "plate",
      "prerender",
      "render"
    ]
    },
    {
    "hosts": [
      "resolve"
    ],
    "task_types": [],
    "is_include": true,
    "filter_product_types": [
      "editorial",
      "image",
      "matchmove",
      "plate",
      "prerender",
      "render",
      "review"
    ]
    }
    ]
  2. When showing the loader in the specific profiles the default "product type" filters on the bottom should be enabled as per the matching profile.

Are there any labels you wish to add?

Relevant log output:

No response

Additional context:

Any pointers on how or where to implement this with all the controller/UI separation logic involved currently @iLLiCiTiT and I can take a look (hopefully understanding what you mean, hehe)

iLLiCiTiT commented 3 days ago

Controller should have method (long name) get_current_context_product_types_filter without any args. It should return object with 2 attributes product_types and is_include (maybe rather is_whitelist?).

class ProductTypesFilter:
    def __init__(self, product_types, is_whitelist):
        self.product_types: List[str] = product_types
        self.is_whitelist: bool = is_whitelist

If current context is not available, for any reason e.g. in tray browser, then it should return object with empty product types and is whitelist to False so all product types are checked.

With that available ProductTypesView should get the value in _on_refresh_finished and set the filter on the proxy.

NOW: question is if we want to also reset the filtering on every reset, so anything user checked/unchecked is lost, or it will happen only once after show (also reset but user closed the window meanwhile).

If it should happen only after show then ProductTypesView also have to define an attribute where stores boolean if should override or not, that will set it's value to True in overriden showEvent method which would mean that on next refresh will apply settings to proxy and change the attribute to False so until user cloes window it does not "change" it.