# This example shows how you can add custom keyboard shortcuts to Hiero.
# If you wish for this code to be run on startup, copy it to your ~/.nuke/Python/Startup directory.

from hiero.ui import findMenuAction, registeredActions
from PySide6 import QtGui

# ADD YOUR CUSTOM SHORTCUTS BELOW

# Examples of adding keyboard shortcuts for 'Metadata View', the 'Spreadsheet View' and the 'Focus Next Tab' action.
# See also:
# https://doc.qt.io/qtforpython-6.5/PySide6/QtGui/QAction.html#PySide6.QtGui.PySide6.QtGui.QAction.setShortcut

myMenuItem = findMenuAction('Metadata View')
myMenuItem.setShortcut(QtGui.QKeySequence('Alt+M'))

# This sets a keyboard shortcut for opening the Spreadsheet View
myMenuItem = findMenuAction('foundry.project.openInSpreadsheet')
myMenuItem.setShortcut(QtGui.QKeySequence('S'))

# This allows you to override the Focus Next Tab (Ctrl+Shift+]) keyboard shortcut
for a in registeredActions():
  if a.objectName() == 'foundry.application.focusNextTab':
    a.setShortcut("Ctrl+Space")
    break

playButton = findMenuAction('Play/Pause')
playButton.setShortcut("")
