Example #1
0
    def __override_nukestudio_shortcuts(self, engine, nuke):
        """
		Override various shortcut keys in Nuke Studio to run our own commands
		instead

		:param engine: The current engine
		:param nuke: nuke module
		"""
        import hiero.ui as ns
        from PySide.QtGui import QKeySequence

        # remove default hotkey from File > Save Project...
        file_save_menu = ns.findMenuAction("Save New Comp Version")
        file_save_menu.setShortcut(QKeySequence(""))
        engine.log_debug(
            "remove default hot key for File > Save Project As...")

        # add new hot key for Shotgun > File Save...
        sg_file_save = ns.findMenuAction("File Save...")
        if sg_file_save:
            #sg_file_save.setShortcut(QKeySequence("Alt+Shift+S"))
            engine.log_debug(
                "set default hot key for File > Shotgun Save Project As...")

        # remove default hotkey from File > Open Project...
        file_open_menu = ns.findMenuAction("Open Project...")
        file_open_menu.setShortcut(QKeySequence(""))
        engine.log_debug("removed default hot key for File > Open Project...")

        # add new hot key for Shotgun > File Open...
        sg_file_open = ns.findMenuAction("File Open...")
        if sg_file_open:
            sg_file_open.setShortcut(QKeySequence('Ctrl+O'))
            engine.log_debug(
                "set default hot key for File > Shotgun Open Project...")
Example #2
0
def update_menu_task_label(*args):
    """Update the task label in Avalon menu to current session"""

    object_name = self._change_context_menu
    found_menu = findMenuAction(object_name)

    if not found_menu:
        log.warning("Can't find menuItem: {}".format(object_name))
        return

    label = "{}, {}".format(Session["AVALON_ASSET"], Session["AVALON_TASK"])

    menu = found_menu.menu()
    self._change_context_menu = label
    menu.setTitle(label)
# 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 <HIERO_PATH>/Startup directory.

from hiero.ui import findMenuAction
from PySide import QtGui

### ADD YOUR CUSTOM SHORTCUTS BELOW

# Examples of adding keyboard shortcuts for 'Show Metadata', and 'Open In Spreadsheet View' and the 'Expand Pane' action
# See also: http://www.pyside.org/docs/pyside/PySide/QtGui/QAction.html#PySide.QtGui.PySide.QtGui.QAction.setShortcut

myMenuItem = findMenuAction('Show Metadata')
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 Expand Pane (~) keyboard shortcut
for a in hiero.ui.registeredActions():
  if a.objectName() == "foundry.application.expandPane":
    a.setShortcut("Space")
    break

playButton = hiero.ui.findMenuAction('Play/Pause')
playButton.setShortcut("")
Example #4
0
        if tag.inTime() >= inTime and tag.outTime() <= outTime:
          activeSequence.removeTag(tag)

    hiero.ui.markersPanel.updateTableView()

  def eventHandler(self, event):
    """Add these actions to the Mark sub-menu"""
    for a in event.menu.actions():
      if a.text().lower().strip() == "mark":
        insertMenuAction( self._addMarkerAction, a.menu())
        insertMenuAction( self._clearAllMarkersAction, a.menu())
        insertMenuAction( self._clearMarkersInOutAction, a.menu())

markerActions = MarkerActions()
hiero.ui.clearAllTimelineMarkers = markerActions.clearAllMarkers
hiero.ui.clearMarkersInActiveRange = markerActions.clearMarkersInActiveRange

hiero.ui.markersPanel = MarkersPanel()
hiero.ui.markersPanel.__doc__ = "The Markers panel object. Call hiero.ui.markersPanel.updateTableView() to refresh the panel."
registerPanel( "uk.co.thefoundry.markers", hiero.ui.markersPanel )

wm = hiero.ui.windowManager()
wm.addWindow( hiero.ui.markersPanel )

# Add action to Timeline menu so it can be given a Global keyboard shortcut
timelineMenu = findMenuAction("foundry.menu.sequence")

if timelineMenu:
  insertMenuAction( markerActions._addMarkerAction, timelineMenu.menu(), after="foundry.timeline.markClip" )
  insertMenuAction( markerActions._clearAllMarkersAction, timelineMenu.menu(), after="foundry.timeline.addMarker" )
  insertMenuAction( markerActions._clearMarkersInOutAction, timelineMenu.menu(), after="foundry.timeline.clearAllMarkers" )
Example #5
0
def install():
    """
    Installing menu into Nukestudio

    """

    # here is the best place to add menu
    from avalon.tools import (
        creator,
        publish,
        cbloader,
        cbsceneinventory,
        contextmanager,
        libraryloader
    )

    menu_name = os.environ['AVALON_LABEL']

    context_label = "{0}, {1}".format(
        Session["AVALON_ASSET"], Session["AVALON_TASK"]
    )

    self._change_context_menu = context_label

    # Grab Hiero's MenuBar
    M = hiero.ui.menuBar()

    try:
        check_made_menu = findMenuAction(menu_name)
    except Exception:
        pass

    if not check_made_menu:
        menu = M.addMenu(menu_name)
    else:
        menu = check_made_menu.menu()

    actions = [
        {
            'parent': context_label,
            'action': QAction('Set Context', None),
            'function': contextmanager.show,
            'icon': QIcon('icons:Position.png')
        },
        "separator",
        {
            'action': QAction("Work Files...", None),
            'function': set_workfiles,
            'icon': QIcon('icons:Position.png')
        },
        {
            'action': QAction('Create Default Tags..', None),
            'function': add_tags_from_presets,
            'icon': QIcon('icons:Position.png')
        },
        "separator",
        # {
        #     'action': QAction('Create...', None),
        #     'function': creator.show,
        #     'icon': QIcon('icons:ColorAdd.png')
        # },
        # {
        #     'action': QAction('Load...', None),
        #     'function': cbloader.show,
        #     'icon': QIcon('icons:CopyRectangle.png')
        # },
        {
            'action': QAction('Publish...', None),
            'function': publish.show,
            'icon': QIcon('icons:Output.png')
        },
        # {
        #     'action': QAction('Manage...', None),
        #     'function': cbsceneinventory.show,
        #     'icon': QIcon('icons:ModifyMetaData.png')
        # },
        {
            'action': QAction('Library...', None),
            'function': libraryloader.show,
            'icon': QIcon('icons:ColorAdd.png')
        },
        "separator",
        {
            'action': QAction('Reload pipeline...', None),
            'function': reload_config,
            'icon': QIcon('icons:ColorAdd.png')
        }]

    # Create menu items
    for a in actions:
        add_to_menu = menu
        if isinstance(a, dict):
            # create action
            for k in a.keys():
                if 'parent' in k:
                    submenus = [sm for sm in a[k].split('/')]
                    submenu = None
                    for sm in submenus:
                        if submenu:
                            submenu.addMenu(sm)
                        else:
                            submenu = menu.addMenu(sm)
                    add_to_menu = submenu
                if 'action' in k:
                    action = a[k]
                elif 'function' in k:
                    action.triggered.connect(a[k])
                elif 'icon' in k:
                    action.setIcon(a[k])

            # add action to menu
            add_to_menu.addAction(action)
            hiero.ui.registerAction(action)
        elif isinstance(a, str):
            add_to_menu.addSeparator()
Example #6
0
def menu_install():
    """
    Installing menu into Hiero

    """
    from . import (publish, launch_workfiles_app, reload_config,
                   apply_colorspace_project, apply_colorspace_clips)
    # here is the best place to add menu
    from avalon.tools import cbloader, creator, sceneinventory
    from avalon.vendor.Qt import QtGui

    menu_name = os.environ['AVALON_LABEL']

    context_label = "{0}, {1}".format(Session["AVALON_ASSET"],
                                      Session["AVALON_TASK"])

    self._change_context_menu = context_label

    try:
        check_made_menu = findMenuAction(menu_name)
    except Exception:
        check_made_menu = None

    if not check_made_menu:
        # Grab Hiero's MenuBar
        menu = hiero.ui.menuBar().addMenu(menu_name)
    else:
        menu = check_made_menu.menu()

    context_label_action = menu.addAction(context_label)
    context_label_action.setEnabled(False)

    menu.addSeparator()

    workfiles_action = menu.addAction("Work Files...")
    workfiles_action.setIcon(QtGui.QIcon("icons:Position.png"))
    workfiles_action.triggered.connect(launch_workfiles_app)

    default_tags_action = menu.addAction("Create Default Tags...")
    default_tags_action.setIcon(QtGui.QIcon("icons:Position.png"))
    default_tags_action.triggered.connect(tags.add_tags_to_workfile)

    menu.addSeparator()

    publish_action = menu.addAction("Publish...")
    publish_action.setIcon(QtGui.QIcon("icons:Output.png"))
    publish_action.triggered.connect(
        lambda *args: publish(hiero.ui.mainWindow()))

    creator_action = menu.addAction("Create...")
    creator_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png"))
    creator_action.triggered.connect(creator.show)

    loader_action = menu.addAction("Load...")
    loader_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png"))
    loader_action.triggered.connect(cbloader.show)

    sceneinventory_action = menu.addAction("Manage...")
    sceneinventory_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png"))
    sceneinventory_action.triggered.connect(sceneinventory.show)
    menu.addSeparator()

    reload_action = menu.addAction("Reload pipeline...")
    reload_action.setIcon(QtGui.QIcon("icons:ColorAdd.png"))
    reload_action.triggered.connect(reload_config)

    menu.addSeparator()
    apply_colorspace_p_action = menu.addAction("Apply Colorspace Project...")
    apply_colorspace_p_action.setIcon(QtGui.QIcon("icons:ColorAdd.png"))
    apply_colorspace_p_action.triggered.connect(apply_colorspace_project)

    apply_colorspace_c_action = menu.addAction("Apply Colorspace Clips...")
    apply_colorspace_c_action.setIcon(QtGui.QIcon("icons:ColorAdd.png"))
    apply_colorspace_c_action.triggered.connect(apply_colorspace_clips)

    self.context_label_action = context_label_action
    self.workfile_actions = workfiles_action
    self.default_tags_action = default_tags_action
    self.publish_action = publish_action
    self.reload_action = reload_action
Example #7
0
      QAction.__init__(self, "Set Poster Frame", None)
      self.triggered.connect(self.setPosterFrameForActiveSequence)
      hiero.core.events.registerInterest("kShowContextMenu/kViewer", self.eventHandler)
      self.setObjectName("foundry.viewer.setPosterFrame")
      self.setShortcut("Shift+P")
      self.currentViewer = None

  def setPosterFrameForActiveSequence(self):
    if not self.currentViewer:
      self.currentViewer = currentViewer()

    currentTime = self.currentViewer.time()
    activeSequence = self.currentViewer.player().sequence()

    if activeSequence and currentTime:
      activeSequence.setPosterFrame(int(currentTime))

    self.currentViewer = None

  def eventHandler(self, event):
    enabled = event.sender.player().sequence() is not None
    for a in event.menu.actions():
      if a.text().lower().strip() == "mark":
        self.setEnabled(enabled)
        insertMenuAction( self, a.menu())

# Instantiate the action, add it to the Viewer menu and register it.
action = SetPosterFrameAction()
v = findMenuAction("foundry.menu.viewer")
insertMenuAction(action, v.menu(), after = 'foundry.viewer.clearInOut')
registerAction(action)
Example #8
0
File: menu.py Project: kalisp/pype
def install():
    """
    Installing menu into Nukestudio

    """

    # here is the best place to add menu
    from avalon.tools import publish, cbloader
    from avalon.vendor.Qt import QtGui

    menu_name = os.environ['AVALON_LABEL']

    context_label = "{0}, {1}".format(Session["AVALON_ASSET"],
                                      Session["AVALON_TASK"])

    self._change_context_menu = context_label

    try:
        check_made_menu = findMenuAction(menu_name)
    except Exception:
        check_made_menu = None

    if not check_made_menu:
        # Grab Hiero's MenuBar
        menu = hiero.ui.menuBar().addMenu(menu_name)
    else:
        menu = check_made_menu.menu()

    context_label_action = menu.addAction(context_label)
    context_label_action.setEnabled(False)

    menu.addSeparator()

    workfiles_action = menu.addAction("Work Files...")
    workfiles_action.setIcon(QtGui.QIcon("icons:Position.png"))
    workfiles_action.triggered.connect(set_workfiles)

    default_tags_action = menu.addAction("Create Default Tags...")
    default_tags_action.setIcon(QtGui.QIcon("icons:Position.png"))
    default_tags_action.triggered.connect(add_tags_from_presets)

    menu.addSeparator()

    publish_action = menu.addAction("Publish...")
    publish_action.setIcon(QtGui.QIcon("icons:Output.png"))
    publish_action.triggered.connect(
        lambda *args: publish.show(hiero.ui.mainWindow()))

    loader_action = menu.addAction("Load...")
    loader_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png"))
    loader_action.triggered.connect(cbloader.show)
    menu.addSeparator()

    reload_action = menu.addAction("Reload pipeline...")
    reload_action.setIcon(QtGui.QIcon("icons:ColorAdd.png"))
    reload_action.triggered.connect(reload_config)

    # Is this required?
    # hiero.ui.registerAction(context_label_action)
    # hiero.ui.registerAction(workfiles_action)
    # hiero.ui.registerAction(default_tags_action)
    # hiero.ui.registerAction(publish_action)
    # hiero.ui.registerAction(loader_action)
    # hiero.ui.registerAction(reload_action)

    self.context_label_action = context_label_action
    self.workfile_actions = workfiles_action
    self.default_tags_action = default_tags_action
    self.publish_action = publish_action
    self.reload_action = reload_action
Example #9
0
        for a in event.menu.actions():
            if a.text().lower().strip() == "mark":
                insertMenuAction(self._addMarkerAction, a.menu())
                insertMenuAction(self._clearAllMarkersAction, a.menu())
                insertMenuAction(self._clearMarkersInOutAction, a.menu())


markerActions = MarkerActions()
hiero.ui.clearAllTimelineMarkers = markerActions.clearAllMarkers
hiero.ui.clearMarkersInActiveRange = markerActions.clearMarkersInActiveRange

hiero.ui.markersPanel = MarkersPanel()
hiero.ui.markersPanel.__doc__ = "The Markers panel object. Call hiero.ui.markersPanel.updateTableView() to refresh the panel."
registerPanel("uk.co.thefoundry.markers", hiero.ui.markersPanel)

wm = hiero.ui.windowManager()
wm.addWindow(hiero.ui.markersPanel)

# Add action to Timeline menu so it can be given a Global keyboard shortcut
timelineMenu = findMenuAction("foundry.menu.sequence")

if timelineMenu:
    insertMenuAction(markerActions._addMarkerAction,
                     timelineMenu.menu(),
                     after="foundry.timeline.markClip")
    insertMenuAction(markerActions._clearAllMarkersAction,
                     timelineMenu.menu(),
                     after="foundry.timeline.addMarker")
    insertMenuAction(markerActions._clearMarkersInOutAction,
                     timelineMenu.menu(),
                     after="foundry.timeline.clearAllMarkers")
Example #10
0
        hiero.core.events.registerInterest("kShowContextMenu/kViewer",
                                           self.eventHandler)
        self.setObjectName("foundry.viewer.setPosterFrame")
        self.setShortcut("Shift+P")
        self.currentViewer = None

    def setPosterFrameForActiveSequence(self):
        if not self.currentViewer:
            self.currentViewer = currentViewer()

        currentTime = self.currentViewer.time()
        activeSequence = self.currentViewer.player().sequence()

        if activeSequence and currentTime:
            activeSequence.setPosterFrame(int(currentTime))

        self.currentViewer = None

    def eventHandler(self, event):
        enabled = event.sender.player().sequence() is not None
        for a in event.menu.actions():
            if a.text().lower().strip() == "mark":
                self.setEnabled(enabled)
                insertMenuAction(self, a.menu())


# Instantiate the action, add it to the Viewer menu and register it.
action = SetPosterFrameAction()
v = findMenuAction("foundry.menu.viewer")
insertMenuAction(action, v.menu(), after='foundry.viewer.clearInOut')
registerAction(action)