mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
* added helper classes to utils * implemented base of ayon utils * initial commit for launcher tool * use image for extender * actions are shown and can be triggered * fix actions on finished refresh * refresh automatically * fix re-refreshing of projects model * added page slide animation * updated abstrack classes * change how icon is prepared * fix actions sorting * show messages like in launcher tool * do not clear items on refresh * stop refresh timer only on close event * use Ynput/AYON for local settings json * register default actions in launcher action module * change register naming * move 'SquareButton' to utils widgets * removed duplicated method * removed unused variable * removed unused import * don't use lambda * swap default name for 'OpenPypeSettingsRegistry' * Change support version
141 lines
3.6 KiB
Python
141 lines
3.6 KiB
Python
import logging
|
|
from openpype.pipeline.plugin_discover import (
|
|
discover,
|
|
register_plugin,
|
|
register_plugin_path,
|
|
deregister_plugin,
|
|
deregister_plugin_path
|
|
)
|
|
|
|
|
|
class LauncherAction(object):
|
|
"""A custom action available"""
|
|
name = None
|
|
label = None
|
|
icon = None
|
|
color = None
|
|
order = 0
|
|
|
|
log = logging.getLogger("LauncherAction")
|
|
log.propagate = True
|
|
|
|
def is_compatible(self, session):
|
|
"""Return whether the class is compatible with the Session.
|
|
|
|
Args:
|
|
session (dict[str, Union[str, None]]): Session data with
|
|
AVALON_PROJECT, AVALON_ASSET and AVALON_TASK.
|
|
"""
|
|
|
|
return True
|
|
|
|
def process(self, session, **kwargs):
|
|
pass
|
|
|
|
|
|
class InventoryAction(object):
|
|
"""A custom action for the scene inventory tool
|
|
|
|
If registered the action will be visible in the Right Mouse Button menu
|
|
under the submenu "Actions".
|
|
|
|
"""
|
|
|
|
label = None
|
|
icon = None
|
|
color = None
|
|
order = 0
|
|
|
|
log = logging.getLogger("InventoryAction")
|
|
log.propagate = True
|
|
|
|
@staticmethod
|
|
def is_compatible(container):
|
|
"""Override function in a custom class
|
|
|
|
This method is specifically used to ensure the action can operate on
|
|
the container.
|
|
|
|
Args:
|
|
container(dict): the data of a loaded asset, see host.ls()
|
|
|
|
Returns:
|
|
bool
|
|
"""
|
|
return bool(container.get("objectName"))
|
|
|
|
def process(self, containers):
|
|
"""Override function in a custom class
|
|
|
|
This method will receive all containers even those which are
|
|
incompatible. It is advised to create a small filter along the lines
|
|
of this example:
|
|
|
|
valid_containers = filter(self.is_compatible(c) for c in containers)
|
|
|
|
The return value will need to be a True-ish value to trigger
|
|
the data_changed signal in order to refresh the view.
|
|
|
|
You can return a list of container names to trigger GUI to select
|
|
treeview items.
|
|
|
|
You can return a dict to carry extra GUI options. For example:
|
|
{
|
|
"objectNames": [container names...],
|
|
"options": {"mode": "toggle",
|
|
"clear": False}
|
|
}
|
|
Currently workable GUI options are:
|
|
- clear (bool): Clear current selection before selecting by action.
|
|
Default `True`.
|
|
- mode (str): selection mode, use one of these:
|
|
"select", "deselect", "toggle". Default is "select".
|
|
|
|
Args:
|
|
containers (list): list of dictionaries
|
|
|
|
Return:
|
|
bool, list or dict
|
|
|
|
"""
|
|
return True
|
|
|
|
|
|
# Launcher action
|
|
def discover_launcher_actions():
|
|
return discover(LauncherAction)
|
|
|
|
|
|
def register_launcher_action(plugin):
|
|
return register_plugin(LauncherAction, plugin)
|
|
|
|
|
|
def register_launcher_action_path(path):
|
|
return register_plugin_path(LauncherAction, path)
|
|
|
|
|
|
# Inventory action
|
|
def discover_inventory_actions():
|
|
actions = discover(InventoryAction)
|
|
filtered_actions = []
|
|
for action in actions:
|
|
if action is not InventoryAction:
|
|
filtered_actions.append(action)
|
|
|
|
return filtered_actions
|
|
|
|
|
|
def register_inventory_action(plugin):
|
|
return register_plugin(InventoryAction, plugin)
|
|
|
|
|
|
def deregister_inventory_action(plugin):
|
|
deregister_plugin(InventoryAction, plugin)
|
|
|
|
|
|
def register_inventory_action_path(path):
|
|
return register_plugin_path(InventoryAction, path)
|
|
|
|
|
|
def deregister_inventory_action_path(path):
|
|
return deregister_plugin_path(InventoryAction, path)
|