-
Notifications
You must be signed in to change notification settings - Fork 33
Add context reset prompt on taskChange #266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 8 commits
a6e74c6
07d9cb2
21e8e48
7878cb6
74fe662
04647a5
cffcfa6
0729b22
4bf94b3
706608e
a27a4e6
276dbee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
|
|
||
| from ayon_core.host import ( | ||
| ApplicationInformation, | ||
| ContextChangeData, | ||
| HostBase, | ||
| IWorkfileHost, | ||
| ILoadHost, | ||
|
|
@@ -55,6 +56,7 @@ | |
| set_avalon_knob_data, | ||
| read_avalon_data, | ||
| on_script_load, | ||
| prompt_reset_context, | ||
| dirmap_file_name_filter, | ||
| add_scripts_menu, | ||
| add_scripts_gizmo, | ||
|
|
@@ -92,6 +94,9 @@ | |
| if os.getenv("PYBLISH_GUI", None): | ||
| pyblish.api.register_gui(os.getenv("PYBLISH_GUI", None)) | ||
|
|
||
| # Track whether the workfile tool is about to save | ||
| _about_to_save = False | ||
|
|
||
|
|
||
| class NukeHost( | ||
| HostBase, IWorkfileHost, ILoadHost, IPublishHost | ||
|
|
@@ -138,8 +143,9 @@ def install(self): | |
| register_workfile_build_plugin_path(WORKFILE_BUILD_PATH) | ||
|
|
||
| # Register AYON event for workfiles loading. | ||
| register_event_callback("workfile.save.before", before_workfile_save) | ||
| register_event_callback("workfile.save.after", after_workfile_save) | ||
| register_event_callback("workio.open_file", check_inventory_versions) | ||
| register_event_callback("taskChanged", change_context_label) | ||
|
|
||
| def setup_ui_callbacks_and_menu(self): | ||
| """Setup AYON menus.""" | ||
|
|
@@ -162,6 +168,25 @@ def update_context_data(self, data, changes): | |
| root_node = nuke.root() | ||
| set_node_data(root_node, ROOT_DATA_KNOB, data) | ||
|
|
||
| def _after_context_change(self, context_change_data: ContextChangeData): | ||
| """After context is changed. | ||
|
|
||
| This method is called after the context is changed. | ||
|
|
||
| Args: | ||
| context_change_data (ContextChangeData): Object with information | ||
| about context change. | ||
|
|
||
| """ | ||
| if not nuke.GUI: | ||
| return | ||
|
|
||
| change_context_label() | ||
|
|
||
| if _about_to_save: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also pointing out that there is also
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sebastianbrandhuber I assume this is a change still to do?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, will implement this next week when back at work 👍 |
||
| # Let's prompt the user to update the context settings or not | ||
| prompt_reset_context() | ||
|
|
||
|
|
||
| def add_nuke_callbacks(project_settings: dict = None): | ||
| """Adding all available nuke callbacks""" | ||
|
|
@@ -405,6 +430,16 @@ def change_context_label(): | |
| old_label, new_label)) | ||
|
|
||
|
|
||
| def after_workfile_save(): | ||
| global _about_to_save | ||
| _about_to_save = False | ||
|
|
||
|
|
||
| def before_workfile_save(event): | ||
| global _about_to_save | ||
| _about_to_save = True | ||
|
|
||
|
|
||
| def add_shortcuts_from_presets(project_settings: dict): | ||
| menubar = nuke.menu("Nuke") | ||
| nuke_presets = project_settings["nuke"]["general"] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.