mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Nuke: fixing menu shortcuts to be specifically OpenPype
This commit is contained in:
parent
fe9729dd18
commit
59ef7c7d05
3 changed files with 27 additions and 23 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import nuke
|
import nuke
|
||||||
from avalon.api import Session
|
from avalon.api import Session
|
||||||
|
|
||||||
|
|
@ -7,10 +8,11 @@ from pype.tools import workfiles
|
||||||
|
|
||||||
log = Logger().get_logger(__name__)
|
log = Logger().get_logger(__name__)
|
||||||
|
|
||||||
|
menu_label = os.environ["AVALON_LABEL"]
|
||||||
|
|
||||||
def install():
|
def install():
|
||||||
menubar = nuke.menu("Nuke")
|
menubar = nuke.menu("Nuke")
|
||||||
menu = menubar.findItem(Session["AVALON_LABEL"])
|
menu = menubar.findItem(menu_label)
|
||||||
|
|
||||||
# replace reset resolution from avalon core to pype's
|
# replace reset resolution from avalon core to pype's
|
||||||
name = "Work Files..."
|
name = "Work Files..."
|
||||||
|
|
@ -90,7 +92,7 @@ def install():
|
||||||
def uninstall():
|
def uninstall():
|
||||||
|
|
||||||
menubar = nuke.menu("Nuke")
|
menubar = nuke.menu("Nuke")
|
||||||
menu = menubar.findItem(Session["AVALON_LABEL"])
|
menu = menubar.findItem(menu_label)
|
||||||
|
|
||||||
for item in menu.items():
|
for item in menu.items():
|
||||||
log.info("Removing menu item: {}".format(item.name()))
|
log.info("Removing menu item: {}".format(item.name()))
|
||||||
|
|
@ -99,7 +101,7 @@ def uninstall():
|
||||||
|
|
||||||
def add_shortcuts_from_presets():
|
def add_shortcuts_from_presets():
|
||||||
menubar = nuke.menu("Nuke")
|
menubar = nuke.menu("Nuke")
|
||||||
nuke_presets = get_current_project_settings()["nuke"]
|
nuke_presets = get_current_project_settings()["nuke"]["general"]
|
||||||
|
|
||||||
if nuke_presets.get("menu"):
|
if nuke_presets.get("menu"):
|
||||||
menu_label_mapping = {
|
menu_label_mapping = {
|
||||||
|
|
@ -109,15 +111,18 @@ def add_shortcuts_from_presets():
|
||||||
"build_workfile": "Build Workfile",
|
"build_workfile": "Build Workfile",
|
||||||
"publish": "Publish..."
|
"publish": "Publish..."
|
||||||
}
|
}
|
||||||
for menu_name, menuitems in nuke_presets.get("menu").items():
|
|
||||||
menu = menubar.findItem(menu_name)
|
for command_name, shortcut_str in nuke_presets.get("menu").items():
|
||||||
for mitem_name, shortcut in menuitems.items():
|
log.info("menu_name `{}` | menu_label `{}`".format(
|
||||||
log.info("Adding Shortcut `{}` to `{}`".format(
|
command_name, menu_label
|
||||||
shortcut, mitem_name
|
))
|
||||||
))
|
log.info("Adding Shortcut `{}` to `{}`".format(
|
||||||
try:
|
shortcut_str, command_name
|
||||||
item_label = menu_label_mapping[mitem_name]
|
))
|
||||||
menuitem = menu.findItem(item_label)
|
try:
|
||||||
menuitem.setShortcut(shortcut)
|
menu = menubar.findItem(menu_label)
|
||||||
except AttributeError as e:
|
item_label = menu_label_mapping[command_name]
|
||||||
log.error(e)
|
menuitem = menu.findItem(item_label)
|
||||||
|
menuitem.setShortcut(shortcut_str)
|
||||||
|
except AttributeError as e:
|
||||||
|
log.error(e)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"menu": {
|
"general": {
|
||||||
"Pype": {
|
"menu": {
|
||||||
"create": "ctrl+shift+alt+c",
|
"create": "ctrl+shift+alt+c",
|
||||||
"publish": "ctrl+alt+p",
|
"publish": "ctrl+alt+p",
|
||||||
"load": "ctrl+alt+l",
|
"load": "ctrl+alt+l",
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,14 @@
|
||||||
{
|
{
|
||||||
"type": "dict",
|
"type": "dict",
|
||||||
"collapsible": true,
|
"collapsible": true,
|
||||||
"key": "menu",
|
"key": "general",
|
||||||
"label": "Menu shortcuts",
|
"label": "General",
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"type": "dict",
|
"type": "dict",
|
||||||
"collapsible": false,
|
"collapsible": true,
|
||||||
"key": "Pype",
|
"key": "menu",
|
||||||
"label": "Pype",
|
"label": "OpenPype Menu shortcuts",
|
||||||
"is_group": true,
|
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue