mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Add global menu from settings
This commit is contained in:
parent
7b16c6837b
commit
b77cb4ba1a
4 changed files with 106 additions and 93 deletions
|
|
@ -38,38 +38,42 @@ class GizmoMenu():
|
|||
return parent
|
||||
|
||||
def build_from_configuration(self, configuration):
|
||||
for item in configuration:
|
||||
assert isinstance(item, dict), "Configuration is wrong!"
|
||||
|
||||
for menu in configuration:
|
||||
# Construct parent path else parent is toolbar
|
||||
parent = self.toolbar
|
||||
gizmo_toolbar_path = item.get("gizmo_toolbar_path")
|
||||
gizmo_toolbar_path = menu.get("gizmo_toolbar_path")
|
||||
if gizmo_toolbar_path:
|
||||
parent = self._make_menu_path(gizmo_toolbar_path)
|
||||
|
||||
item_type = item.get("sourcetype")
|
||||
for item in menu["sub_gizmo_list"]:
|
||||
assert isinstance(item, dict), "Configuration is wrong!"
|
||||
|
||||
if item_type == ("python" or "file"):
|
||||
parent.addCommand(
|
||||
item['title'],
|
||||
command=str(item["command"]),
|
||||
icon=item.get("icon"),
|
||||
shortcut=item.get('hotkey')
|
||||
)
|
||||
if not item.get("title"):
|
||||
continue
|
||||
|
||||
# add separator
|
||||
# Special behavior for separators
|
||||
elif item_type == "separator":
|
||||
parent.addSeparator()
|
||||
item_type = item.get("sourcetype")
|
||||
|
||||
# add submenu
|
||||
# items should hold a collection of submenu items (dict)
|
||||
elif item_type == "menu":
|
||||
# assert "items" in item, "Menu is missing 'items' key"
|
||||
parent.addMenu(
|
||||
item['title'],
|
||||
icon=item.get('icon')
|
||||
)
|
||||
if item_type == ("python" or "file"):
|
||||
parent.addCommand(
|
||||
item["title"],
|
||||
command=str(item["command"]),
|
||||
icon=item.get("icon"),
|
||||
shortcut=item.get("hotkey")
|
||||
)
|
||||
|
||||
# add separator
|
||||
# Special behavior for separators
|
||||
elif item_type == "separator":
|
||||
parent.addSeparator()
|
||||
|
||||
# add submenu
|
||||
# items should hold a collection of submenu items (dict)
|
||||
elif item_type == "menu":
|
||||
# assert "items" in item, "Menu is missing 'items' key"
|
||||
parent.addMenu(
|
||||
item['title'],
|
||||
icon=item.get('icon')
|
||||
)
|
||||
|
||||
def add_gizmo_path(self, gizmo_paths):
|
||||
for gizmo_path in gizmo_paths:
|
||||
|
|
|
|||
|
|
@ -2516,7 +2516,6 @@ def add_scripts_gizmo():
|
|||
|
||||
for gizmo_settings in project_settings["nuke"]["gizmo"]:
|
||||
gizmo_list_definition = gizmo_settings["gizmo_definition"]
|
||||
print(1, gizmo_list_definition)
|
||||
toolbar_name = gizmo_settings["toolbar_menu_name"]
|
||||
# gizmo_toolbar_path = gizmo_settings["gizmo_toolbar_path"]
|
||||
gizmo_source_dir = gizmo_settings.get(
|
||||
|
|
|
|||
|
|
@ -301,10 +301,15 @@
|
|||
"toolbar_icon_path": {},
|
||||
"gizmo_definition": [
|
||||
{
|
||||
"type": "action",
|
||||
"sourcetype": "python",
|
||||
"title": "Gizmo Note",
|
||||
"command": "nuke.nodes.StickyNote(label='You can create your own toolbar menu in the Nuke GizmoMenu of OpenPype')"
|
||||
"gizmo_toolbar_path": "/path/to/menu",
|
||||
"sub_gizmo_list": [
|
||||
{
|
||||
"sourcetype": "python",
|
||||
"title": "Gizmo Note",
|
||||
"command": "nuke.nodes.StickyNote(label='You can create your own toolbar menu in the Nuke GizmoMenu of OpenPype')",
|
||||
"shortcut": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,73 +41,78 @@
|
|||
"label": "Gizmo definitions",
|
||||
"use_label_wrap": true,
|
||||
"object_type": {
|
||||
"type": "dict-conditional",
|
||||
"enum_key": "sourcetype",
|
||||
"enum_label": "Type of usage",
|
||||
"enum_children": [
|
||||
"type": "dict",
|
||||
"children": [
|
||||
{
|
||||
"key": "python",
|
||||
"label": "Python",
|
||||
"children": [
|
||||
{
|
||||
"type": "text",
|
||||
"key": "title",
|
||||
"label": "Title"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "gizmo_toolbar_path",
|
||||
"label": "Toolbar path"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "command",
|
||||
"label": "Python command"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "shortcut",
|
||||
"label": "Hotkey"
|
||||
}
|
||||
]
|
||||
"type": "text",
|
||||
"key": "gizmo_toolbar_path",
|
||||
"label": "Gizmo Menu Path"
|
||||
},
|
||||
{
|
||||
"key": "file",
|
||||
"label": "File",
|
||||
"children": [
|
||||
{
|
||||
"type": "text",
|
||||
"key": "title",
|
||||
"label": "Title"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "gizmo_toolbar_path",
|
||||
"label": "Toolbar path"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "file_name",
|
||||
"label": "Gizmo file name"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "shortcut",
|
||||
"label": "Hotkey"
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "separator",
|
||||
"label": "Separator",
|
||||
"children": [
|
||||
{
|
||||
"type": "text",
|
||||
"key": "gizmo_toolbar_path",
|
||||
"label": "Toolbar path"
|
||||
}
|
||||
]
|
||||
"type": "list",
|
||||
"key": "sub_gizmo_list",
|
||||
"label": "Sub Gizmo List",
|
||||
"use_label_wrap": true,
|
||||
"object_type": {
|
||||
"type": "dict-conditional",
|
||||
"enum_key": "sourcetype",
|
||||
"enum_label": "Type of usage",
|
||||
"enum_children": [
|
||||
{
|
||||
"key": "python",
|
||||
"label": "Python",
|
||||
"children": [
|
||||
{
|
||||
"type": "text",
|
||||
"key": "title",
|
||||
"label": "Title"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "command",
|
||||
"label": "Python command"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "shortcut",
|
||||
"label": "Hotkey"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "file",
|
||||
"label": "File",
|
||||
"children": [
|
||||
{
|
||||
"type": "text",
|
||||
"key": "title",
|
||||
"label": "Title"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "file_name",
|
||||
"label": "Gizmo file name"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "shortcut",
|
||||
"label": "Hotkey"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"key": "separator",
|
||||
"label": "Separator",
|
||||
"children": [
|
||||
{
|
||||
"type": "text",
|
||||
"key": "gizmo_toolbar_path",
|
||||
"label": "Toolbar path"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue