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

{On hold} v1.4.2_rdo7 to v1.9.1_rdo #11

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
80 changes: 80 additions & 0 deletions hooks/tk-softimage_actions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Copyright (c) 2013 Shotgun Software Inc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test notes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!fix

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!resolved

#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

"""
Hook that loads defines all the available actions, broken down by publish type.
"""
import sgtk

HookBaseClass = sgtk.get_hook_baseclass()


class SoftimageActions(HookBaseClass):

##########################################################################################################
# public interface - to be overridden by deriving classes

def generate_actions(self, sg_publish_data, actions, ui_area):
"""
Returns a list of action instances for a particular publish.
This method is called each time a user clicks a publish somewhere in the UI.
The data returned from this hook will be used to populate the actions menu for a publish.

The mapping between Publish types and actions are kept in a different place
(in the configuration) so at the point when this hook is called, the loader app
has already established *which* actions are appropriate for this object.

The hook should return at least one action for each item passed in via the
actions parameter.

This method needs to return detailed data for those actions, in the form of a list
of dictionaries, each with name, params, caption and description keys.

Because you are operating on a particular publish, you may tailor the output
(caption, tooltip etc) to contain custom information suitable for this publish.

The ui_area parameter is a string and indicates where the publish is to be shown.
- If it will be shown in the main browsing area, "main" is passed.
- If it will be shown in the details area, "details" is passed.
- If it will be shown in the history area, "history" is passed.

Please note that it is perfectly possible to create more than one action "instance" for
an action! You can for example do scene introspection - if the action passed in
is "character_attachment" you may for example scan the scene, figure out all the nodes
where this object can be attached and return a list of action instances:
"attach to left hand", "attach to right hand" etc. In this case, when more than
one object is returned for an action, use the params key to pass additional
data into the run_action hook.

:param sg_publish_data: Shotgun data dictionary with all the standard publish fields.
:param actions: List of action strings which have been defined in the app configuration.
:param ui_area: String denoting the UI Area (see above).
:returns List of dictionaries, each with keys name, params, caption and description
"""
app = self.parent
app.log_debug("Generate actions called for UI element %s. "
"Actions: %s. Publish Data: %s" % (ui_area, actions, sg_publish_data))

action_instances = []
return action_instances

def execute_action(self, name, params, sg_publish_data):
"""
Execute a given action. The data sent to this be method will
represent one of the actions enumerated by the generate_actions method.

:param name: Action name string representing one of the items returned by generate_actions.
:param params: Params data, as specified by generate_actions.
:param sg_publish_data: Shotgun data dictionary with all the standard publish fields.
:returns: No return value expected.
"""
app = self.parent
app.log_debug("Execute action called for action %s. "
"Parameters: %s. Publish Data: %s" % (name, params, sg_publish_data))
1 change: 1 addition & 0 deletions info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,4 @@ requires_engine_version:
frameworks:
- {"name": "tk-framework-shotgunutils", "version": "v4.x.x"}
- {"name": "tk-framework-qtwidgets", "version": "v2.x.x"}
- {"name": "tk-framework-rdo", 'version': "v0.0.x"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to share our framework? It is used only for the icons right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Julien (in git colony):

It's used for the icons and for the custom widget we use for the load options. We won't share it

3 changes: 2 additions & 1 deletion python/tk_multi_loader/delegate_publish_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ def _format_publish(self, model_index, widget):
small_text = "<span style='color:#2C93E2'>%s</span> by %s at %s" % (pub_type_str,
author_str,
date_str)

small_text += "<br><b>Description:</b> %s" % sg_data.get("description") or "No description given"

# and set a tooltip
tooltip = "<b>Name:</b> %s" % (sg_data.get("code") or "No name given.")
tooltip += "<br><br><b>Path:</b> %s" % ((sg_data.get("path") or {}).get("local_path"))
Expand Down
107 changes: 77 additions & 30 deletions python/tk_multi_loader/delegate_publish_thumb.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def _on_before_paint(self, widget, model_index, style_options):
# this is a publish!

# example data:

# {'code': 'aaa_00010_F004_C003_0228F8_v000.%04d.dpx',
# 'created_at': 1425378837.0,
# 'created_by': {'id': 42, 'name': 'Manne Ohrstrom', 'type': 'HumanUser'},
Expand Down Expand Up @@ -299,34 +299,11 @@ def _on_before_paint(self, widget, model_index, style_options):
# 'version.Version.sg_status_list': 'rev',
# 'version_number': 2}

# get the name (lighting v3)
name_str = "Unnamed"
if sg_data.get("name"):
name_str = sg_data.get("name")

if sg_data.get("version_number"):
name_str += " v%s" % sg_data.get("version_number")

# now we are tracking whether this item has a unique task/name/type combo
# or not via the specially injected task_uniqueness boolean.
# If this is true, that means that this is the only item in the listing
# with this name/type combo, and we can render its display name on two
# lines, name first and then type, e.g.:
# MyScene, v3
# Maya Render
#
# However, there can be multiple *different* tasks which have the same
# name/type combo - in this case, we want to display the task name too
# since this is what differentiates the data. In that case we display it:
# MyScene, v3 (Layout)
# Maya Render
#
if sg_data.get("task_uniqueness") == False and sg_data.get("task") is not None:
name_str += " (%s)" % sg_data["task"]["name"]

name_str = self._get_name_string(sg_data)

# make this the title of the card
header_text = name_str

# and set a tooltip
tooltip = "<b>Name:</b> %s" % (sg_data.get("code") or "No name given.")
# Version 012 by John Smith at 2014-02-23 10:34
Expand Down Expand Up @@ -366,12 +343,81 @@ def _on_before_paint(self, widget, model_index, style_options):
# std publish - render with a name and a publish type
# main_body v3
# Render
details_text = shotgun_model.get_sanitized_data(model_index,
SgLatestPublishModel.PUBLISH_TYPE_NAME_ROLE)
details_text = self._get_details_text(sg_data)


widget.set_text(header_text, details_text, tooltip)

def _get_name_string(self, sg_data):
# example data:

# {'code': 'aaa_00010_F004_C003_0228F8_v000.%04d.dpx',
# 'created_at': 1425378837.0,
# 'created_by': {'id': 42, 'name': 'Manne Ohrstrom', 'type': 'HumanUser'},
# 'created_by.HumanUser.image': 'https://...',
# 'description': 'testing testing, 1,2,3',
# 'entity': {'id': 1660, 'name': 'aaa_00010', 'type': 'Shot'},
# 'id': 1340,
# 'image': 'https:...',
# 'name': 'aaa_00010, F004_C003_0228F8',
# 'path': {'content_type': 'image/dpx',
# 'id': 24116,
# 'link_type': 'local',
# 'local_path': '/mnt/projects...',
# 'local_path_linux': '/mnt/projects...',
# 'local_path_mac': '/mnt/projects...',
# 'local_path_windows': 'z:\\mnt\\projects...',
# 'local_storage': {'id': 4,
# 'name': 'primary',
# 'type': 'LocalStorage'},
# 'name': 'aaa_00010_F004_C003_0228F8_v000.%04d.dpx',
# 'type': 'Attachment',
# 'url': 'file:///mnt/projects...'},
# 'project': {'id': 289, 'name': 'Climp', 'type': 'Project'},
# 'published_file_type': {'id': 53,
# 'name': 'Flame Render',
# 'type': 'PublishedFileType'},
# 'task': None,
# 'task.Task.content': None,
# 'task.Task.due_date': None,
# 'task.Task.sg_status_list': None,
# 'task_uniqueness': False,
# 'type': 'PublishedFile',
# 'version': {'id': 6697,
# 'name': 'aaa_00010_F004_C003_0228F8_v000',
# 'type': 'Version'},
# 'version.Version.sg_status_list': 'rev',
# 'version_number': 2}

# get the name (lighting v3)
name_str = "Unnamed"
if sg_data.get("name"):
name_str = sg_data.get("name")

if sg_data.get("version_number"):
name_str += " v%s" % sg_data.get("version_number")

# now we are tracking whether this item has a unique task/name/type combo
# or not via the specially injected task_uniqueness boolean.
# If this is true, that means that this is the only item in the listing
# with this name/type combo, and we can render its display name on two
# lines, name first and then type, e.g.:
# MyScene, v3
# Maya Render
#
# However, there can be multiple *different* tasks which have the same
# name/type combo - in this case, we want to display the task name too
# since this is what differentiates the data. In that case we display it:
# MyScene, v3 (Layout)
# Maya Render
#
if sg_data.get("task_uniqueness") == False and sg_data.get("task") is not None:
name_str += " (%s)" % sg_data["task"]["name"]

return name_str

def _get_details_text(self, sg_data):
return ""

def sizeHint(self, style_options, model_index):
"""
Specify the size of the item.
Expand All @@ -384,3 +430,4 @@ def sizeHint(self, style_options, model_index):
return PublishThumbWidget.calculate_size(scale_factor)



Loading