-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
Issue
The ThumbnailBase label widget is relatively low level in that you have to pass it the required URL it needs to retrieve the thumbnail from using its load method.
Meaning getting a Thumbnail for a User is something like this:
# Load user thumbnail
thumbnail = ThumbnailBase()
thumbnail.setFixedWidth(75)
thumbnail.setFixedHeight(75)
thumbnail.load("pictures/thumbnails/persons/{0}.png".format(user["id"]))The URL changes dependent on the type of entity you are working with making this slightly more involved, plus you'll need to know the URLs for the entities.
Approach
What if we would hide away these URLs and make it easily accessible through a get_thumbnail_url function.
Here's a quick prototype that has some parts unfinished:
def get_thumbnail_url(entity):
"""Get the related thumbnail for an entity"""
entity_id = entity["id"]
entity_type = entity["type"]
if entity_type == "Person":
return "pictures/thumbnails/persons/{0}.png".format(entity_id)
elif entity_type == "Project":
return "pictures/thumbnails/projects/{0}.png".format(entity_id)
elif entity_type == "Shot" or entity_type == "Asset":
# Get Main Preview
preview_file_id = entity.get("preview_file_id")
if not preview_file_id:
return
return "pictures/thumbnails/preview-files/{0}.png".format(preview_file_id)
elif entity_type == "Task":
# todo: get latest image content from Comments on Task?
raise NotImplementedError("Not implemented.")This way, if any of the URLs change on CG-Wire's API side we would only need to update this one function as opposed to all codebases using qtazu requiring to update the URLs in their code..
Metadata
Metadata
Assignees
Labels
No labels