vcl/inc/qt5/Qt5DragAndDrop.hxx | 6 ++++++ vcl/inc/qt5/Qt5Frame.hxx | 2 ++ vcl/qt5/Qt5DragAndDrop.cxx | 23 +++++++++++++++++++++-- vcl/qt5/Qt5Frame.cxx | 31 +++++++++++++++++++++++++++++++ vcl/qt5/Qt5Widget.cxx | 3 +++ 5 files changed, 63 insertions(+), 2 deletions(-)
New commits: commit 5ebef042bd44e9babd58f53b4458616aa3215beb Author: Katarina Behrens <katarina.behr...@cib.de> AuthorDate: Mon Oct 15 14:44:29 2018 +0200 Commit: Katarina Behrens <katarina.behr...@cib.de> CommitDate: Fri Oct 19 10:05:00 2018 +0200 Kick-start beginning of drag event Change-Id: Iaad25a7acdc7d64013bc3dd0d9410e7d2d5c6762 Reviewed-on: https://gerrit.libreoffice.org/61791 Tested-by: Jenkins Reviewed-by: Katarina Behrens <katarina.behr...@cib.de> diff --git a/vcl/inc/qt5/Qt5DragAndDrop.hxx b/vcl/inc/qt5/Qt5DragAndDrop.hxx index 733cf4d03570..424a1ba638e4 100644 --- a/vcl/inc/qt5/Qt5DragAndDrop.hxx +++ b/vcl/inc/qt5/Qt5DragAndDrop.hxx @@ -57,6 +57,10 @@ public: css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; void dragFailed(); + css::uno::Reference<css::datatransfer::XTransferable> const& GetTransferable() const + { + return m_xTrans; + } }; class Qt5DropTarget @@ -102,6 +106,8 @@ public: OUString SAL_CALL getImplementationName() override; sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override; css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + void fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx index d3400f378d1f..9ee9f50666e9 100644 --- a/vcl/inc/qt5/Qt5Frame.hxx +++ b/vcl/inc/qt5/Qt5Frame.hxx @@ -75,6 +75,7 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame Qt5DragSource* m_pDragSource; Qt5DropTarget* m_pDropTarget; + bool m_bInDrag; bool m_bDefaultSize; bool m_bDefaultPos; @@ -133,6 +134,7 @@ 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); virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override; virtual void Show(bool bVisible, bool bNoActivate = false) override; diff --git a/vcl/qt5/Qt5DragAndDrop.cxx b/vcl/qt5/Qt5DragAndDrop.cxx index 6e83f6ff40fa..ac9a0fdb6339 100644 --- a/vcl/qt5/Qt5DragAndDrop.cxx +++ b/vcl/qt5/Qt5DragAndDrop.cxx @@ -16,6 +16,7 @@ #include <Qt5DragAndDrop.hxx> #include <Qt5Frame.hxx> +#include <Qt5Widget.hxx> using namespace com::sun::star; using namespace com::sun::star::uno; @@ -63,7 +64,12 @@ void Qt5DragSource::startDrag( m_xListener = rListener; m_xTrans = rTrans; - if (!m_pFrame) + if (m_pFrame) + { + Qt5Widget* qw = static_cast<Qt5Widget*>(m_pFrame->GetQWidget()); + qw->startDrag(); + } + else dragFailed(); } @@ -150,7 +156,7 @@ void Qt5DropTarget::initialize(const Sequence<Any>& rArguments) } m_pFrame = reinterpret_cast<Qt5Frame*>(nFrame); - //m_pFrame->registerDropTarget(this); + m_pFrame->registerDropTarget(this); m_bActive = true; } @@ -182,6 +188,19 @@ void Qt5DropTarget::setDefaultActions(sal_Int8 nDefaultActions) m_nDefaultActions = nDefaultActions; } +void Qt5DropTarget::fire_dragEnter(const css::datatransfer::dnd::DropTargetDragEnterEvent& dtde) +{ + osl::ClearableGuard<::osl::Mutex> aGuard(m_aMutex); + std::vector<css::uno::Reference<css::datatransfer::dnd::XDropTargetListener>> aListeners( + m_aListeners); + aGuard.clear(); + + for (auto const& listener : aListeners) + { + listener->dragEnter(dtde); + } +} + void Qt5DropTarget::acceptDrag(sal_Int8 /*dragOperation*/) { return; } void Qt5DropTarget::rejectDrag() { return; } diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index ae3ae325ccd2..bbf541dea312 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -46,6 +46,8 @@ #include <vcl/layout.hxx> #include <vcl/syswin.hxx> +#include <com/sun/star/datatransfer/dnd/DNDConstants.hpp> + #include <cairo.h> #include <headless/svpgdi.hxx> @@ -63,6 +65,9 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nStyle, bool bUseCairo) , m_bNullRegion(true) , m_bGraphicsInUse(false) , m_ePointerStyle(PointerStyle::Arrow) + , m_pDragSource(nullptr) + , m_pDropTarget(nullptr) + , m_bInDrag(false) , m_bDefaultSize(true) , m_bDefaultPos(true) { @@ -870,4 +875,30 @@ void Qt5Frame::deregisterDropTarget(Qt5DropTarget const* pDropTarget) m_pDropTarget = nullptr; } +void Qt5Frame::draggingStarted(const int x, const int y) +{ + assert(m_pDropTarget); + + 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 = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; //FIXME + aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; + + css::uno::Reference<css::datatransfer::XTransferable> xTransferable; + xTransferable = m_pDragSource->GetTransferable(); + + if (!m_bInDrag && xTransferable.is()) + { + css::uno::Sequence<css::datatransfer::DataFlavor> aFormats + = xTransferable->getTransferDataFlavors(); + aEvent.SupportedDataFlavors = aFormats; + + m_pDropTarget->fire_dragEnter(aEvent); + m_bInDrag = true; + } +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 5c4711afd065..33b5faf8a9a2 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -184,7 +184,10 @@ void Qt5Widget::dragEnterEvent(QDragEnterEvent* event) void Qt5Widget::dragMoveEvent(QDragMoveEvent* event) { + QPoint point = event->pos(); SAL_WARN("vcl.qt5", "dragmoveevent"); + + m_pFrame->draggingStarted(point.x(), point.y()); QWidget::dragMoveEvent(event); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits