1717 QPainterPathStroker
1818)
1919from AnyQt .QtCore import (
20- Qt , QEvent , QPointF , QRectF , QRect , QSize , QTimer , QPropertyAnimation
20+ Qt , QEvent , QPointF , QRectF , QRect , QSize , QTime , QTimer , QPropertyAnimation
2121)
2222from AnyQt .QtCore import pyqtSignal as Signal , pyqtProperty as Property
2323
@@ -77,7 +77,7 @@ class NodeBodyItem(GraphicsPathObject):
7777 """
7878 def __init__ (self , parent = None ):
7979 GraphicsPathObject .__init__ (self , parent )
80- assert ( isinstance (parent , NodeItem ) )
80+ assert isinstance (parent , NodeItem )
8181
8282 self .__processingState = 0
8383 self .__progress = - 1
@@ -799,6 +799,9 @@ def __init__(self, widget_description=None, parent=None, **kwargs):
799799 self .warningItem = None
800800 self .infoItem = None
801801
802+ self .mousePressTime = QTime ()
803+ self .mousePressTime .start ()
804+
802805 self .__title = ""
803806 self .__processingState = 0
804807 self .__progress = - 1
@@ -1189,7 +1192,7 @@ def __updateTitleText(self):
11891192 if "progress" in format_fields and len (format_fields ) == 1 :
11901193 # Insert progress into the status text format string.
11911194 spec , _ = format_fields ["progress" ]
1192- if spec != None :
1195+ if spec is not None :
11931196 progress_included = True
11941197 progress_str = "{0:.0f}%" .format (self .progress ())
11951198 status_text .append (msg .format (progress = progress_str ))
@@ -1241,10 +1244,17 @@ def __updateMessages(self):
12411244 origin = origin + QPointF (rect .width () + spacing , 0 )
12421245
12431246 def mousePressEvent (self , event ):
1244- if self .shapeItem .path ().contains (event .pos ()):
1245- return super ().mousePressEvent (event )
1246- else :
1247+ if self .mousePressTime .elapsed () < QApplication .doubleClickInterval ():
1248+ # Double-click triggers two mouse press events and a double-click event.
1249+ # Ignore the second mouse press event (causes widget's node relocation with
1250+ # Logitech's Smart Move).
12471251 event .ignore ()
1252+ else :
1253+ self .mousePressTime .restart ()
1254+ if self .shapeItem .path ().contains (event .pos ()):
1255+ super ().mousePressEvent (event )
1256+ else :
1257+ event .ignore ()
12481258
12491259 def mouseDoubleClickEvent (self , event ):
12501260 if self .shapeItem .path ().contains (event .pos ()):
@@ -1255,17 +1265,17 @@ def mouseDoubleClickEvent(self, event):
12551265
12561266 def contextMenuEvent (self , event ):
12571267 if self .shapeItem .path ().contains (event .pos ()):
1258- return super ().contextMenuEvent (event )
1268+ super ().contextMenuEvent (event )
12591269 else :
12601270 event .ignore ()
12611271
12621272 def focusInEvent (self , event ):
12631273 self .shapeItem .setHasFocus (True )
1264- return super ().focusInEvent (event )
1274+ super ().focusInEvent (event )
12651275
12661276 def focusOutEvent (self , event ):
12671277 self .shapeItem .setHasFocus (False )
1268- return super ().focusOutEvent (event )
1278+ super ().focusOutEvent (event )
12691279
12701280 def changeEvent (self , event ):
12711281 if event .type () == QEvent .PaletteChange :
@@ -1332,13 +1342,13 @@ def NodeItem_toolTipHelper(node, links_in=[], links_out=[]):
13321342 inputs = [channel_fmt .format (inp .name ) for inp in desc .inputs ]
13331343 inputs = inputs_list_fmt .format (inputs = "" .join (inputs ))
13341344 else :
1335- inputs = "No inputs<hr/>"
1345+ inputs = "No inputs<hr/>"
13361346
13371347 if desc .outputs :
13381348 outputs = [channel_fmt .format (out .name ) for out in desc .outputs ]
13391349 outputs = outputs_list_fmt .format (outputs = "" .join (outputs ))
13401350 else :
1341- outputs = "No outputs"
1351+ outputs = "No outputs"
13421352
13431353 tooltip = title + inputs + outputs
13441354 style = "ul { margin-top: 1px; margin-bottom: 1px; }"
0 commit comments