mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #14 from ynput/enhancement/shortcut_to_open_template
Add shortcut to open template for current context
This commit is contained in:
commit
21a10c53d7
6 changed files with 74 additions and 14 deletions
|
|
@ -9,7 +9,8 @@ import maya.cmds as cmds
|
|||
|
||||
from ayon_core.pipeline import (
|
||||
get_current_asset_name,
|
||||
get_current_task_name
|
||||
get_current_task_name,
|
||||
registered_host
|
||||
)
|
||||
from ayon_core.pipeline.workfile import BuildWorkfile
|
||||
from ayon_core.tools.utils import host_tools
|
||||
|
|
@ -21,8 +22,10 @@ from .workfile_template_builder import (
|
|||
create_placeholder,
|
||||
update_placeholder,
|
||||
build_workfile_template,
|
||||
update_workfile_template,
|
||||
update_workfile_template
|
||||
)
|
||||
from ayon_core.tools.workfile_template_build import open_template_ui
|
||||
from .workfile_template_builder import MayaTemplateBuilder
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -167,16 +170,6 @@ def install(project_settings):
|
|||
tearOff=True,
|
||||
parent=MENU_NAME
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Create Placeholder",
|
||||
parent=builder_menu,
|
||||
command=create_placeholder
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Update Placeholder",
|
||||
parent=builder_menu,
|
||||
command=update_placeholder
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Build Workfile from template",
|
||||
parent=builder_menu,
|
||||
|
|
@ -187,6 +180,27 @@ def install(project_settings):
|
|||
parent=builder_menu,
|
||||
command=update_workfile_template
|
||||
)
|
||||
cmds.menuItem(
|
||||
divider=True,
|
||||
parent=builder_menu
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Open Template",
|
||||
parent=builder_menu,
|
||||
command=lambda *args: open_template_ui(
|
||||
MayaTemplateBuilder(registered_host()), get_main_window()
|
||||
),
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Create Placeholder",
|
||||
parent=builder_menu,
|
||||
command=create_placeholder
|
||||
)
|
||||
cmds.menuItem(
|
||||
"Update Placeholder",
|
||||
parent=builder_menu,
|
||||
command=update_placeholder
|
||||
)
|
||||
|
||||
cmds.setParent(MENU_NAME, menu=True)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,12 @@ from ayon_core.pipeline import (
|
|||
AVALON_CONTAINER_ID,
|
||||
get_current_asset_name,
|
||||
get_current_task_name,
|
||||
registered_host,
|
||||
)
|
||||
from ayon_core.pipeline.workfile import BuildWorkfile
|
||||
from ayon_core.tools.utils import host_tools
|
||||
from ayon_core.hosts.nuke import NUKE_ROOT_DIR
|
||||
from ayon_core.tools.workfile_template_build import open_template_ui
|
||||
|
||||
from .command import viewer_update_and_undo_stop
|
||||
from .lib import (
|
||||
|
|
@ -55,6 +57,7 @@ from .workfile_template_builder import (
|
|||
build_workfile_template,
|
||||
create_placeholder,
|
||||
update_placeholder,
|
||||
NukeTemplateBuilder,
|
||||
)
|
||||
from .workio import (
|
||||
open_file,
|
||||
|
|
@ -313,7 +316,7 @@ def _install_menu():
|
|||
lambda: BuildWorkfile().process()
|
||||
)
|
||||
|
||||
menu_template = menu.addMenu("Template Builder") # creating template menu
|
||||
menu_template = menu.addMenu("Template Builder")
|
||||
menu_template.addCommand(
|
||||
"Build Workfile from template",
|
||||
lambda: build_workfile_template()
|
||||
|
|
@ -321,6 +324,12 @@ def _install_menu():
|
|||
|
||||
if not ASSIST:
|
||||
menu_template.addSeparator()
|
||||
menu_template.addCommand(
|
||||
"Open template",
|
||||
lambda: open_template_ui(
|
||||
NukeTemplateBuilder(registered_host()), get_main_window()
|
||||
)
|
||||
)
|
||||
menu_template.addCommand(
|
||||
"Create Place Holder",
|
||||
lambda: create_placeholder()
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from ayon_core.pipeline.workfile.workfile_template_builder import (
|
|||
LoadPlaceholderItem,
|
||||
CreatePlaceholderItem,
|
||||
PlaceholderLoadMixin,
|
||||
PlaceholderCreateMixin
|
||||
PlaceholderCreateMixin,
|
||||
)
|
||||
from ayon_core.tools.workfile_template_build import (
|
||||
WorkfileBuildPlaceholderDialog,
|
||||
|
|
|
|||
|
|
@ -553,6 +553,12 @@ class AbstractTemplateBuilder(object):
|
|||
|
||||
self.clear_shared_populate_data()
|
||||
|
||||
def open_template(self):
|
||||
"""Open template file with registered host."""
|
||||
template_preset = self.get_template_preset()
|
||||
template_path = template_preset["path"]
|
||||
self.host.open_file(template_path)
|
||||
|
||||
@abstractmethod
|
||||
def import_template(self, template_path):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
from .window import WorkfileBuildPlaceholderDialog
|
||||
from .lib import open_template_ui
|
||||
|
||||
__all__ = (
|
||||
"WorkfileBuildPlaceholderDialog",
|
||||
|
||||
"open_template_ui"
|
||||
)
|
||||
|
|
|
|||
28
client/ayon_core/tools/workfile_template_build/lib.py
Normal file
28
client/ayon_core/tools/workfile_template_build/lib.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import traceback
|
||||
|
||||
from qtpy import QtWidgets
|
||||
|
||||
from ayon_core.tools.utils.dialogs import show_message_dialog
|
||||
|
||||
|
||||
def open_template_ui(builder, main_window):
|
||||
"""Open template from `builder`
|
||||
|
||||
Asks user about overwriting current scene and feedsback exceptions.
|
||||
"""
|
||||
result = QtWidgets.QMessageBox.question(
|
||||
main_window,
|
||||
"Opening template",
|
||||
"Caution! You will loose unsaved changes.\nDo you want to continue?",
|
||||
QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No
|
||||
)
|
||||
if result == QtWidgets.QMessageBox.Yes:
|
||||
try:
|
||||
builder.open_template()
|
||||
except Exception:
|
||||
show_message_dialog(
|
||||
title="Template Load Failed",
|
||||
message="".join(traceback.format_exc()),
|
||||
parent=main_window,
|
||||
level="critical"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue