Skip to content

Commit ff2ee27

Browse files
committed
Added support to insert the image of a clip inside a Tracked Object
1 parent 45da4d6 commit ff2ee27

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/windows/views/properties_tableview.py

+34
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,40 @@ def contextMenuEvent(self, event):
438438
})
439439
self.choices.append({"name": _("Detected Objects"), "value": object_index_choices, "selected": False, "icon": None})
440440

441+
# Handle property to set the Tracked Object's child clip
442+
if property_key == "child_clip_id" and not self.choices:
443+
clip_choices = [{
444+
"name": "None",
445+
"value": "None",
446+
"selected": False,
447+
"icon": QIcon()
448+
}]
449+
# Instantiate the timeline
450+
timeline_instance = get_app().window.timeline_sync.timeline
451+
# Loop through timeline's clips
452+
for clip_instance in timeline_instance.Clips():
453+
clip_instance_id = clip_instance.Id()
454+
# Avoid attach a clip to it's own object
455+
if (clip_instance_id != clip_id):
456+
# Clip's propertyJSON data
457+
clip_instance_data = Clip.get(id = clip_instance_id).data
458+
# Path to the clip file
459+
clip_instance_path = clip_instance_data["reader"]["path"]
460+
# Iterate through all clip files on the timeline
461+
for clip_number in range(self.files_model.rowCount()):
462+
clip_index = self.files_model.index(clip_number, 0)
463+
clip_name = clip_index.sibling(clip_number, 1).data()
464+
clip_path = os.path.join(clip_index.sibling(clip_number, 4).data(), clip_name)
465+
# Check if the timeline's clip file name matches the clip the user selected
466+
if (clip_path == clip_instance_path):
467+
# Generate the clip icon to show in the selection menu
468+
clip_instance_icon = clip_index.data(Qt.DecorationRole)
469+
clip_choices.append({"name": clip_instance_data["title"],
470+
"value": clip_instance_id,
471+
"selected": False,
472+
"icon": clip_instance_icon})
473+
self.choices.append({"name": _("Clips"), "value": clip_choices, "selected": False, "icon": None})
474+
441475
# Handle clip attach options
442476
if property_key == "parentObjectId" and not self.choices:
443477
# Add all Clips as choices - initialize with None

0 commit comments

Comments
 (0)