mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
context title taken from host implementation
This commit is contained in:
parent
51370baa09
commit
0ec8ab8f6e
4 changed files with 50 additions and 6 deletions
|
|
@ -10,7 +10,8 @@ from .pipeline import (
|
||||||
update_instances,
|
update_instances,
|
||||||
remove_instances,
|
remove_instances,
|
||||||
get_context_data,
|
get_context_data,
|
||||||
update_context_data
|
update_context_data,
|
||||||
|
get_context_title
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -36,6 +37,7 @@ __all__ = (
|
||||||
"remove_instances",
|
"remove_instances",
|
||||||
"get_context_data",
|
"get_context_data",
|
||||||
"update_context_data",
|
"update_context_data",
|
||||||
|
"get_context_title",
|
||||||
|
|
||||||
"install"
|
"install"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,33 @@ class HostContext:
|
||||||
instances_json_path = None
|
instances_json_path = None
|
||||||
context_json_path = None
|
context_json_path = None
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_context_title(cls):
|
||||||
|
project_name = os.environ.get("AVALON_PROJECT")
|
||||||
|
if not project_name:
|
||||||
|
return "TestHost"
|
||||||
|
|
||||||
|
asset_name = os.environ.get("AVALON_ASSET")
|
||||||
|
if not asset_name:
|
||||||
|
return project_name
|
||||||
|
|
||||||
|
from avalon import io
|
||||||
|
|
||||||
|
asset_doc = io.find_one(
|
||||||
|
{"type": "asset", "name": asset_name},
|
||||||
|
{"data.parents": 1}
|
||||||
|
)
|
||||||
|
parents = asset_doc.get("data", {}).get("parents") or []
|
||||||
|
|
||||||
|
hierarchy = [project_name]
|
||||||
|
hierarchy.extend(parents)
|
||||||
|
hierarchy.append("<b>{}</b>".format(asset_name))
|
||||||
|
task_name = os.environ.get("AVALON_TASK")
|
||||||
|
if task_name:
|
||||||
|
hierarchy.append(task_name)
|
||||||
|
|
||||||
|
return "/".join(hierarchy)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_current_dir_filepath(cls, filename):
|
def get_current_dir_filepath(cls, filename):
|
||||||
return os.path.join(
|
return os.path.join(
|
||||||
|
|
@ -124,3 +151,7 @@ def get_context_data():
|
||||||
|
|
||||||
def update_context_data(data, changes):
|
def update_context_data(data, changes):
|
||||||
HostContext.save_context_data(data)
|
HostContext.save_context_data(data)
|
||||||
|
|
||||||
|
|
||||||
|
def get_context_title():
|
||||||
|
return HostContext.get_context_title()
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import os
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
|
@ -430,6 +431,18 @@ class PublisherController:
|
||||||
def get_asset_docs(self):
|
def get_asset_docs(self):
|
||||||
return self._asset_docs_cache.get_asset_docs()
|
return self._asset_docs_cache.get_asset_docs()
|
||||||
|
|
||||||
|
def get_context_title(self):
|
||||||
|
context_title = None
|
||||||
|
if hasattr(self.host, "get_context_title"):
|
||||||
|
context_title = self.host.get_context_title()
|
||||||
|
|
||||||
|
if context_title is None:
|
||||||
|
context_title = os.environ.get("AVALON_APP_NAME")
|
||||||
|
if context_title is None:
|
||||||
|
context_title = os.environ.get("AVALON_APP")
|
||||||
|
|
||||||
|
return context_title
|
||||||
|
|
||||||
def get_asset_hierarchy(self):
|
def get_asset_hierarchy(self):
|
||||||
_queue = collections.deque(self.get_asset_docs())
|
_queue = collections.deque(self.get_asset_docs())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,11 +245,6 @@ class PublisherWindow(QtWidgets.QDialog):
|
||||||
|
|
||||||
self.resize(self.default_width, self.default_height)
|
self.resize(self.default_width, self.default_height)
|
||||||
|
|
||||||
# DEBUGING
|
|
||||||
self.set_context_label(
|
|
||||||
"<project>/<hierarchy>/<asset>/<task>/<workfile>"
|
|
||||||
)
|
|
||||||
|
|
||||||
def showEvent(self, event):
|
def showEvent(self, event):
|
||||||
super(PublisherWindow, self).showEvent(event)
|
super(PublisherWindow, self).showEvent(event)
|
||||||
if self._first_show:
|
if self._first_show:
|
||||||
|
|
@ -384,6 +379,9 @@ class PublisherWindow(QtWidgets.QDialog):
|
||||||
|
|
||||||
self._validate_create_instances()
|
self._validate_create_instances()
|
||||||
|
|
||||||
|
context_title = self.controller.get_context_title()
|
||||||
|
self.set_context_label(context_title)
|
||||||
|
|
||||||
def _on_subset_change(self, *_args):
|
def _on_subset_change(self, *_args):
|
||||||
# Ignore changes if in middle of refreshing
|
# Ignore changes if in middle of refreshing
|
||||||
if self._refreshing_instances:
|
if self._refreshing_instances:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue