26
26
"""
27
27
28
28
import os
29
- from functools import partial
29
+ import functools
30
30
from operator import itemgetter
31
- from PyQt5 .QtCore import Qt , QRectF , QLocale , pyqtSignal , QTimer
31
+
32
+ from PyQt5 .QtCore import Qt , QRectF , QLocale , pyqtSignal , pyqtSlot
32
33
from PyQt5 .QtGui import (
33
34
QIcon , QColor , QBrush , QPen , QPalette , QPixmap ,
34
35
QPainter , QPainterPath , QLinearGradient , QFont , QFontInfo ,
35
36
)
36
37
from PyQt5 .QtWidgets import (
37
38
QTableView , QAbstractItemView , QMenu , QSizePolicy ,
38
- QHeaderView , QColorDialog , QItemDelegate , QStyle , QLabel ,
39
+ QHeaderView , QItemDelegate , QStyle , QLabel ,
39
40
QPushButton , QHBoxLayout , QFrame , QFontDialog
40
41
)
41
42
42
43
from classes .logger import log
43
44
from classes .app import get_app
44
45
from classes import info
45
46
from classes .query import Clip , Effect , Transition
47
+
46
48
from windows .models .properties_model import PropertiesModel
49
+ from windows .color_picker import ColorPicker
47
50
48
51
import openshot
49
52
@@ -297,6 +300,13 @@ def mouseReleaseEvent(self, event):
297
300
self .lock_selection = False
298
301
self .previous_x = - 1
299
302
303
+ @pyqtSlot (QColor )
304
+ def color_callback (self , newColor : QColor ):
305
+ # Set the new color keyframe
306
+ if newColor .isValid ():
307
+ self .clip_properties_model .color_update (
308
+ self .selected_item , newColor )
309
+
300
310
def doubleClickedCB (self , model_index ):
301
311
"""Double click handler for the property table"""
302
312
@@ -322,12 +332,11 @@ def doubleClickedCB(self, model_index):
322
332
323
333
# Show color dialog
324
334
currentColor = QColor (red , green , blue )
325
- newColor = QColorDialog .getColor (currentColor , self , _ ("Select a Color" ),
326
- QColorDialog .DontUseNativeDialog )
327
-
328
- # Set the new color keyframe
329
- if newColor .isValid ():
330
- self .clip_properties_model .color_update (self .selected_item , newColor )
335
+ log .debug ("Launching ColorPicker for %s" , currentColor .name ())
336
+ ColorPicker (
337
+ currentColor , parent = self , title = _ ("Select a Color" ),
338
+ callback = self .color_callback )
339
+ return
331
340
332
341
elif property_type == "font" :
333
342
# Get font from user
@@ -381,7 +390,7 @@ def filter_changed(self, value=None):
381
390
self .clip_properties_model .update_model (value )
382
391
383
392
def contextMenuEvent (self , event ):
384
- """ Display context menu, or release lock when menu displays """
393
+ """ Display context menu """
385
394
# Get property being acted on
386
395
index = self .indexAt (event .pos ())
387
396
if not index .isValid ():
@@ -469,6 +478,7 @@ def contextMenuEvent(self, event):
469
478
track_name = track .get ("label" ) or _ ("Track %s" ) % display_count
470
479
self .choices .append ({"name" : track_name , "value" : track .get ("number" ), "selected" : False , "icon" : None })
471
480
display_count -= 1
481
+ return
472
482
473
483
elif self .property_type == "font" :
474
484
# Get font from user
@@ -480,7 +490,6 @@ def contextMenuEvent(self, event):
480
490
if ok and font :
481
491
fontinfo = QFontInfo (font )
482
492
self .clip_properties_model .value_updated (self .selected_item , value = fontinfo .family ())
483
- return self .contextMenuEvent (event , release = True )
484
493
485
494
elif self .property_type == "color" :
486
495
# Get current value of color
@@ -490,13 +499,11 @@ def contextMenuEvent(self, event):
490
499
491
500
# Show color dialog
492
501
currentColor = QColor (red , green , blue )
493
- newColor = QColorDialog .getColor (currentColor , self , _ ("Select a Color" ),
494
- QColorDialog .DontUseNativeDialog )
495
-
496
- # Set the new color keyframe
497
- if newColor .isValid ():
498
- self .clip_properties_model .color_update (self .selected_item , newColor )
499
- return self .contextMenuEvent (event , release = True )
502
+ log .debug ("Launching ColorPicker for %s" , currentColor .name ())
503
+ ColorPicker (
504
+ currentColor , parent = self , title = _ ("Select a Color" ),
505
+ callback = self .color_callback )
506
+ return
500
507
501
508
# Define bezier presets
502
509
bezier_presets = [
@@ -540,7 +547,8 @@ def contextMenuEvent(self, event):
540
547
Bezier_Menu = menu .AddMenu (self .bezier_icon , _ ("Bezier" ))
541
548
for bezier_preset in bezier_presets :
542
549
preset_action = Bezier_Menu .addAction (bezier_preset [4 ])
543
- preset_action .triggered .connect (partial (self .Bezier_Action_Triggered , bezier_preset ))
550
+ preset_action .triggered .connect (functools .partial (
551
+ self .Bezier_Action_Triggered , bezier_preset ))
544
552
Linear_Action = menu .addAction (self .linear_icon , _ ("Linear" ))
545
553
Linear_Action .triggered .connect (self .Linear_Action_Triggered )
546
554
Constant_Action = menu .addAction (self .constant_icon , _ ("Constant" ))
0 commit comments