mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
feat(nuke): menu shortcut from settings
This commit is contained in:
parent
05f4b77d6b
commit
b9dd3edbbd
3 changed files with 73 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ import nuke
|
|||
from avalon.api import Session
|
||||
|
||||
from .lib import WorkfileSettings
|
||||
from pype.api import Logger, BuildWorkfile
|
||||
from pype.api import Logger, BuildWorkfile, get_current_project_settings
|
||||
|
||||
log = Logger().get_logger(__name__)
|
||||
|
||||
|
|
@ -66,6 +66,9 @@ def install():
|
|||
)
|
||||
log.debug("Adding menu item: {}".format(name))
|
||||
|
||||
# adding shortcuts
|
||||
add_shortcuts_from_presets()
|
||||
|
||||
|
||||
def uninstall():
|
||||
|
||||
|
|
@ -75,3 +78,21 @@ def uninstall():
|
|||
for item in menu.items():
|
||||
log.info("Removing menu item: {}".format(item.name()))
|
||||
menu.removeItem(item.name())
|
||||
|
||||
|
||||
def add_shortcuts_from_presets():
|
||||
menubar = nuke.menu("Nuke")
|
||||
nuke_presets = get_current_project_settings()["nuke"]
|
||||
|
||||
if nuke_presets.get("menu"):
|
||||
for menu_name, menuitems in nuke_presets.get("menu").items():
|
||||
menu = menubar.findItem(menu_name)
|
||||
for mitem_name, shortcut in menuitems.items():
|
||||
log.info("Adding Shortcut `{}` to `{}`".format(
|
||||
shortcut, mitem_name
|
||||
))
|
||||
try:
|
||||
menuitem = menu.findItem(mitem_name)
|
||||
menuitem.setShortcut(shortcut)
|
||||
except AttributeError as e:
|
||||
log.error(e)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
{
|
||||
"menu": {
|
||||
"Pype": {
|
||||
"Create...": "ctrl+shift+alt+c",
|
||||
"Publish...": "ctrl+alt+p",
|
||||
"Load...": "ctrl+alt+l",
|
||||
"Manage...": "ctrl+alt+m",
|
||||
"Build Workfile": "ctrl+alt+b"
|
||||
}
|
||||
},
|
||||
"create": {
|
||||
"CreateWriteRender": {
|
||||
"fpath_template": "{work}/renders/nuke/{subset}/{subset}.{frame}.{ext}"
|
||||
|
|
|
|||
|
|
@ -5,6 +5,48 @@
|
|||
"label": "Nuke",
|
||||
"is_file": true,
|
||||
"children": [
|
||||
{
|
||||
"type": "dict",
|
||||
"collapsible": true,
|
||||
"key": "menu",
|
||||
"label": "Menu shortcuts",
|
||||
"children": [
|
||||
{
|
||||
"type": "dict",
|
||||
"collapsible": false,
|
||||
"key": "Pype",
|
||||
"label": "Pype",
|
||||
"is_group": true,
|
||||
"children": [
|
||||
{
|
||||
"type": "text",
|
||||
"key": "Create...",
|
||||
"label": "Create..."
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "Publish...",
|
||||
"label": "Publish..."
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "Load...",
|
||||
"label": "Load..."
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "Manage...",
|
||||
"label": "Manage..."
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "Build Workfile",
|
||||
"label": "Build Workfile"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "dict",
|
||||
"collapsible": true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue