Skip to content

Commit

Permalink
Widget : Set DragDropEvent.sourceWidget from foreign drags
Browse files Browse the repository at this point in the history
Our assumption was that such drags would always comes from outside of Gaffer - the foreign drag handling was originally added so that we could drag files from the system browser into the GraphEditor. In that case there is no source of information for `sourceWidget`.

But some folks prefer to code their Gaffer extensions in pure Qt, with a tiny shim to host them in GafferUI. In this case, we _can_ find a suitable `sourceWidget`, which we now do.
  • Loading branch information
johnhaddon committed Nov 27, 2024
1 parent a698791 commit 5d19325
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Fixes
-----

- GraphEditor : Fixed errors when dragging an unknown file type into the GraphEditor.
- Widget : Fixed `event.sourceWidget` for DragDropEvents generated from a Qt native drag within the same Gaffer process. This will now reference the `GafferUI.Widget` that the Qt source widget belongs to, if any.

1.4.15.2 (relative to 1.4.15.1)
========
Expand Down
6 changes: 5 additions & 1 deletion python/GafferUI/Widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -1578,9 +1578,13 @@ def __foreignDragEnter( self, qObject, qEvent ) :
Widget._modifiers( qEvent.keyboardModifiers() ),
)
dragDropEvent.data = data
dragDropEvent.sourceWidget = None
dragDropEvent.destinationWidget = None

if isinstance( qEvent.source(), QtWidgets.QWidget ) :
dragDropEvent.sourceWidget = GafferUI.Widget._owner( qEvent.source() )
else :
dragDropEvent.sourceWidget = None

if widget._dragEnterSignal( widget, dragDropEvent ) :
qEvent.acceptProposedAction()
self.__foreignDragDropEvent = dragDropEvent
Expand Down

0 comments on commit 5d19325

Please sign in to comment.