Blender Kitsu: Use new Kitsu Context UI in Multi Edit / Metadata #280
@ -27,6 +27,7 @@ from bpy.app.handlers import persistent
|
|||||||
from . import propsdata, bkglobals
|
from . import propsdata, bkglobals
|
||||||
from .logger import LoggerFactory
|
from .logger import LoggerFactory
|
||||||
from . import cache
|
from . import cache
|
||||||
|
from .types import Sequence
|
||||||
|
|
||||||
logger = LoggerFactory.getLogger()
|
logger = LoggerFactory.getLogger()
|
||||||
|
|
||||||
@ -49,21 +50,98 @@ class KITSU_property_group_sequence(bpy.types.PropertyGroup):
|
|||||||
They hold metadata that will be used to compose a data structure that can
|
They hold metadata that will be used to compose a data structure that can
|
||||||
be pushed to backend.
|
be pushed to backend.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _get_shot_description(self):
|
def _get_shot_description(self):
|
||||||
return self.shot_description
|
return self.shot_description
|
||||||
|
|
||||||
def _get_sequence_name(self):
|
def _get_sequence_entity(self):
|
||||||
return self.sequence_name
|
try:
|
||||||
|
return Sequence.by_id(self.sequence_id)
|
||||||
|
except AttributeError:
|
||||||
|
return None
|
||||||
|
|
||||||
# Shot.
|
# Shot.
|
||||||
shot_id: bpy.props.StringProperty(name="Shot ID") # type: ignore
|
shot_id: bpy.props.StringProperty(name="Shot ID") # type: ignore
|
||||||
shot_name: bpy.props.StringProperty(name="Shot", default="") # type: ignore
|
shot_name: bpy.props.StringProperty(name="Shot", default="") # type: ignore
|
||||||
|
|
||||||
|
###########
|
||||||
|
# Shot
|
||||||
|
###########
|
||||||
|
shot_id: bpy.props.StringProperty( # type: ignore
|
||||||
|
name="Shot ID",
|
||||||
|
description="ID that refers to the strip's shot on server",
|
||||||
|
default="",
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_shot_via_name(self):
|
||||||
|
return get_safely_string_prop(self, "shot_name")
|
||||||
|
|
||||||
|
def set_shot_via_name(self, input):
|
||||||
|
seq = self._get_sequence_entity()
|
||||||
|
if seq is None:
|
||||||
|
return
|
||||||
|
set_kitsu_entity_id_via_enum_name(
|
||||||
|
self=self,
|
||||||
|
input_name=input,
|
||||||
|
items=cache.get_shots_enum_for_seq(self, bpy.context, seq),
|
||||||
|
name_prop='shot_name',
|
||||||
|
id_prop='shot_id',
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
def get_shot_search_list(self, context, edit_text):
|
||||||
|
seq = self._get_sequence_entity()
|
||||||
|
if seq is None:
|
||||||
|
return []
|
||||||
|
return get_enum_item_names(cache.get_shots_enum_for_seq(self, bpy.context, seq))
|
||||||
|
|
||||||
|
shot_name: bpy.props.StringProperty( # type: ignore
|
||||||
|
name="Shot",
|
||||||
|
description="Name that refers to the strip's shot on server",
|
||||||
|
default="",
|
||||||
|
get=get_shot_via_name,
|
||||||
|
set=set_shot_via_name,
|
||||||
|
options=set(),
|
||||||
|
search=get_shot_search_list,
|
||||||
|
search_options={'SORT'},
|
||||||
|
)
|
||||||
|
|
||||||
shot_description: bpy.props.StringProperty(name="Description", default="", options={"HIDDEN"}) # type: ignore
|
shot_description: bpy.props.StringProperty(name="Description", default="", options={"HIDDEN"}) # type: ignore
|
||||||
|
|
||||||
# Sequence.
|
###########
|
||||||
sequence_name: bpy.props.StringProperty(name="Sequence", default="") # type: ignore
|
# Sequence
|
||||||
sequence_id: bpy.props.StringProperty(name="Seq ID", default="") # type: ignore
|
###########
|
||||||
|
sequence_id: bpy.props.StringProperty( # type: ignore
|
||||||
|
name="Seq ID",
|
||||||
|
description="ID that refers to the active sequence on server",
|
||||||
|
default="",
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_sequences_via_name(self):
|
||||||
|
return get_safely_string_prop(self, "sequence_name")
|
||||||
|
|
||||||
|
def set_sequences_via_name(self, input):
|
||||||
|
key = set_kitsu_entity_id_via_enum_name(
|
||||||
|
self=self,
|
||||||
|
input_name=input,
|
||||||
|
items=cache.get_sequences_enum_list(self, bpy.context),
|
||||||
|
name_prop='sequence_name',
|
||||||
|
id_prop='sequence_id',
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
def get_sequence_search_list(self, context, edit_text):
|
||||||
|
return get_enum_item_names(cache.get_sequences_enum_list(self, bpy.context))
|
||||||
|
|
||||||
|
sequence_name: bpy.props.StringProperty( # type: ignore
|
||||||
|
name="Sequence",
|
||||||
|
description="Sequence",
|
||||||
|
default="",
|
||||||
|
get=get_sequences_via_name,
|
||||||
|
set=set_sequences_via_name,
|
||||||
|
options=set(),
|
||||||
|
search=get_sequence_search_list,
|
||||||
|
search_options={'SORT'},
|
||||||
|
)
|
||||||
|
|
||||||
# Project.
|
# Project.
|
||||||
project_name: bpy.props.StringProperty(name="Project", default="") # type: ignore
|
project_name: bpy.props.StringProperty(name="Project", default="") # type: ignore
|
||||||
@ -89,7 +167,6 @@ class KITSU_property_group_sequence(bpy.types.PropertyGroup):
|
|||||||
|
|
||||||
# Display props.
|
# Display props.
|
||||||
shot_description_display: bpy.props.StringProperty(name="Description", get=_get_shot_description) # type: ignore
|
shot_description_display: bpy.props.StringProperty(name="Description", get=_get_shot_description) # type: ignore
|
||||||
sequence_name_display: bpy.props.StringProperty(name="Sequence", get=_get_sequence_name) # type: ignore
|
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return {
|
return {
|
||||||
|
@ -528,8 +528,6 @@ class KITSU_OT_sqe_link_shot(bpy.types.Operator):
|
|||||||
bl_description = "Links selected sequence strip to shot on server. Pulls all metadata of shot from server"
|
bl_description = "Links selected sequence strip to shot on server. Pulls all metadata of shot from server"
|
||||||
bl_options = {"REGISTER", "UNDO"}
|
bl_options = {"REGISTER", "UNDO"}
|
||||||
|
|
||||||
sequence_enum: bpy.props.EnumProperty(items=cache.get_sequences_enum_list, name="Sequence") # type: ignore
|
|
||||||
shots_enum: bpy.props.EnumProperty(items=opsdata.get_shots_enum_for_link_shot_op, name="Shot") # type: ignore
|
|
||||||
use_url: bpy.props.BoolProperty(
|
use_url: bpy.props.BoolProperty(
|
||||||
name="Use URL",
|
name="Use URL",
|
||||||
description="Use URL of shot on server to initiate strip. Paste complete URL",
|
description="Use URL of shot on server to initiate strip. Paste complete URL",
|
||||||
@ -540,6 +538,8 @@ class KITSU_OT_sqe_link_shot(bpy.types.Operator):
|
|||||||
default="",
|
default="",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_strip = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context: bpy.types.Context) -> bool:
|
def poll(cls, context: bpy.types.Context) -> bool:
|
||||||
sqe = context.scene.sequence_editor
|
sqe = context.scene.sequence_editor
|
||||||
@ -555,9 +555,8 @@ class KITSU_OT_sqe_link_shot(bpy.types.Operator):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||||
strip = context.scene.sequence_editor.active_strip
|
|
||||||
|
|
||||||
shot_id = self.shots_enum
|
shot_id = self._strip.kitsu.shot_id
|
||||||
|
|
||||||
# By url.
|
# By url.
|
||||||
if self.use_url:
|
if self.use_url:
|
||||||
@ -567,8 +566,8 @@ class KITSU_OT_sqe_link_shot(bpy.types.Operator):
|
|||||||
|
|
||||||
# By shot enum.
|
# By shot enum.
|
||||||
else:
|
else:
|
||||||
shot_id = self.shots_enum
|
shot_id = self._strip.kitsu.shot_id
|
||||||
if not shot_id:
|
if shot_id == "":
|
||||||
self.report({"WARNING"}, "Invalid selection. Please choose a shot")
|
self.report({"WARNING"}, "Invalid selection. Please choose a shot")
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
@ -585,10 +584,10 @@ class KITSU_OT_sqe_link_shot(bpy.types.Operator):
|
|||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
# Pull shot meta.
|
# Pull shot meta.
|
||||||
pull.shot_meta(strip, shot)
|
pull.shot_meta(self._strip, shot)
|
||||||
|
|
||||||
# Rename strip.
|
# Rename strip.
|
||||||
strip.name = shot.name
|
self._strip.name = shot.name
|
||||||
|
|
||||||
# Pull sequence color.
|
# Pull sequence color.
|
||||||
seq = Sequence.by_id(shot.parent_id)
|
seq = Sequence.by_id(shot.parent_id)
|
||||||
@ -596,7 +595,7 @@ class KITSU_OT_sqe_link_shot(bpy.types.Operator):
|
|||||||
|
|
||||||
# Log.
|
# Log.
|
||||||
t = "Linked strip: %s to shot: %s with ID: %s" % (
|
t = "Linked strip: %s to shot: %s with ID: %s" % (
|
||||||
strip.name,
|
self._strip.name,
|
||||||
shot.name,
|
shot.name,
|
||||||
shot.id,
|
shot.id,
|
||||||
)
|
)
|
||||||
@ -609,6 +608,7 @@ class KITSU_OT_sqe_link_shot(bpy.types.Operator):
|
|||||||
def invoke(self, context: bpy.types.Context, event: bpy.types.Event) -> Set[str]:
|
def invoke(self, context: bpy.types.Context, event: bpy.types.Event) -> Set[str]:
|
||||||
if context.window_manager.clipboard:
|
if context.window_manager.clipboard:
|
||||||
self.url = context.window_manager.clipboard
|
self.url = context.window_manager.clipboard
|
||||||
|
self._strip = context.scene.sequence_editor.active_strip
|
||||||
|
|
||||||
return context.window_manager.invoke_props_dialog( # type: ignore
|
return context.window_manager.invoke_props_dialog( # type: ignore
|
||||||
self, width=400
|
self, width=400
|
||||||
@ -624,9 +624,9 @@ class KITSU_OT_sqe_link_shot(bpy.types.Operator):
|
|||||||
row.prop(self, "url", text="")
|
row.prop(self, "url", text="")
|
||||||
else:
|
else:
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(self, "sequence_enum")
|
row.prop(self._strip.kitsu, "sequence_name")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(self, "shots_enum")
|
row.prop(self._strip.kitsu, "shot_name")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user