summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/Qt5DragAndDrop.cxx23
-rw-r--r--vcl/qt5/Qt5Frame.cxx31
-rw-r--r--vcl/qt5/Qt5Widget.cxx3
3 files changed, 55 insertions, 2 deletions
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);
}