vcl/inc/qt5/Qt5Frame.hxx | 3 ++- vcl/inc/qt5/Qt5Tools.hxx | 5 +++++ vcl/inc/qt5/Qt5Widget.hxx | 2 +- vcl/qt5/Qt5DragAndDrop.cxx | 4 ++-- vcl/qt5/Qt5Frame.cxx | 7 ++++--- vcl/qt5/Qt5Tools.cxx | 38 ++++++++++++++++++++++++++++++++++++++ vcl/qt5/Qt5Widget.cxx | 6 +++--- 7 files changed, 55 insertions(+), 10 deletions(-)
New commits: commit 66b352eca973c72bc40239591addabb5fd0b49c0 Author: Katarina Behrens <katarina.behr...@cib.de> AuthorDate: Thu Feb 28 15:03:12 2019 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Mar 13 00:02:50 2019 +0100 tdf#120783: take suggested/preferred DnD ops into account use those for drag operation start in Qt5Widget and eventually to construct DropTargetDragEnterEvent Change-Id: I3a92cbe722dadc64f8a210f7fd4016c8eb17216b Reviewed-on: https://gerrit.libreoffice.org/68675 Tested-by: Jenkins Reviewed-by: Katarina Behrens <katarina.behr...@cib.de> (cherry picked from commit c3751ed3c98e8ed40100a8073b97c83d9ded0803) Reviewed-on: https://gerrit.libreoffice.org/69122 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx index 669833f0ffd1..f3f8a38d761a 100644 --- a/vcl/inc/qt5/Qt5Frame.hxx +++ b/vcl/inc/qt5/Qt5Frame.hxx @@ -137,7 +137,8 @@ public: virtual void deregisterDragSource(Qt5DragSource const* pDragSource); virtual void registerDropTarget(Qt5DropTarget* pDropTarget); virtual void deregisterDropTarget(Qt5DropTarget const* pDropTarget); - void draggingStarted(const int x, const int y, const QMimeData* pQMimeData); + void draggingStarted(const int x, const int y, Qt::DropActions eActions, + const QMimeData* pQMimeData); void dropping(const int x, const int y, const QMimeData* pQMimeData); virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override; diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx index 57bf94793955..336a942c772b 100644 --- a/vcl/inc/qt5/Qt5Tools.hxx +++ b/vcl/inc/qt5/Qt5Tools.hxx @@ -30,6 +30,7 @@ #include <tools/gen.hxx> #include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> #include <memory> @@ -64,6 +65,10 @@ inline QColor toQColor(const Color& rColor) 255 - rColor.GetTransparency()); } +Qt::DropActions toQtDropActions(sal_Int8 dragOperation); +sal_Int8 toVclDropActions(Qt::DropActions dragOperation); +Qt::DropAction getPreferredDropAction(sal_Int8 dragOperation); + inline QList<int> toQList(const css::uno::Sequence<sal_Int32>& aSequence) { QList<int> aList; diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx index 731498f11d13..a9b7a0b1934f 100644 --- a/vcl/inc/qt5/Qt5Widget.hxx +++ b/vcl/inc/qt5/Qt5Widget.hxx @@ -74,7 +74,7 @@ public slots: public: Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags()); Qt5Frame* m_pFrame; - void startDrag(); + void startDrag(sal_Int8 nSourceActions); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx index fcd65fe39049..adc7a94fa0c2 100644 --- a/vcl/qt5/Qt5DragAndDrop.cxx +++ b/vcl/qt5/Qt5DragAndDrop.cxx @@ -128,7 +128,7 @@ void Qt5DragSource::initialize(const css::uno::Sequence<css::uno::Any>& rArgumen } void Qt5DragSource::startDrag( - const datatransfer::dnd::DragGestureEvent& /*rEvent*/, sal_Int8 /*sourceActions*/, + const datatransfer::dnd::DragGestureEvent& /*rEvent*/, sal_Int8 sourceActions, sal_Int32 /*cursor*/, sal_Int32 /*image*/, const css::uno::Reference<css::datatransfer::XTransferable>& rTrans, const css::uno::Reference<css::datatransfer::dnd::XDragSourceListener>& rListener) @@ -140,7 +140,7 @@ void Qt5DragSource::startDrag( { Qt5Widget* qw = static_cast<Qt5Widget*>(m_pFrame->GetQWidget()); m_ActiveDragSource = this; - qw->startDrag(); + qw->startDrag(sourceActions); } else dragFailed(); diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index acf7c6da7266..27f331ce2f05 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -1078,7 +1078,8 @@ void Qt5Frame::deregisterDropTarget(Qt5DropTarget const* pDropTarget) m_pDropTarget = nullptr; } -void Qt5Frame::draggingStarted(const int x, const int y, const QMimeData* pQMimeData) +void Qt5Frame::draggingStarted(const int x, const int y, Qt::DropActions eActions, + const QMimeData* pQMimeData) { assert(m_pDropTarget); @@ -1087,8 +1088,8 @@ void Qt5Frame::draggingStarted(const int x, const int y, const QMimeData* pQMime aEvent.Context = static_cast<css::datatransfer::dnd::XDropTargetDragContext*>(m_pDropTarget); aEvent.LocationX = x; aEvent.LocationY = y; - aEvent.DropAction = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; - aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; + aEvent.DropAction = getPreferredDropAction(eActions); + aEvent.SourceActions = toVclDropActions(eActions); css::uno::Reference<css::datatransfer::XTransferable> xTransferable; if (pQMimeData) diff --git a/vcl/qt5/Qt5Tools.cxx b/vcl/qt5/Qt5Tools.cxx index 54ac3f99e26f..94bb03d1797f 100644 --- a/vcl/qt5/Qt5Tools.cxx +++ b/vcl/qt5/Qt5Tools.cxx @@ -51,4 +51,42 @@ sal_uInt16 GetMouseModCode(Qt::MouseButtons eButtons) return nCode; } +Qt::DropActions toQtDropActions(sal_Int8 dragOperation) +{ + Qt::DropActions eRet = Qt::IgnoreAction; + if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_COPY) + eRet |= Qt::CopyAction; + if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_MOVE) + eRet |= Qt::MoveAction; + if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_LINK) + eRet |= Qt::LinkAction; + return eRet; +} + +sal_Int8 toVclDropActions(Qt::DropActions dragOperation) +{ + sal_Int8 nRet(0); + if (dragOperation & Qt::CopyAction) + nRet |= css::datatransfer::dnd::DNDConstants::ACTION_COPY; + if (dragOperation & Qt::MoveAction) + nRet |= css::datatransfer::dnd::DNDConstants::ACTION_MOVE; + if (dragOperation & Qt::LinkAction) + nRet |= css::datatransfer::dnd::DNDConstants::ACTION_LINK; + return nRet; +} + +Qt::DropAction getPreferredDropAction(sal_Int8 dragOperation) +{ + Qt::DropAction eAct = Qt::IgnoreAction; + + if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_MOVE) + eAct = Qt::MoveAction; + else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_COPY) + eAct = Qt::CopyAction; + else if (dragOperation & css::datatransfer::dnd::DNDConstants::ACTION_LINK) + eAct = Qt::LinkAction; + + return eAct; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 6d44262b38e8..4335a2bcff76 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -188,7 +188,7 @@ void Qt5Widget::wheelEvent(QWheelEvent* pEvent) pEvent->accept(); } -void Qt5Widget::startDrag() +void Qt5Widget::startDrag(sal_Int8 nSourceActions) { // internal drag source QMimeData* mimeData = new QMimeData; @@ -196,7 +196,7 @@ void Qt5Widget::startDrag() QDrag* drag = new QDrag(this); drag->setMimeData(mimeData); - drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction); + drag->exec(toQtDropActions(nSourceActions), Qt::MoveAction); } void Qt5Widget::dragEnterEvent(QDragEnterEvent* event) @@ -211,7 +211,7 @@ void Qt5Widget::dragMoveEvent(QDragMoveEvent* event) { QPoint point = event->pos(); - m_pFrame->draggingStarted(point.x(), point.y(), event->mimeData()); + m_pFrame->draggingStarted(point.x(), point.y(), event->possibleActions(), event->mimeData()); QWidget::dragMoveEvent(event); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits