30
30
from operator import itemgetter
31
31
32
32
from PyQt5 .QtCore import QMimeData , Qt , QLocale , QTimer
33
- from PyQt5 .QtGui import *
33
+ from PyQt5 .QtGui import (
34
+ QStandardItemModel , QStandardItem ,
35
+ QPixmap , QColor ,
36
+ )
34
37
35
38
from classes import updates
36
39
from classes import info
37
- from classes .query import Clip , Transition , Effect , File
40
+ from classes .query import Clip , Transition , Effect
38
41
from classes .logger import log
39
42
from classes .app import get_app
40
43
import openshot
41
44
42
45
import json
43
46
47
+
44
48
class ClipStandardItemModel (QStandardItemModel ):
45
49
def __init__ (self , parent = None ):
46
50
QStandardItemModel .__init__ (self )
@@ -128,7 +132,6 @@ def update_item_timeout(self):
128
132
# Append to selected items
129
133
self .selected .append ((e , item_type ))
130
134
131
-
132
135
# Update frame # from timeline
133
136
self .update_frame (get_app ().window .preview_thread .player .Position (), reload_model = False )
134
137
@@ -199,7 +202,6 @@ def remove_keyframe(self, item):
199
202
200
203
# Determine what was changed
201
204
property = self .model .item (item .row (), 0 ).data ()
202
- property_name = property [1 ]["name" ]
203
205
property_type = property [1 ]["type" ]
204
206
closest_point_x = property [1 ]["closest_point_x" ]
205
207
property_type = property [1 ]["type" ]
@@ -228,7 +230,10 @@ def remove_keyframe(self, item):
228
230
# Determine type of keyframe (normal or color)
229
231
keyframe_list = []
230
232
if property_type == "color" :
231
- keyframe_list = [c .data [property_key ]["red" ], c .data [property_key ]["blue" ], c .data [property_key ]["green" ]]
233
+ keyframe_list = [
234
+ c .data [property_key ]["red" ],
235
+ c .data [property_key ]["blue" ],
236
+ c .data [property_key ]["green" ]]
232
237
else :
233
238
keyframe_list = [c .data [property_key ]]
234
239
@@ -304,7 +309,11 @@ def color_update(self, item, new_color, interpolation=-1, interpolation_details=
304
309
log .info ("color update: %s" % c .data )
305
310
306
311
# Loop through each keyframe (red, blue, and green)
307
- for color , new_value in [("red" , new_color .red ()), ("blue" , new_color .blue ()), ("green" , new_color .green ())]:
312
+ for color , new_value in [
313
+ ("red" , new_color .red ()),
314
+ ("blue" , new_color .blue ()),
315
+ ("green" , new_color .green ()),
316
+ ]:
308
317
309
318
# Keyframe
310
319
# Loop through points, find a matching points on this frame
@@ -317,7 +326,9 @@ def color_update(self, item, new_color, interpolation=-1, interpolation_details=
317
326
clip_updated = True
318
327
# Update point
319
328
point ["co" ]["Y" ] = new_value
320
- log .info ("updating point: co.X = %s to value: %s" % (point ["co" ]["X" ], float (new_value )))
329
+ log .info (
330
+ "updating point: co.X = %s to value: %s"
331
+ % (point ["co" ]["X" ], float (new_value )))
321
332
break
322
333
323
334
elif interpolation > - 1 and point ["co" ]["X" ] == previous_point_x :
@@ -330,7 +341,9 @@ def color_update(self, item, new_color, interpolation=-1, interpolation_details=
330
341
point ["handle_right" ]["X" ] = interpolation_details [0 ]
331
342
point ["handle_right" ]["Y" ] = interpolation_details [1 ]
332
343
333
- log .info ("updating interpolation mode point: co.X = %s to %s" % (point ["co" ]["X" ], interpolation ))
344
+ log .info (
345
+ "updating interpolation mode point: co.X = %s to %s"
346
+ % (point ["co" ]["X" ], interpolation ))
334
347
log .info ("use interpolation preset: %s" % str (interpolation_details ))
335
348
336
349
elif interpolation > - 1 and point ["co" ]["X" ] == closest_point_x :
@@ -343,14 +356,18 @@ def color_update(self, item, new_color, interpolation=-1, interpolation_details=
343
356
point ["handle_left" ]["X" ] = interpolation_details [2 ]
344
357
point ["handle_left" ]["Y" ] = interpolation_details [3 ]
345
358
346
- log .info ("updating interpolation mode point: co.X = %s to %s" % (point ["co" ]["X" ], interpolation ))
359
+ log .info (
360
+ "updating interpolation mode point: co.X = %s to %s"
361
+ % (point ["co" ]["X" ], interpolation ))
347
362
log .info ("use interpolation preset: %s" % str (interpolation_details ))
348
363
349
364
# Create new point (if needed)
350
365
if not found_point :
351
366
clip_updated = True
352
367
log .info ("Created new point at X=%s" % self .frame_number )
353
- c .data [property_key ][color ]["Points" ].append ({'co' : {'X' : self .frame_number , 'Y' : new_value }, 'interpolation' : 1 })
368
+ c .data [property_key ][color ]["Points" ].append ({
369
+ 'co' : {'X' : self .frame_number , 'Y' : new_value },
370
+ 'interpolation' : 1 })
354
371
355
372
# Reduce # of clip properties we are saving (performance boost)
356
373
c .data = {property_key : c .data [property_key ]}
@@ -377,7 +394,6 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
377
394
378
395
# Determine what was changed
379
396
property = self .model .item (item .row (), 0 ).data ()
380
- property_name = property [1 ]["name" ]
381
397
closest_point_x = property [1 ]["closest_point_x" ]
382
398
previous_point_x = property [1 ]["previous_point_x" ]
383
399
property_type = property [1 ]["type" ]
@@ -387,7 +403,7 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
387
403
# Get value (if any)
388
404
if item .text ():
389
405
# Set and format value based on property type
390
- if value != None :
406
+ if value is not None :
391
407
# Override value
392
408
new_value = value
393
409
elif property_type == "string" :
@@ -408,8 +424,9 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
408
424
else :
409
425
new_value = None
410
426
411
- log .info ("%s for %s changed to %s at frame %s with interpolation: %s at closest x: %s" % (property_key , clip_id , new_value , self .frame_number , interpolation , closest_point_x ))
412
-
427
+ log .info (
428
+ "%s for %s changed to %s at frame %s with interpolation: %s at closest x: %s"
429
+ % (property_key , clip_id , new_value , self .frame_number , interpolation , closest_point_x ))
413
430
414
431
# Find this clip
415
432
c = None
@@ -443,9 +460,11 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
443
460
found_point = True
444
461
clip_updated = True
445
462
# Update or delete point
446
- if new_value != None :
463
+ if new_value is not None :
447
464
point ["co" ]["Y" ] = float (new_value )
448
- log .info ("updating point: co.X = %s to value: %s" % (point ["co" ]["X" ], float (new_value )))
465
+ log .info (
466
+ "updating point: co.X = %s to value: %s"
467
+ % (point ["co" ]["X" ], float (new_value )))
449
468
else :
450
469
point_to_delete = point
451
470
break
@@ -460,7 +479,9 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
460
479
point ["handle_right" ]["X" ] = interpolation_details [0 ]
461
480
point ["handle_right" ]["Y" ] = interpolation_details [1 ]
462
481
463
- log .info ("updating interpolation mode point: co.X = %s to %s" % (point ["co" ]["X" ], interpolation ))
482
+ log .info (
483
+ "updating interpolation mode point: co.X = %s to %s"
484
+ % (point ["co" ]["X" ], interpolation ))
464
485
log .info ("use interpolation preset: %s" % str (interpolation_details ))
465
486
466
487
elif interpolation > - 1 and point ["co" ]["X" ] == closest_point_x :
@@ -473,7 +494,9 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
473
494
point ["handle_left" ]["X" ] = interpolation_details [2 ]
474
495
point ["handle_left" ]["Y" ] = interpolation_details [3 ]
475
496
476
- log .info ("updating interpolation mode point: co.X = %s to %s" % (point ["co" ]["X" ], interpolation ))
497
+ log .info (
498
+ "updating interpolation mode point: co.X = %s to %s"
499
+ % (point ["co" ]["X" ], interpolation ))
477
500
log .info ("use interpolation preset: %s" % str (interpolation_details ))
478
501
479
502
# Delete point (if needed)
@@ -483,10 +506,12 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
483
506
c .data [property_key ]["Points" ].remove (point_to_delete )
484
507
485
508
# Create new point (if needed)
486
- elif not found_point and new_value != None :
487
- clip_updated = True
488
- log .info ("Created new point at X=%s" % self .frame_number )
489
- c .data [property_key ]["Points" ].append ({'co' : {'X' : self .frame_number , 'Y' : new_value }, 'interpolation' : 1 })
509
+ elif not found_point and new_value is not None :
510
+ clip_updated = True
511
+ log .info ("Created new point at X=%s" % self .frame_number )
512
+ c .data [property_key ]["Points" ].append ({
513
+ 'co' : {'X' : self .frame_number , 'Y' : new_value },
514
+ 'interpolation' : 1 })
490
515
491
516
if not clip_updated :
492
517
# If no keyframe was found, set a basic property
@@ -579,7 +604,6 @@ def update_model(self, filter=""):
579
604
# Add Headers
580
605
self .model .setHorizontalHeaderLabels ([_ ("Property" ), _ ("Value" )])
581
606
582
-
583
607
# Loop through properties, and build a model
584
608
for property in all_properties .items ():
585
609
label = property [1 ]["name" ]
@@ -591,15 +615,14 @@ def update_model(self, filter=""):
591
615
keyframe = property [1 ]["keyframe" ]
592
616
points = property [1 ]["points" ]
593
617
interpolation = property [1 ]["interpolation" ]
594
- closest_point_x = property [1 ]["closest_point_x" ]
595
618
choices = property [1 ]["choices" ]
596
619
597
620
# Adding Transparency to translation file
598
- transparency_label = _ ("Transparency" )
621
+ transparency_label = _ ("Transparency" ) # noqa
599
622
600
623
selected_choice = None
601
624
if choices :
602
- selected_choice = [c for c in choices if c ["selected" ] == True ][0 ]["name" ]
625
+ selected_choice = [c for c in choices if c ["selected" ] is True ][0 ]["name" ]
603
626
604
627
# Hide filtered out properties
605
628
if filter and filter .lower () not in _ (label ).lower ():
@@ -688,7 +711,11 @@ def update_model(self, filter=""):
688
711
if readonly or type == "color" or choices or label == "Track" :
689
712
col .setFlags (Qt .ItemIsEnabled )
690
713
else :
691
- col .setFlags (Qt .ItemIsSelectable | Qt .ItemIsEnabled | Qt .ItemIsUserCheckable | Qt .ItemIsEditable )
714
+ col .setFlags (
715
+ Qt .ItemIsSelectable
716
+ | Qt .ItemIsEnabled
717
+ | Qt .ItemIsUserCheckable
718
+ | Qt .ItemIsEditable )
692
719
row .append (col )
693
720
694
721
# Append ROW to MODEL (if does not already exist in model)
@@ -795,7 +822,6 @@ def update_model(self, filter=""):
795
822
# Add Headers
796
823
self .model .setHorizontalHeaderLabels ([_ ("Property" ), _ ("Value" )])
797
824
798
-
799
825
# Done updating model
800
826
self .ignore_update_signal = False
801
827
0 commit comments