Skip to content
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

Loader support add to shot inventory #62

Open
wants to merge 25 commits into
base: production-2
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
791c724
Add get_publish_path function, can get publish path without using rep…
jackyjacky1307 Jun 22, 2022
c45b772
Avalon support episode and sequence
jackyjacky1307 Aug 11, 2022
f87e52b
Avalon episode and sequence env setup
jackyjacky1307 Aug 12, 2022
311af31
Create asset support episode and sequence
jackyjacky1307 Aug 12, 2022
12f5e20
switch lut when from workio
rebeccaLinx Sep 22, 2022
8d4e6a0
Check for same name asset
jackyjacky1307 Sep 23, 2022
4adb213
compute_session_changes support for ep and seq
jackyjacky1307 Sep 27, 2022
1d15996
Add creator and createTime field
jackyjacky1307 Sep 26, 2022
7705bed
add admin permission and same name validate
jackyjacky1307 Sep 26, 2022
15b7984
add permission hint label
jackyjacky1307 Sep 27, 2022
2703604
support asset_type
jackyjacky1307 Nov 1, 2022
b672bad
show grab info in loader
jackyjacky1307 Oct 19, 2022
c29194a
show grab info in loader and scene inventory
jackyjacky1307 Nov 9, 2022
561eb72
Fix workfile get wrong path
jackyjacky1307 Dec 2, 2022
d7bce93
Add get_publish_path function, can get publish path without using rep…
jackyjacky1307 Jun 22, 2022
3c27f52
Avalon support episode and sequence
jackyjacky1307 Aug 11, 2022
4a6c25b
Avalon episode and sequence env setup
jackyjacky1307 Aug 12, 2022
ef8ad42
Add creator and createTime field
jackyjacky1307 Sep 26, 2022
23aed69
support asset_type
jackyjacky1307 Nov 1, 2022
c806791
show grab info in loader
jackyjacky1307 Oct 19, 2022
2c79d2a
show grab info in loader and scene inventory
jackyjacky1307 Nov 9, 2022
1b9bb84
Loader support renderFrames and renderDuration attribute
jackyjacky1307 Dec 8, 2022
1151465
Add usd icon
rebeccaLinx Dec 15, 2022
b5f32d2
Avalon menu add switch task
jackyjacky1307 Dec 15, 2022
07f6209
Loader support add to shot inventory
jackyjacky1307 Jan 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avalon menu add switch task
  • Loading branch information
jackyjacky1307 authored and rebeccaLinx committed Jan 13, 2023
commit b5f32d2f3338c816dddcc71fe2ea181ab9640736
3 changes: 3 additions & 0 deletions avalon/maya/pipeline.py
Original file line number Diff line number Diff line change
@@ -137,6 +137,9 @@ def deferred():
enable=False
)

cmds.menuItem("Switch Task",
command=lambda *args: workfiles.show_switch_task(parent=self._parent))

cmds.setParent("..", menu=True)

cmds.menuItem(divider=True)
3 changes: 3 additions & 0 deletions avalon/nuke/pipeline.py
Original file line number Diff line number Diff line change
@@ -414,6 +414,9 @@ def _install_menu():
# Create menu
menubar = nuke.menu("Nuke")
menu = menubar.addMenu(api.Session["AVALON_LABEL"])
menu.addCommand("Switch Task",
lambda: workfiles.show_switch_task(parent=get_main_window())
)

_add_contextmanager_menu(menu)

6 changes: 4 additions & 2 deletions avalon/tools/workfiles/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from .app import (
show
show,
show_switch_task
)

__all__ = [
"show"
"show",
"show_switch_task"
]
153 changes: 153 additions & 0 deletions avalon/tools/workfiles/app.py
Original file line number Diff line number Diff line change
@@ -891,6 +891,127 @@ def _on_task_changed(self):
files.refresh()


class SwitchTaskWindow(QtWidgets.QMainWindow):
"""Switch Task Window"""
title = "Switch Task"

def __init__(self, parent=None):
super(SwitchTaskWindow, self).__init__(parent=parent)
self.setWindowTitle(self.title)
self.setWindowFlags(QtCore.Qt.Window | QtCore.Qt.WindowCloseButtonHint)
self.setWindowModality(QtCore.Qt.ApplicationModal)

pages = {
"home": QtWidgets.QWidget()
}

widgets = {
"pages": QtWidgets.QStackedWidget(),
"body": QtWidgets.QWidget(),
"assets": AssetWidget(),
"tasks": TasksWidget(),
"switch": QtWidgets.QPushButton("Switch")
}

self.setCentralWidget(widgets["pages"])
widgets["pages"].addWidget(pages["home"])

# Build home
layout = QtWidgets.QVBoxLayout(pages["home"])
layout.addWidget(widgets["body"])

# Build home - body
layout = QtWidgets.QVBoxLayout(widgets["body"])
split = QtWidgets.QSplitter()
split.addWidget(widgets["assets"])
split.addWidget(widgets["tasks"])
split.setStretchFactor(0, 1)
split.setStretchFactor(1, 1)
layout.addWidget(split)
layout.addWidget(widgets["switch"])

# Add top margin for tasks to align it visually with files as
# the files widget has a filter field which tasks does not.
widgets["tasks"].setContentsMargins(0, 32, 0, 0)

# Connect signals
widgets["assets"].current_changed.connect(self.on_asset_changed)
widgets["tasks"].task_changed.connect(self.on_task_changed)
widgets["switch"].clicked.connect(self.on_switch)

self.widgets = widgets
self.refresh()

self.resize(600, 600)

def on_task_changed(self):
tools_lib.schedule(self._on_task_changed, 100, channel="mongo")

def on_asset_changed(self):
tools_lib.schedule(self._on_asset_changed, 50, channel="mongo")

def on_switch(self):
asset = self.widgets["assets"].get_active_asset_document()
task = self.widgets["tasks"].get_current_task()
"""Enter the asset and task session currently selected"""

session = api.Session.copy()
changes = pipeline.compute_session_changes(session,
asset=asset,
task=task)
if not changes:
# Return early if we're already in the right Session context
# to avoid any unwanted Task Changed callbacks to be triggered.
self.close()
return

api.update_current_task(asset=asset, task=task)
self.close()

def set_context(self, context):

if "asset" in context:
asset = context["asset"]
asset_document = io.find_one({
"name": asset,
"type": "asset"
})

# Select the asset
self.widgets["assets"].select_assets([asset], expand=True)

# Force a refresh on Tasks?
self.widgets["tasks"].set_asset(asset_document)

if "task" in context:
self.widgets["tasks"].select_task(context["task"])

def refresh(self):

# Refresh asset widget
self.widgets["assets"].refresh()

self.on_task_changed()

def _on_asset_changed(self):
asset = self.widgets["assets"].get_active_asset_document()

if not asset:
# Force disable the other widgets if no
# active selection
self.widgets["tasks"].setEnabled(False)
else:
self.widgets["tasks"].setEnabled(True)

self.widgets["tasks"].set_asset(asset)

def _on_task_changed(self):
asset = self.widgets["assets"].get_active_asset_document()
task = self.widgets["tasks"].get_current_task()
self.widgets["tasks"].setEnabled(bool(asset))
self.widgets["switch"].setEnabled(all([bool(task), bool(asset)]))


def show(root=None, debug=False, parent=None, use_context=True):
"""Show Work Files GUI"""
# todo: remove `root` argument to show()
@@ -942,3 +1063,35 @@ def show(root=None, debug=False, parent=None, use_context=True):
# Pull window to the front.
module.window.raise_()
module.window.activateWindow()


def show_switch_task(parent=None, use_context=True):
"""Show Switch Task GUI"""

if module.window:
module.window.close()
del(module.window)

host = api.registered_host()
if host is None:
raise RuntimeError("No registered host.")

with tools_lib.application():

window = SwitchTaskWindow(parent=parent)
window.refresh()

if use_context:
context = {"asset": api.Session["AVALON_ASSET"],
"silo": api.Session["AVALON_SILO"],
"task": api.Session["AVALON_TASK"]}
window.set_context(context)

window.show()
window.setStyleSheet(style.load_stylesheet())

module.window = window

# Pull window to the front.
module.window.raise_()
module.window.activateWindow()