diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-05-23 18:11:43 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2019-05-24 09:42:35 +0200 |
commit | c58487251272b390e9c56a880fa4788d0a5b5a7f (patch) | |
tree | 9b507a1e4191e1c75d3457ea5d71c2176c67d8cc /vcl/qt5/Qt5Frame.cxx | |
parent | c4ab578198aaa177b693ec9fc8b67b74f2ca9ba2 (diff) |
tdf#125160: honour keyboard modifiers if used during DnD
e.g. copy-DnD with Ctrl held down. This is qt5 remix of tdf#109227
Change-Id: Ib0794c7468cc04d3d50686952305717e10c90c9a
Reviewed-on: https://gerrit.libreoffice.org/72878
Tested-by: Jenkins
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'vcl/qt5/Qt5Frame.cxx')
-rw-r--r-- | vcl/qt5/Qt5Frame.cxx | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index 3cfb5d5d9e33..41a4544b4acb 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -1159,16 +1159,30 @@ void Qt5Frame::deregisterDropTarget(Qt5DropTarget const* pDropTarget) } void Qt5Frame::draggingStarted(const int x, const int y, Qt::DropActions eActions, - const QMimeData* pQMimeData) + Qt::KeyboardModifiers eKeyMod, const QMimeData* pQMimeData) { assert(m_pDropTarget); + sal_Int8 nUserDropAction = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; + if ((eKeyMod & Qt::ShiftModifier) && !(eKeyMod & Qt::ControlModifier)) + nUserDropAction = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; + else if ((eKeyMod & Qt::ControlModifier) && !(eKeyMod & Qt::ShiftModifier)) + nUserDropAction = css::datatransfer::dnd::DNDConstants::ACTION_COPY; + else if ((eKeyMod & Qt::ShiftModifier) && (eKeyMod & Qt::ControlModifier)) + nUserDropAction = css::datatransfer::dnd::DNDConstants::ACTION_LINK; + css::datatransfer::dnd::DropTargetDragEnterEvent aEvent; aEvent.Source = static_cast<css::datatransfer::dnd::XDropTarget*>(m_pDropTarget); aEvent.Context = static_cast<css::datatransfer::dnd::XDropTargetDragContext*>(m_pDropTarget); aEvent.LocationX = x; aEvent.LocationY = y; - aEvent.DropAction = getPreferredDropAction(eActions); + + // system drop action if neither Shift nor Control is held + if (!(eKeyMod & (Qt::ShiftModifier | Qt::ControlModifier))) + aEvent.DropAction = getPreferredDropAction(eActions); + // otherwise user-preferred action + else + aEvent.DropAction = nUserDropAction; aEvent.SourceActions = toVclDropActions(eActions); css::uno::Reference<css::datatransfer::XTransferable> xTransferable; @@ -1190,7 +1204,8 @@ void Qt5Frame::draggingStarted(const int x, const int y, Qt::DropActions eAction m_pDropTarget->fire_dragOver(aEvent); } -void Qt5Frame::dropping(const int x, const int y, const QMimeData* pQMimeData) +void Qt5Frame::dropping(const int x, const int y, Qt::KeyboardModifiers eKeyMod, + const QMimeData* pQMimeData) { assert(m_pDropTarget); @@ -1199,8 +1214,12 @@ void Qt5Frame::dropping(const int x, const int y, const QMimeData* pQMimeData) aEvent.Context = static_cast<css::datatransfer::dnd::XDropTargetDropContext*>(m_pDropTarget); aEvent.LocationX = x; aEvent.LocationY = y; - aEvent.DropAction = m_pDropTarget->proposedDragAction() - | css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT; + + if (!(eKeyMod & (Qt::ShiftModifier | Qt::ControlModifier))) + aEvent.DropAction = m_pDropTarget->proposedDragAction() + | css::datatransfer::dnd::DNDConstants::ACTION_DEFAULT; + else + aEvent.DropAction = m_pDropTarget->proposedDragAction(); aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; css::uno::Reference<css::datatransfer::XTransferable> xTransferable; |