Show more appropriate cursor when dragging and enable modifier keys
ClosedPublic

Authored by rkflx on Jun 25 2018, 9:46 PM.

Details

Summary

984b9737f079 enabled dragging from View mode, but the cursor
stayed the same as when panning. This is because by default
QGraphicsView sets the cursor for moving objects, i.e.
ClosedHandCursor. By setting a default action for QDrag::exec, we
get the DragCopyCursor which better indicates that the image can be
dropped, and which is also used when dragging from the ThumbnailView.

When drag-and-dropping within Dolphin, you can press ,
Ctrl or Ctrl+ to directly move, copy or link a file
instead of showing the popup menu asking for the desired action. By
setting all three actions for the drag object, we can enabled this
behaviour for dragging from Gwenview to Dolphin too, instead of always
defaulting to copying.

Test Plan

Press +Ctrl while dragging an image from either View or
Browse mode to Dolphin. A cursor indicating the linking action
should be shown instead of the panning cursor.

Diff Detail

Repository
R260 Gwenview
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
rkflx requested review of this revision.Jun 25 2018, 9:46 PM
rkflx created this revision.
huoni accepted this revision.Jul 8 2018, 12:19 AM
huoni added a subscriber: huoni.

LGTM!

Two things I noticed while testing:

  1. If you drag to e.g. Dolphin, keep the mouse still, and then hold or ctrl+, the action doesn't change until you move the mouse with the modifiers held (ctrl doesn't seem to have this problem - because default?). I'm guessing this is a Qt quirk.
  2. The modifier keys don't work when dragging from Dolphin to Gwenview. I.e. the copy/move/link context menu always appears. Is this a Dolphin or Gwenview problem?
This revision is now accepted and ready to land.Jul 8 2018, 12:19 AM
rkflx added a comment.Jul 8 2018, 10:40 PM
  1. If you drag to e.g. Dolphin, keep the mouse still, and then hold or ctrl+, the action doesn't change until you move the mouse with the modifiers held (ctrl doesn't seem to have this problem - because default?). I'm guessing this is a Qt quirk.

I noticed that too, but now that you are mentioning it, the cursor changing only once you move your mouse seems like a common theme, see e.g. #1 in D11877#282977. What this probably needs is a minimal test case and a bugreport (and someone who has time to spend on both…).

  1. The modifier keys don't work when dragging from Dolphin to Gwenview. I.e. the copy/move/link context menu always appears. Is this a Dolphin or Gwenview problem?

I know, needs implementation in Gwenview's thumbnail views. We've still got plenty of problems to fix:

  • Bug 212417 – gwenview ignores CTRL and SHIFT keys on drag-and-drop
  • Refine modifier handling when dragging to Gwenview's View mode: Default to Open for NoModifier, and with modifiers pressed show menu with options (Open/Copy/Move/Link) or simply don't change cursor at all to indicate only opening is possible?
  • Bug 252471 – drag n drop in folder tree not possible
  • Lots more, which I haven't gotten around to file a bug for yet.
This revision was automatically updated to reflect the committed changes.