diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-10-12 16:19:07 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2018-10-18 20:37:41 +0200 |
commit | ac2b58cdae26375846f67bfbe7244e4a0fd306ba (patch) | |
tree | b7572adae26a7cbfcbc835d43ab3eff49f34e7fa /vcl | |
parent | 0585043a6f326a2e108a51bba251ce77ca6a2ea0 (diff) |
Implement drag'n'drop-related qt5 events, no-op so far
Change-Id: I67b8cecdc85ad77d7ab48d229459a79bc168072d
Reviewed-on: https://gerrit.libreoffice.org/61721
Tested-by: Jenkins
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/qt5/Qt5Widget.hxx | 4 | ||||
-rw-r--r-- | vcl/qt5/Qt5Widget.cxx | 36 |
2 files changed, 38 insertions, 2 deletions
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx index 101ae6d68f67..9d4d535d2e90 100644 --- a/vcl/inc/qt5/Qt5Widget.hxx +++ b/vcl/inc/qt5/Qt5Widget.hxx @@ -46,6 +46,9 @@ class Qt5Widget : public QWidget virtual void mouseMoveEvent(QMouseEvent*) override; virtual void mousePressEvent(QMouseEvent*) override; virtual void mouseReleaseEvent(QMouseEvent*) override; + virtual void dragEnterEvent(QDragEnterEvent*) override; + virtual void dragMoveEvent(QDragMoveEvent*) override; + virtual void dropEvent(QDropEvent*) override; virtual void moveEvent(QMoveEvent*) override; virtual void paintEvent(QPaintEvent*) override; virtual void resizeEvent(QResizeEvent*) override; @@ -56,6 +59,7 @@ class Qt5Widget : public QWidget public: Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f = Qt::WindowFlags()); Qt5Frame* m_pFrame; + void startDrag(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 00ab29744a67..5c4711afd065 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -124,10 +124,12 @@ void Qt5Widget::mouseReleaseEvent(QMouseEvent* pEvent) { handleMouseButtonEvent( void Qt5Widget::mouseMoveEvent(QMouseEvent* pEvent) { + QPoint point = pEvent->pos(); + SalMouseEvent aEvent; aEvent.mnTime = pEvent->timestamp(); - aEvent.mnX = pEvent->pos().x(); - aEvent.mnY = pEvent->pos().y(); + aEvent.mnX = point.x(); + aEvent.mnY = point.y(); aEvent.mnCode = GetKeyModCode(pEvent->modifiers()) | GetMouseModCode(pEvent->buttons()); aEvent.mnButton = 0; @@ -163,6 +165,35 @@ void Qt5Widget::wheelEvent(QWheelEvent* pEvent) pEvent->accept(); } +void Qt5Widget::startDrag() +{ + QMimeData* mimeData = new QMimeData; + mimeData->setData("application/x-libreoffice-dnditem", nullptr); + + QDrag* drag = new QDrag(this); + drag->setMimeData(mimeData); + drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::MoveAction); +} + +void Qt5Widget::dragEnterEvent(QDragEnterEvent* event) +{ + SAL_WARN("vcl.qt5", "dragenterevent"); + if (event->source() == this) + event->accept(); +} + +void Qt5Widget::dragMoveEvent(QDragMoveEvent* event) +{ + SAL_WARN("vcl.qt5", "dragmoveevent"); + QWidget::dragMoveEvent(event); +} + +void Qt5Widget::dropEvent(QDropEvent* event) +{ + SAL_WARN("vcl.qt5", "dropevent"); + QWidget::dropEvent(event); +} + void Qt5Widget::moveEvent(QMoveEvent*) { m_pFrame->CallCallback(SalEvent::Move, nullptr); } void Qt5Widget::showEvent(QShowEvent*) @@ -359,6 +390,7 @@ Qt5Widget::Qt5Widget(Qt5Frame& rFrame, Qt::WindowFlags f) { create(); setMouseTracking(true); + setAcceptDrops(true); setFocusPolicy(Qt::StrongFocus); } |