vcl/inc/qt5/Qt5DragAndDrop.hxx | 15 +++++++++ vcl/inc/qt5/Qt5Frame.hxx | 5 +-- vcl/qt5/Qt5Clipboard.cxx | 30 ------------------- vcl/qt5/Qt5DragAndDrop.cxx | 63 +++++++++++++++++++++++++++++++++++++++++ vcl/qt5/Qt5Frame.cxx | 14 ++++++--- vcl/qt5/Qt5Widget.cxx | 7 ++-- 6 files changed, 95 insertions(+), 39 deletions(-)
New commits: commit 18a451e4719a8205374478f1f58b09ac5fe63beb Author: Katarina Behrens <[email protected]> AuthorDate: Fri Jan 25 12:24:50 2019 +0100 Commit: Thorsten Behrens <[email protected]> CommitDate: Wed Feb 6 16:26:38 2019 +0100 tdf#120772: implement file manager -> LibO DnD not sure if we should support also other than URL list mimetypes Change-Id: Ida3f65637247822198b04682a3d1a7c196a24e0c Reviewed-on: https://gerrit.libreoffice.org/66997 Tested-by: Jenkins Reviewed-by: Katarina Behrens <[email protected]> (cherry picked from commit 67b0fcea9d748c4dd8101036cbb2c587d65f0bf7) -Werror,-Wunused-parameter Change-Id: I60b67eeabf5f11f0d3ad4de7b5ad11bc5851d474 loplugin:includeform Change-Id: I8ac8b1cbbf94f405ffef0037b6957b35d44a8f91 bodge to fix build Change-Id: Ia2363177e7187dfda9a1b326e5e110696b9a1697 Reviewed-on: https://gerrit.libreoffice.org/67441 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <[email protected]> diff --git a/vcl/inc/qt5/Qt5DragAndDrop.hxx b/vcl/inc/qt5/Qt5DragAndDrop.hxx index f5ffac3bb21e..099ba444ea15 100644 --- a/vcl/inc/qt5/Qt5DragAndDrop.hxx +++ b/vcl/inc/qt5/Qt5DragAndDrop.hxx @@ -11,6 +11,7 @@ #pragma once #include <cppuhelper/compbase.hxx> +#include "Qt5Clipboard.hxx" #include <com/sun/star/datatransfer/dnd/XDragSource.hpp> #include <com/sun/star/datatransfer/dnd/XDropTarget.hpp> @@ -18,6 +19,20 @@ #include <com/sun/star/lang/XServiceInfo.hpp> class Qt5Frame; +class QMimeData; + +class Qt5DnDTransferable : public Qt5Transferable +{ +public: + Qt5DnDTransferable(const QMimeData* pMimeData); + virtual css::uno::Any SAL_CALL + getTransferData(const css::datatransfer::DataFlavor& rFlavor) override; + + virtual std::vector<css::datatransfer::DataFlavor> getTransferDataFlavorsAsVector() override; + +private: + const QMimeData* m_pMimeData; +}; class Qt5DragSource : public cppu::WeakComponentImplHelper<css::datatransfer::dnd::XDragSource, diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx index e88c1ead3d85..669833f0ffd1 100644 --- a/vcl/inc/qt5/Qt5Frame.hxx +++ b/vcl/inc/qt5/Qt5Frame.hxx @@ -37,6 +37,7 @@ class QWidget; class Qt5MainWindow; class Qt5DragSource; class Qt5DropTarget; +class QMimeData; class QPaintDevice; class QScreen; class QImage; @@ -136,8 +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); - void dropping(const int x, const int y); + void draggingStarted(const int x, const int y, const QMimeData* pQMimeData); + void dropping(const int x, const int y, const QMimeData* pQMimeData); 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 092c2b2e10a6..9352eea1cc47 100644 --- a/vcl/qt5/Qt5DragAndDrop.cxx +++ b/vcl/qt5/Qt5DragAndDrop.cxx @@ -14,6 +14,9 @@ #include <cppuhelper/supportsservice.hxx> #include <sal/log.hxx> +#include <QtCore/QMimeData> +#include <QtCore/QUrl> + #include <Qt5DragAndDrop.hxx> #include <Qt5Frame.hxx> #include <Qt5Widget.hxx> @@ -22,6 +25,66 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::lang; +Qt5DnDTransferable::Qt5DnDTransferable(const QMimeData* pMimeData) + : Qt5Transferable(QClipboard::Clipboard) + , m_pMimeData(pMimeData) +{ +} + +css::uno::Any Qt5DnDTransferable::getTransferData(const css::datatransfer::DataFlavor&) +{ + uno::Any aAny; + assert(m_pMimeData); + + // FIXME: not sure if we should support more mimetypes here + // (how to carry out external DnD with anything else than [file] URL?) + if (m_pMimeData->hasUrls()) + { + QList<QUrl> urlList = m_pMimeData->urls(); + + if (urlList.size() > 0) + { + //FIXME: multiple URLs, here we take only 1st one + QString url = urlList.at(0).path(); + std::string aStr = url.toStdString(); + Sequence<sal_Int8> aSeq(reinterpret_cast<const sal_Int8*>(aStr.c_str()), aStr.length()); + aAny <<= aSeq; + } + } + return aAny; +} + +std::vector<css::datatransfer::DataFlavor> Qt5DnDTransferable::getTransferDataFlavorsAsVector() +{ + std::vector<css::datatransfer::DataFlavor> aVector; + css::datatransfer::DataFlavor aFlavor; + + if (m_pMimeData) + { + for (QString& rMimeType : m_pMimeData->formats()) + { + // filter out non-MIME types such as TARGETS, MULTIPLE, TIMESTAMP + if (rMimeType.indexOf('/') == -1) + continue; + + if (rMimeType.startsWith("text/plain")) + { + aFlavor.MimeType = "text/plain;charset=utf-16"; + aFlavor.DataType = cppu::UnoType<OUString>::get(); + aVector.push_back(aFlavor); + } + else + { + aFlavor.MimeType = toOUString(rMimeType); + aFlavor.DataType = cppu::UnoType<Sequence<sal_Int8>>::get(); + aVector.push_back(aFlavor); + } + } + } + + return aVector; +} + Qt5DragSource::~Qt5DragSource() { //if (m_pFrame) diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx index e3ced2dec236..55e0eea76ff7 100644 --- a/vcl/qt5/Qt5Frame.cxx +++ b/vcl/qt5/Qt5Frame.cxx @@ -1059,7 +1059,7 @@ void Qt5Frame::deregisterDropTarget(Qt5DropTarget const* pDropTarget) m_pDropTarget = nullptr; } -void Qt5Frame::draggingStarted(const int x, const int y) +void Qt5Frame::draggingStarted(const int x, const int y, const QMimeData* pQMimeData) { assert(m_pDropTarget); @@ -1072,7 +1072,10 @@ void Qt5Frame::draggingStarted(const int x, const int y) aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; css::uno::Reference<css::datatransfer::XTransferable> xTransferable; - xTransferable = Qt5DragSource::m_ActiveDragSource->GetTransferable(); + if (pQMimeData) + xTransferable = new Qt5DnDTransferable(pQMimeData); + else + xTransferable = Qt5DragSource::m_ActiveDragSource->GetTransferable(); if (!m_bInDrag && xTransferable.is()) { @@ -1087,7 +1090,7 @@ void Qt5Frame::draggingStarted(const int x, const int y) m_pDropTarget->fire_dragOver(aEvent); } -void Qt5Frame::dropping(const int x, const int y) +void Qt5Frame::dropping(const int x, const int y, const QMimeData* pQMimeData) { assert(m_pDropTarget); @@ -1101,7 +1104,10 @@ void Qt5Frame::dropping(const int x, const int y) aEvent.SourceActions = css::datatransfer::dnd::DNDConstants::ACTION_MOVE; css::uno::Reference<css::datatransfer::XTransferable> xTransferable; - xTransferable = Qt5DragSource::m_ActiveDragSource->GetTransferable(); + if (pQMimeData) + xTransferable = new Qt5DnDTransferable(pQMimeData); + else + xTransferable = Qt5DragSource::m_ActiveDragSource->GetTransferable(); aEvent.Transferable = xTransferable; m_pDropTarget->fire_drop(aEvent); diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx index 69ca329ab97f..394bcc1029e4 100644 --- a/vcl/qt5/Qt5Widget.cxx +++ b/vcl/qt5/Qt5Widget.cxx @@ -203,14 +203,15 @@ void Qt5Widget::dragEnterEvent(QDragEnterEvent* event) { if (event->mimeData()->hasFormat(m_InternalMimeType)) event->accept(); - // else FIXME: external drag source + else + event->acceptProposedAction(); } void Qt5Widget::dragMoveEvent(QDragMoveEvent* event) { QPoint point = event->pos(); - m_pFrame->draggingStarted(point.x(), point.y()); + m_pFrame->draggingStarted(point.x(), point.y(), event->mimeData()); QWidget::dragMoveEvent(event); } @@ -218,7 +219,7 @@ void Qt5Widget::dropEvent(QDropEvent* event) { QPoint point = event->pos(); - m_pFrame->dropping(point.x(), point.y()); + m_pFrame->dropping(point.x(), point.y(), event->mimeData()); QWidget::dropEvent(event); } commit 012e471393b41dae7fe6d35bbaf575f87e7c8470 Author: Aleksei Nikiforov <[email protected]> AuthorDate: Mon Jan 21 15:15:22 2019 +0300 Commit: Thorsten Behrens <[email protected]> CommitDate: Wed Feb 6 16:26:24 2019 +0100 tdf#120836 KDE5: Clipboard: don't put images to clipboard Image generation is very slow. Change-Id: I34d45ed1f4d665613700f01cceec59069b091a79 Reviewed-on: https://gerrit.libreoffice.org/66680 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <[email protected]> (cherry picked from commit c8b0c382c6330865df50ae7cf7360c8a2c08ebe6) Reviewed-on: https://gerrit.libreoffice.org/67411 diff --git a/vcl/qt5/Qt5Clipboard.cxx b/vcl/qt5/Qt5Clipboard.cxx index 7407e2b062b0..92bb3a89da3d 100644 --- a/vcl/qt5/Qt5Clipboard.cxx +++ b/vcl/qt5/Qt5Clipboard.cxx @@ -277,36 +277,6 @@ void VclQt5Clipboard::setContents( } } - // Add image data if present - if (bHasImage) - { - css::datatransfer::DataFlavor aFlavor; - //FIXME: other image formats? - aFlavor.MimeType = "image/png"; - aFlavor.DataType = cppu::UnoType<Sequence<sal_Int8>>::get(); - - Any aValue; - try - { - aValue = xTrans->getTransferData(aFlavor); - } - catch (...) - { - } - - if (aValue.getValueType() == cppu::UnoType<Sequence<sal_Int8>>::get()) - { - Sequence<sal_Int8> aData; - aValue >>= aData; - - QImage image; - image.loadFromData(reinterpret_cast<const uchar*>(aData.getConstArray()), - aData.getLength()); - - pMimeData->setImageData(image); - } - } - // Add text data // TODO: consider checking if text of suitable type is present { _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
