Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Flame: OpenPype submenu to batch and media manager #3825

Merged
merged 3 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openpype/hosts/flame/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
)
from .menu import (
FlameMenuProjectConnect,
FlameMenuTimeline
FlameMenuTimeline,
FlameMenuUniversal
)
from .plugin import (
Creator,
Expand Down Expand Up @@ -131,6 +132,7 @@
# menu
"FlameMenuProjectConnect",
"FlameMenuTimeline",
"FlameMenuUniversal",

# plugin
"Creator",
Expand Down
50 changes: 50 additions & 0 deletions openpype/hosts/flame/api/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,53 @@ def rescan(self, *args, **kwargs):
if self.flame:
self.flame.execute_shortcut('Rescan Python Hooks')
self.log.info('Rescan Python Hooks')


class FlameMenuUniversal(_FlameMenuApp):

# flameMenuProjectconnect app takes care of the preferences dialog as well

def __init__(self, framework):
_FlameMenuApp.__init__(self, framework)

def __getattr__(self, name):
def method(*args, **kwargs):
project = self.dynamic_menu_data.get(name)
if project:
self.link_project(project)
return method

def build_menu(self):
if not self.flame:
return []

menu = deepcopy(self.menu)

menu['actions'].append({
"name": "Load...",
"execute": lambda x: self.tools_helper.show_loader()
})
menu['actions'].append({
"name": "Manage...",
"execute": lambda x: self.tools_helper.show_scene_inventory()
})
menu['actions'].append({
"name": "Library...",
"execute": lambda x: self.tools_helper.show_library_loader()
})
return menu

def refresh(self, *args, **kwargs):
self.rescan()

def rescan(self, *args, **kwargs):
if not self.flame:
try:
import flame
self.flame = flame
except ImportError:
self.flame = None

if self.flame:
self.flame.execute_shortcut('Rescan Python Hooks')
self.log.info('Rescan Python Hooks')
26 changes: 26 additions & 0 deletions openpype/hosts/flame/startup/openpype_in_flame.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def load_apps():
opfapi.FlameMenuProjectConnect(opfapi.CTX.app_framework))
opfapi.CTX.flame_apps.append(
opfapi.FlameMenuTimeline(opfapi.CTX.app_framework))
opfapi.CTX.flame_apps.append(
opfapi.FlameMenuUniversal(opfapi.CTX.app_framework))
opfapi.CTX.app_framework.log.info("Apps are loaded")


Expand Down Expand Up @@ -191,3 +193,27 @@ def get_timeline_custom_ui_actions():
openpype_install()

return _build_app_menu("FlameMenuTimeline")


def get_batch_custom_ui_actions():
"""Hook to create submenu in batch

Returns:
list: menu object
"""
# install openpype and the host
openpype_install()

return _build_app_menu("FlameMenuUniversal")


def get_media_panel_custom_ui_actions():
"""Hook to create submenu in desktop

Returns:
list: menu object
"""
# install openpype and the host
openpype_install()

return _build_app_menu("FlameMenuUniversal")