@@ -456,45 +456,40 @@ def contextMenuEvent(self, event):
456
456
457
457
# Handle parent effect options
458
458
if property_key == "parent_effect_id" and not self .choices :
459
- # Instantiate the timeline
460
- timeline_instance = get_app ().window .timeline_sync .timeline
461
459
# Instantiate this effect
462
- effect = timeline_instance .GetClipEffect (clip_id )
463
- effect_json = json .loads (effect .Json ())
460
+ effect = Effect .get (id = clip_id )
464
461
465
462
# Loop through timeline's clips
466
463
clip_choices = []
467
- for clip_instance in timeline_instance .Clips ():
468
- clip_instance_id = clip_instance .Id ()
469
- # Avoid parent a clip effect to it's own effect
470
- if clip_instance_id != effect .ParentClipId ():
471
- # Clip's propertyJSON data
472
- clip_instance_data = Clip .get (id = clip_instance_id ).data
473
- # Path to the clip file
474
- clip_instance_path = clip_instance_data ["reader" ]["path" ]
475
- # Iterate through all clip files on the timeline
476
- for clip_number in range (self .files_model .rowCount ()):
477
- clip_index = self .files_model .index (clip_number , 0 )
478
- clip_name = clip_index .sibling (clip_number , 1 ).data ()
479
- clip_path = os .path .join (clip_index .sibling (clip_number , 4 ).data (), clip_name )
480
- # Check if the timeline's clip file name matches the clip the user selected
481
- if clip_path == clip_instance_path :
482
- # Generate the clip icon to show in the selection menu
483
- clip_instance_icon = clip_index .data (Qt .DecorationRole )
464
+ for clip in Clip .filter ():
465
+ file_id = clip .data .get ("file_id" )
466
+
467
+ # Look up parent clip id (if effect)
468
+ parent_clip_id = effect .parent .get ("id" )
469
+
470
+ # Avoid attach a clip to it's own object
471
+ if clip .id != parent_clip_id :
472
+ # Iterate through all project files (to find matching QIcon)
473
+ for file_index in range (self .files_model .rowCount ()):
474
+ file_row = self .files_model .index (file_index , 0 )
475
+ project_file_id = file_row .sibling (file_index , 5 ).data ()
476
+ if file_id == project_file_id :
477
+ clip_instance_icon = file_row .data (Qt .DecorationRole )
478
+ break
479
+
484
480
effect_choices = []
485
481
# Iterate through clip's effects
486
- for effect_data in clip_instance_data ["effects" ]:
482
+ for clip_effect_data in clip . data ["effects" ]:
487
483
# Make sure the user can only set a parent effect of the same type as this effect
488
- if effect_data ['class_name' ] == effect_json ['class_name' ]:
489
- effect_id = effect_data ["id" ]
490
- effect_name = effect_data ['class_name' ]
491
- effect_icon = QIcon (QPixmap (os .path .join (info .PATH , "effects" , "icons" , "%s.png" % effect_data ['class_name' ].lower ())))
484
+ if clip_effect_data ['class_name' ] == effect .data ['class_name' ]:
485
+ effect_id = clip_effect_data ["id" ]
486
+ effect_icon = QIcon (QPixmap (os .path .join (info .PATH , "effects" , "icons" , "%s.png" % clip_effect_data ['class_name' ].lower ())))
492
487
effect_choices .append ({"name" : effect_id ,
493
488
"value" : effect_id ,
494
489
"selected" : False ,
495
490
"icon" : effect_icon })
496
491
if effect_choices :
497
- clip_choices .append ({"name" : _ (clip_instance_data ["title" ]),
492
+ clip_choices .append ({"name" : _ (clip . data ["title" ]),
498
493
"value" : effect_choices ,
499
494
"selected" : False ,
500
495
"icon" : clip_instance_icon })
@@ -531,39 +526,33 @@ def contextMenuEvent(self, event):
531
526
# Instantiate the timeline
532
527
timeline_instance = get_app ().window .timeline_sync .timeline
533
528
# Loop through timeline's clips
534
- for clip_instance in timeline_instance .Clips ():
535
- clip_instance_id = clip_instance .Id ()
529
+ for clip in Clip .filter ():
530
+ file_id = clip .data .get ("file_id" )
531
+
536
532
# Look up parent clip id (if effect)
537
533
parent_clip_id = clip_id
538
534
if item_type == "effect" :
539
535
parent_clip_id = Effect .get (id = clip_id ).parent .get ("id" )
540
536
log .debug (f"Lookup parent clip ID for effect: '{ clip_id } ' = '{ parent_clip_id } '" )
541
537
542
538
# Avoid attach a clip to it's own object
543
- if clip_instance_id != parent_clip_id :
544
- # Clip's propertyJSON data
545
- clip_instance_data = Clip .get (id = clip_instance_id ).data
546
- # Path to the clip file
547
- clip_instance_path = clip_instance_data ["reader" ]["path" ]
548
- # Iterate through all clip files on the timeline
549
- for clip_number in range (self .files_model .rowCount ()):
550
- clip_index = self .files_model .index (clip_number , 0 )
551
- clip_name = clip_index .sibling (clip_number , 1 ).data ()
552
- clip_path = os .path .join (clip_index .sibling (clip_number , 4 ).data (), clip_name )
553
- # Check if the timeline's clip file name matches the clip the user selected
554
- if clip_path == clip_instance_path :
555
- # Generate the clip icon to show in the selection menu
556
- clip_instance_icon = clip_index .data (Qt .DecorationRole )
557
- clip_choices .append ({"name" : clip_instance_data ["title" ],
558
- "value" : clip_instance_id ,
539
+ if clip .id != parent_clip_id :
540
+ # Iterate through all project files (to find matching QIcon)
541
+ for file_index in range (self .files_model .rowCount ()):
542
+ file_row = self .files_model .index (file_index , 0 )
543
+ project_file_id = file_row .sibling (file_index , 5 ).data ()
544
+ if file_id == project_file_id :
545
+ clip_instance_icon = file_row .data (Qt .DecorationRole )
546
+ clip_choices .append ({"name" : clip .data ["title" ],
547
+ "value" : clip .id ,
559
548
"selected" : False ,
560
549
"icon" : clip_instance_icon })
561
550
# Get the pixmap of the clip icon
562
551
icon_size = 72
563
552
icon_pixmap = clip_instance_icon .pixmap (icon_size , icon_size )
564
553
# Add tracked objects to the selection menu
565
554
tracked_objects = []
566
- for effect in clip_instance_data ["effects" ]:
555
+ for effect in clip . data ["effects" ]:
567
556
# Check if effect has a tracked object
568
557
if effect .get ("has_tracked_object" ):
569
558
# Instantiate the effect
@@ -583,7 +572,7 @@ def contextMenuEvent(self, event):
583
572
"value" : str (object_id ),
584
573
"selected" : False ,
585
574
"icon" : QIcon (tracked_object_icon )})
586
- tracked_choices .append ({"name" : clip_instance_data ["title" ],
575
+ tracked_choices .append ({"name" : clip . data ["title" ],
587
576
"value" : tracked_objects ,
588
577
"selected" : False ,
589
578
"icon" : clip_instance_icon })
0 commit comments