@@ -222,20 +222,41 @@ def color_button_clicked(self, widget, param, index):
222
222
# Get translation object
223
223
_ = get_app ()._tr
224
224
225
- # Show color dialog
226
225
color_value = self .params [param ["name" ]]
227
226
currentColor = QColor ("#FFFFFF" )
228
227
if len (color_value ) >= 3 :
229
228
currentColor .setRgbF (color_value [0 ], color_value [1 ], color_value [2 ])
230
- newColor = QColorDialog .getColor (currentColor , self , _ ("Select a Color" ),
231
- QColorDialog .DontUseNativeDialog )
232
- if newColor .isValid ():
233
- widget .setStyleSheet ("background-color: {}" .format (newColor .name ()))
234
- self .params [param ["name" ]] = [newColor .redF (), newColor .greenF (), newColor .blueF ()]
235
- if "diffuse_color" in param .get ("name" ):
236
- self .params [param ["name" ]].append (newColor .alphaF ())
237
-
238
- log .info ('Animation param %s set to %s' % (param ["name" ], newColor .name ()))
229
+ # Store our arguments for the callback to pick up again
230
+ self ._color_scratchpad = (widget , param )
231
+
232
+ # Set up non-modal color dialog (to avoid blocking the eyedropper)
233
+ self .newColorDialog = QColorDialog (currentColor , self .win )
234
+ self .newColorDialog .setWindowTitle (_ ("Select a Color" ))
235
+ self .newColorDialog .setWindowFlags (Qt .Tool )
236
+ self .newColorDialog .setOptions (QColorDialog .DontUseNativeDialog )
237
+ # Avoid signal loops
238
+ self .newColorDialog .blockSignals (True )
239
+ self .newColorDialog .colorSelected .connect (self .color_selected )
240
+ self .newColorDialog .finished .connect (self .newColorDialog .deleteLater )
241
+ self .newColorDialog .blockSignals (False )
242
+ self .newColorDialog .open ()
243
+
244
+ @pyqtSlot (QColor )
245
+ def color_selected (self , newColor ):
246
+ """QColorDialog callback when the user chooses a color"""
247
+ if not self ._color_scratchpad :
248
+ log .warning ("QColorDialog callback called without parameter to set" )
249
+ return
250
+ (widget , param ) = self ._color_scratchpad
251
+ if not newColor or not newColor .isValid ():
252
+ return
253
+ widget .setStyleSheet ("background-color: {}" .format (newColor .name ()))
254
+ self .params [param ["name" ]] = [
255
+ newColor .redF (), newColor .greenF (), newColor .blueF ()
256
+ ]
257
+ if "diffuse_color" in param .get ("name" ):
258
+ self .params [param ["name" ]].append (newColor .alphaF ())
259
+ log .info ('Animation param %s set to %s' , param ["name" ], newColor .name ())
239
260
240
261
def generateUniqueFolder (self ):
241
262
""" Generate a new, unique folder name to contain Blender frames """
@@ -651,6 +672,8 @@ def __init__(self, parent, *args):
651
672
652
673
self .selected = None
653
674
self .deselected = None
675
+ self ._color_scratchpad = None
676
+ self .newColorDialog = None
654
677
self .selected_template = ""
655
678
self .final_render = False
656
679
0 commit comments