summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-06-07 19:10:53 +0200
committerLiang Qi <liang.qi@qt.io>2018-06-07 19:10:53 +0200
commit096e37910d93f9c52976600e985c615ea36fe291 (patch)
tree713d020f4a04f03d8ca6e111055e7eebe85953a8 /src/gui/kernel
parent88eda007a3b5046999dd0b287634765efcd8934d (diff)
parenta14a943f9ac3d1e85514d7fb6688c84e624ac850 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: .qmake.conf src/corelib/kernel/qeventdispatcher_cf.mm src/gui/kernel/qguiapplication_p.h src/gui/kernel/qwindowsysteminterface.cpp src/gui/kernel/qwindowsysteminterface.h src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/cocoa/qnswindowdelegate.mm src/plugins/platforms/ios/qioseventdispatcher.mm src/plugins/platforms/windows/qwindowsdrag.h src/plugins/platforms/windows/qwindowsinternalmimedata.h src/plugins/platforms/windows/qwindowsmime.cpp src/plugins/platforms/winrt/qwinrtscreen.cpp Change-Id: Ic817f265c2386e83839d2bb9ef7419cb29705246
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/kernel.pri27
-rw-r--r--src/gui/kernel/qdnd.cpp217
-rw-r--r--src/gui/kernel/qdnd_p.h41
-rw-r--r--src/gui/kernel/qdrag.cpp4
-rw-r--r--src/gui/kernel/qdrag.h6
-rw-r--r--src/gui/kernel/qevent.cpp19
-rw-r--r--src/gui/kernel/qevent.h4
-rw-r--r--src/gui/kernel/qguiapplication.cpp13
-rw-r--r--src/gui/kernel/qguiapplication_p.h10
-rw-r--r--src/gui/kernel/qinternalmimedata.cpp234
-rw-r--r--src/gui/kernel/qinternalmimedata_p.h93
-rw-r--r--src/gui/kernel/qplatformcursor.cpp2
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp6
-rw-r--r--src/gui/kernel/qplatformdrag.cpp3
-rw-r--r--src/gui/kernel/qplatformdrag.h6
-rw-r--r--src/gui/kernel/qplatformintegration.cpp7
-rw-r--r--src/gui/kernel/qplatformintegration.h2
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow_p.h2
-rw-r--r--src/gui/kernel/qsimpledrag.cpp4
-rw-r--r--src/gui/kernel/qsimpledrag_p.h6
-rw-r--r--src/gui/kernel/qwindow.cpp8
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp9
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h4
23 files changed, 411 insertions, 316 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 792ca9fbaf..3b9afdfe8b 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -13,7 +13,6 @@ HEADERS += \
kernel/qwindowsysteminterface.h \
kernel/qwindowsysteminterface_p.h \
kernel/qplatformintegration.h \
- kernel/qplatformdrag.h \
kernel/qplatformscreen.h \
kernel/qplatformscreen_p.h \
kernel/qplatforminputcontext.h \
@@ -33,8 +32,6 @@ HEADERS += \
kernel/qplatformclipboard.h \
kernel/qplatformnativeinterface.h \
kernel/qplatformmenu.h \
- kernel/qshapedpixmapdndwindow_p.h \
- kernel/qsimpledrag_p.h \
kernel/qsurfaceformat.h \
kernel/qguiapplication.h \
kernel/qguiapplication_p.h \
@@ -46,12 +43,11 @@ HEADERS += \
kernel/qclipboard.h \
kernel/qcursor.h \
kernel/qcursor_p.h \
- kernel/qdrag.h \
- kernel/qdnd_p.h \
kernel/qevent.h \
kernel/qevent_p.h \
kernel/qinputmethod.h \
kernel/qinputmethod_p.h \
+ kernel/qinternalmimedata_p.h \
kernel/qkeysequence.h \
kernel/qkeysequence_p.h \
kernel/qkeymapper_p.h \
@@ -89,7 +85,6 @@ SOURCES += \
kernel/qplatforminputcontextplugin.cpp \
kernel/qplatforminputcontext.cpp \
kernel/qplatformintegration.cpp \
- kernel/qplatformdrag.cpp \
kernel/qplatformscreen.cpp \
kernel/qplatformintegrationfactory.cpp \
kernel/qplatformintegrationplugin.cpp \
@@ -102,8 +97,6 @@ SOURCES += \
kernel/qplatformclipboard.cpp \
kernel/qplatformnativeinterface.cpp \
kernel/qsessionmanager.cpp \
- kernel/qshapedpixmapdndwindow.cpp \
- kernel/qsimpledrag.cpp \
kernel/qsurfaceformat.cpp \
kernel/qguiapplication.cpp \
kernel/qwindow.cpp \
@@ -112,10 +105,9 @@ SOURCES += \
kernel/qsurface.cpp \
kernel/qclipboard.cpp \
kernel/qcursor.cpp \
- kernel/qdrag.cpp \
- kernel/qdnd.cpp \
kernel/qevent.cpp \
kernel/qinputmethod.cpp \
+ kernel/qinternalmimedata.cpp \
kernel/qkeysequence.cpp \
kernel/qkeymapper.cpp \
kernel/qpalette.cpp \
@@ -138,6 +130,21 @@ SOURCES += \
kernel/qinputdevicemanager.cpp \
kernel/qhighdpiscaling.cpp
+qtConfig(draganddrop) {
+ HEADERS += \
+ kernel/qdnd_p.h \
+ kernel/qdrag.h \
+ kernel/qplatformdrag.h \
+ kernel/qshapedpixmapdndwindow_p.h \
+ kernel/qsimpledrag_p.h
+
+ SOURCES += \
+ kernel/qdnd.cpp \
+ kernel/qdrag.cpp \
+ kernel/qplatformdrag.cpp \
+ kernel/qshapedpixmapdndwindow.cpp \
+ kernel/qsimpledrag.cpp
+}
qtConfig(opengl) {
HEADERS += \
diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp
index 3af7f5c181..5c5f166554 100644
--- a/src/gui/kernel/qdnd.cpp
+++ b/src/gui/kernel/qdnd.cpp
@@ -37,39 +37,19 @@
**
****************************************************************************/
-#include "qplatformdefs.h"
+#include "qdnd_p.h"
-#include "qbitmap.h"
-#include "qdrag.h"
-#include "qpixmap.h"
-#include "qevent.h"
-#include "qfile.h"
-#include "qtextcodec.h"
#include "qguiapplication.h"
-#include "qpoint.h"
-#include "qbuffer.h"
-#include "qimage.h"
-#include "qpainter.h"
-#include "qregexp.h"
-#include "qdir.h"
-#include "qdnd_p.h"
-#include "qimagereader.h"
-#include "qimagewriter.h"
-#include "qdebug.h"
#include <ctype.h>
-#include <qpa/qplatformintegration.h>
#include <qpa/qplatformdrag.h>
-
+#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
-#ifndef QT_NO_DRAGANDDROP
-
QT_BEGIN_NAMESPACE
// the universe's only drag manager
QDragManager *QDragManager::m_instance = 0;
-
QDragManager::QDragManager()
: QObject(qApp), m_currentDropTarget(0),
m_platformDrag(QGuiApplicationPrivate::platformIntegration()->drag()),
@@ -78,7 +58,6 @@ QDragManager::QDragManager()
Q_ASSERT(!m_instance);
}
-
QDragManager::~QDragManager()
{
m_instance = 0;
@@ -142,196 +121,4 @@ Qt::DropAction QDragManager::drag(QDrag *o)
return result;
}
-#endif // QT_NO_DRAGANDDROP
-
-#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
-
-static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats)
-{
- QStringList formats;
- formats.reserve(imageFormats.size());
- for (const auto &format : imageFormats)
- formats.append(QLatin1String("image/") + QLatin1String(format.toLower()));
-
- //put png at the front because it is best
- int pngIndex = formats.indexOf(QLatin1String("image/png"));
- if (pngIndex != -1 && pngIndex != 0)
- formats.move(pngIndex, 0);
-
- return formats;
-}
-
-static inline QStringList imageReadMimeFormats()
-{
- return imageMimeFormats(QImageReader::supportedImageFormats());
-}
-
-
-static inline QStringList imageWriteMimeFormats()
-{
- return imageMimeFormats(QImageWriter::supportedImageFormats());
-}
-
-QInternalMimeData::QInternalMimeData()
- : QMimeData()
-{
-}
-
-QInternalMimeData::~QInternalMimeData()
-{
-}
-
-bool QInternalMimeData::hasFormat(const QString &mimeType) const
-{
- bool foundFormat = hasFormat_sys(mimeType);
- if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) {
- QStringList imageFormats = imageReadMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- if ((foundFormat = hasFormat_sys(imageFormats.at(i))))
- break;
- }
- }
- return foundFormat;
-}
-
-QStringList QInternalMimeData::formats() const
-{
- QStringList realFormats = formats_sys();
- if (!realFormats.contains(QLatin1String("application/x-qt-image"))) {
- QStringList imageFormats = imageReadMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- if (realFormats.contains(imageFormats.at(i))) {
- realFormats += QLatin1String("application/x-qt-image");
- break;
- }
- }
- }
- return realFormats;
-}
-
-QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const
-{
- QVariant data = retrieveData_sys(mimeType, type);
- if (mimeType == QLatin1String("application/x-qt-image")) {
- if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) {
- // try to find an image
- QStringList imageFormats = imageReadMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- data = retrieveData_sys(imageFormats.at(i), type);
- if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty()))
- continue;
- break;
- }
- }
- // we wanted some image type, but all we got was a byte array. Convert it to an image.
- if (data.type() == QVariant::ByteArray
- && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap))
- data = QImage::fromData(data.toByteArray());
-
- } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) {
- QColor c;
- QByteArray ba = data.toByteArray();
- if (ba.size() == 8) {
- ushort * colBuf = (ushort *)ba.data();
- c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF),
- qreal(colBuf[1]) / qreal(0xFFFF),
- qreal(colBuf[2]) / qreal(0xFFFF),
- qreal(colBuf[3]) / qreal(0xFFFF));
- data = c;
- } else {
- qWarning("Qt: Invalid color format");
- }
- } else if (data.type() != type && data.type() == QVariant::ByteArray) {
- // try to use mime data's internal conversion stuf.
- QInternalMimeData *that = const_cast<QInternalMimeData *>(this);
- that->setData(mimeType, data.toByteArray());
- data = QMimeData::retrieveData(mimeType, type);
- that->clear();
- }
- return data;
-}
-
-bool QInternalMimeData::canReadData(const QString &mimeType)
-{
- return imageReadMimeFormats().contains(mimeType);
-}
-
-// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core.
-QStringList QInternalMimeData::formatsHelper(const QMimeData *data)
-{
- QStringList realFormats = data->formats();
- if (realFormats.contains(QLatin1String("application/x-qt-image"))) {
- // add all supported image formats
- QStringList imageFormats = imageWriteMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- if (!realFormats.contains(imageFormats.at(i)))
- realFormats.append(imageFormats.at(i));
- }
- }
- return realFormats;
-}
-
-bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data)
-{
-
- bool foundFormat = data->hasFormat(mimeType);
- if (!foundFormat) {
- if (mimeType == QLatin1String("application/x-qt-image")) {
- // check all supported image formats
- QStringList imageFormats = imageWriteMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- if ((foundFormat = data->hasFormat(imageFormats.at(i))))
- break;
- }
- } else if (mimeType.startsWith(QLatin1String("image/"))) {
- return data->hasImage() && imageWriteMimeFormats().contains(mimeType);
- }
- }
- return foundFormat;
-}
-
-QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data)
-{
- QByteArray ba;
- if (mimeType == QLatin1String("application/x-color")) {
- /* QMimeData can only provide colors as QColor or the name
- of a color as a QByteArray or a QString. So we need to do
- the conversion to application/x-color here.
- The application/x-color format is :
- type: application/x-color
- format: 16
- data[0]: red
- data[1]: green
- data[2]: blue
- data[3]: opacity
- */
- ba.resize(8);
- ushort * colBuf = (ushort *)ba.data();
- QColor c = qvariant_cast<QColor>(data->colorData());
- colBuf[0] = ushort(c.redF() * 0xFFFF);
- colBuf[1] = ushort(c.greenF() * 0xFFFF);
- colBuf[2] = ushort(c.blueF() * 0xFFFF);
- colBuf[3] = ushort(c.alphaF() * 0xFFFF);
- } else {
- ba = data->data(mimeType);
- if (ba.isEmpty()) {
- if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) {
- QImage image = qvariant_cast<QImage>(data->imageData());
- QBuffer buf(&ba);
- buf.open(QBuffer::WriteOnly);
- // would there not be PNG ??
- image.save(&buf, "PNG");
- } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) {
- QImage image = qvariant_cast<QImage>(data->imageData());
- QBuffer buf(&ba);
- buf.open(QBuffer::WriteOnly);
- image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper());
- }
- }
- }
- return ba;
-}
-
-#endif // QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD
-
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h
index e7d83cbbaf..cc00bc1442 100644
--- a/src/gui/kernel/qdnd_p.h
+++ b/src/gui/kernel/qdnd_p.h
@@ -62,41 +62,16 @@
#include "QtCore/qpoint.h"
#include "private/qobject_p.h"
#include "QtGui/qbackingstore.h"
-QT_BEGIN_NAMESPACE
-
-class QEventLoop;
-class QMouseEvent;
-class QPlatformDrag;
-
-#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
-
-class Q_GUI_EXPORT QInternalMimeData : public QMimeData
-{
- Q_OBJECT
-public:
- QInternalMimeData();
- ~QInternalMimeData();
-
- bool hasFormat(const QString &mimeType) const override;
- QStringList formats() const override;
- static bool canReadData(const QString &mimeType);
+// ### Remove the following include, once everybody includes
+// qinternalmimedata_p.h for QInternalMimeData.
+#include "qinternalmimedata_p.h"
- static QStringList formatsHelper(const QMimeData *data);
- static bool hasFormatHelper(const QString &mimeType, const QMimeData *data);
- static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data);
+QT_REQUIRE_CONFIG(draganddrop);
-protected:
- QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override;
-
- virtual bool hasFormat_sys(const QString &mimeType) const = 0;
- virtual QStringList formats_sys() const = 0;
- virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0;
-};
-
-#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
+QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DRAGANDDROP
+class QPlatformDrag;
class QDragPrivate : public QObjectPrivate
{
@@ -142,10 +117,6 @@ private:
Q_DISABLE_COPY(QDragManager)
};
-
-#endif // !QT_NO_DRAGANDDROP
-
-
QT_END_NAMESPACE
#endif // QDND_P_H
diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp
index 982c9e7659..bb0e490aa0 100644
--- a/src/gui/kernel/qdrag.cpp
+++ b/src/gui/kernel/qdrag.cpp
@@ -45,8 +45,6 @@
#include <qpoint.h>
#include "qdnd_p.h"
-#ifndef QT_NO_DRAGANDDROP
-
QT_BEGIN_NAMESPACE
/*!
@@ -420,5 +418,3 @@ void QDrag::cancel()
*/
QT_END_NAMESPACE
-
-#endif // QT_NO_DRAGANDDROP
diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h
index a8288e1b53..27b9c2c88f 100644
--- a/src/gui/kernel/qdrag.h
+++ b/src/gui/kernel/qdrag.h
@@ -43,10 +43,10 @@
#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(draganddrop);
+QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DRAGANDDROP
class QMimeData;
class QDragPrivate;
class QPixmap;
@@ -95,8 +95,6 @@ private:
Q_DISABLE_COPY(QDrag)
};
-#endif // QT_NO_DRAGANDDROP
-
QT_END_NAMESPACE
#endif // QDRAG_H
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 2e2e6b8301..e8f3cdd504 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -42,16 +42,19 @@
#include "private/qguiapplication_p.h"
#include "private/qtouchdevice_p.h"
#include "qpa/qplatformintegration.h"
-#include "qpa/qplatformdrag.h"
#include "private/qevent_p.h"
#include "qfile.h"
#include "qhashfunctions.h"
#include "qmetaobject.h"
#include "qmimedata.h"
-#include "private/qdnd_p.h"
#include "qevent_p.h"
#include "qmath.h"
+#if QT_CONFIG(draganddrop)
+#include <qpa/qplatformdrag.h>
+#include <private/qdnd_p.h>
+#endif
+
#include <private/qdebug_p.h>
QT_BEGIN_NAMESPACE
@@ -2920,7 +2923,7 @@ const QTouchDevice *QNativeGestureEvent::device() const
*/
#endif // QT_NO_GESTURES
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
/*!
Creates a QDragMoveEvent of the required \a type indicating
that the mouse is at position \a pos given within a widget.
@@ -3264,7 +3267,7 @@ QDragLeaveEvent::QDragLeaveEvent()
QDragLeaveEvent::~QDragLeaveEvent()
{
}
-#endif // QT_NO_DRAGANDDROP
+#endif // QT_CONFIG(draganddrop)
/*!
\class QHelpEvent
@@ -3939,7 +3942,7 @@ static const char *eventClassName(QEvent::Type t)
return "QEvent";
}
-# ifndef QT_NO_DRAGANDDROP
+# if QT_CONFIG(draganddrop)
static void formatDropEvent(QDebug d, const QDropEvent *e)
{
@@ -3960,7 +3963,7 @@ static void formatDropEvent(QDebug d, const QDropEvent *e)
QtDebugUtils::formatQFlags(d, e->mouseButtons());
}
-# endif // !QT_NO_DRAGANDDROP
+# endif // QT_CONFIG(draganddrop)
# if QT_CONFIG(tabletevent)
@@ -4123,13 +4126,13 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
dbg << ')';
}
break;
-# ifndef QT_NO_DRAGANDDROP
+# if QT_CONFIG(draganddrop)
case QEvent::DragEnter:
case QEvent::DragMove:
case QEvent::Drop:
formatDropEvent(dbg, static_cast<const QDropEvent *>(e));
break;
-# endif // !QT_NO_DRAGANDDROP
+# endif // QT_CONFIG(draganddrop)
case QEvent::InputMethod:
formatInputMethodEvent(dbg, static_cast<const QInputMethodEvent *>(e));
break;
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 2a47afaa0b..8d2f225809 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -602,7 +602,7 @@ Q_DECLARE_TYPEINFO(QInputMethodQueryEvent::QueryPair, Q_MOVABLE_TYPE);
#endif // QT_NO_INPUTMETHOD
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
class QMimeData;
@@ -675,7 +675,7 @@ public:
QDragLeaveEvent();
~QDragLeaveEvent();
};
-#endif // QT_NO_DRAGANDDROP
+#endif // QT_CONFIG(draganddrop)
class Q_GUI_EXPORT QHelpEvent : public QEvent
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index d1655da478..1ebdde3426 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -50,7 +50,6 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformtheme.h>
#include <qpa/qplatformintegration.h>
-#include <qpa/qplatformdrag.h>
#include <QtCore/QAbstractEventDispatcher>
#include <QtCore/QStandardPaths>
@@ -87,9 +86,13 @@
#include "private/qinputdevicemanager_p.h"
#include "private/qtouchdevice_p.h"
-#include "private/qdnd_p.h"
#include <qpa/qplatformthemefactory_p.h>
+#if QT_CONFIG(draganddrop)
+#include <qpa/qplatformdrag.h>
+#include <private/qdnd_p.h>
+#endif
+
#ifndef QT_NO_CURSOR
#include <qpa/qplatformcursor.h>
#endif
@@ -3037,7 +3040,7 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E
QCoreApplication::sendSpontaneousEvent(window, &exposeEvent);
}
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
/*! \internal
@@ -3146,7 +3149,7 @@ QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QM
return response;
}
-#endif // QT_NO_DRAGANDDROP
+#endif // QT_CONFIG(draganddrop)
#ifndef QT_NO_CLIPBOARD
/*!
@@ -3962,7 +3965,7 @@ void QGuiApplicationPrivate::notifyThemeChanged()
}
}
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag)
{
Q_UNUSED(drag)
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index fb7dda10a9..b7ee9f86b5 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -70,9 +70,9 @@ class QColorProfile;
class QPlatformIntegration;
class QPlatformTheme;
class QPlatformDragQtResponse;
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
class QDrag;
-#endif // QT_NO_DRAGANDDROP
+#endif // QT_CONFIG(draganddrop)
class QInputDeviceManager;
class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
@@ -162,7 +162,7 @@ public:
static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e);
#endif
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData,
const QPoint &p, Qt::DropActions supportedActions,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
@@ -313,9 +313,9 @@ public:
protected:
virtual void notifyThemeChanged();
bool tryCloseRemainingWindows(QWindowList processedWindows);
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
virtual void notifyDragStarted(const QDrag *);
-#endif // QT_NO_DRAGANDDROP
+#endif // QT_CONFIG(draganddrop)
private:
friend class QDragManager;
diff --git a/src/gui/kernel/qinternalmimedata.cpp b/src/gui/kernel/qinternalmimedata.cpp
new file mode 100644
index 0000000000..8f4da1afb5
--- /dev/null
+++ b/src/gui/kernel/qinternalmimedata.cpp
@@ -0,0 +1,234 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qinternalmimedata_p.h"
+
+#include <QtCore/qbuffer.h>
+#include <QtGui/qimage.h>
+#include <QtGui/qimagereader.h>
+#include <QtGui/qimagewriter.h>
+
+QT_BEGIN_NAMESPACE
+
+static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats)
+{
+ QStringList formats;
+ formats.reserve(imageFormats.size());
+ for (const auto &format : imageFormats)
+ formats.append(QLatin1String("image/") + QLatin1String(format.toLower()));
+
+ //put png at the front because it is best
+ int pngIndex = formats.indexOf(QLatin1String("image/png"));
+ if (pngIndex != -1 && pngIndex != 0)
+ formats.move(pngIndex, 0);
+
+ return formats;
+}
+
+static inline QStringList imageReadMimeFormats()
+{
+ return imageMimeFormats(QImageReader::supportedImageFormats());
+}
+
+static inline QStringList imageWriteMimeFormats()
+{
+ return imageMimeFormats(QImageWriter::supportedImageFormats());
+}
+
+QInternalMimeData::QInternalMimeData()
+ : QMimeData()
+{
+}
+
+QInternalMimeData::~QInternalMimeData()
+{
+}
+
+bool QInternalMimeData::hasFormat(const QString &mimeType) const
+{
+ bool foundFormat = hasFormat_sys(mimeType);
+ if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) {
+ QStringList imageFormats = imageReadMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ if ((foundFormat = hasFormat_sys(imageFormats.at(i))))
+ break;
+ }
+ }
+ return foundFormat;
+}
+
+QStringList QInternalMimeData::formats() const
+{
+ QStringList realFormats = formats_sys();
+ if (!realFormats.contains(QLatin1String("application/x-qt-image"))) {
+ QStringList imageFormats = imageReadMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ if (realFormats.contains(imageFormats.at(i))) {
+ realFormats += QLatin1String("application/x-qt-image");
+ break;
+ }
+ }
+ }
+ return realFormats;
+}
+
+QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const
+{
+ QVariant data = retrieveData_sys(mimeType, type);
+ if (mimeType == QLatin1String("application/x-qt-image")) {
+ if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) {
+ // try to find an image
+ QStringList imageFormats = imageReadMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ data = retrieveData_sys(imageFormats.at(i), type);
+ if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty()))
+ continue;
+ break;
+ }
+ }
+ // we wanted some image type, but all we got was a byte array. Convert it to an image.
+ if (data.type() == QVariant::ByteArray
+ && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap))
+ data = QImage::fromData(data.toByteArray());
+
+ } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) {
+ QColor c;
+ QByteArray ba = data.toByteArray();
+ if (ba.size() == 8) {
+ ushort * colBuf = (ushort *)ba.data();
+ c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF),
+ qreal(colBuf[1]) / qreal(0xFFFF),
+ qreal(colBuf[2]) / qreal(0xFFFF),
+ qreal(colBuf[3]) / qreal(0xFFFF));
+ data = c;
+ } else {
+ qWarning("Qt: Invalid color format");
+ }
+ } else if (data.type() != type && data.type() == QVariant::ByteArray) {
+ // try to use mime data's internal conversion stuf.
+ QInternalMimeData *that = const_cast<QInternalMimeData *>(this);
+ that->setData(mimeType, data.toByteArray());
+ data = QMimeData::retrieveData(mimeType, type);
+ that->clear();
+ }
+ return data;
+}
+
+bool QInternalMimeData::canReadData(const QString &mimeType)
+{
+ return imageReadMimeFormats().contains(mimeType);
+}
+
+// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core.
+QStringList QInternalMimeData::formatsHelper(const QMimeData *data)
+{
+ QStringList realFormats = data->formats();
+ if (realFormats.contains(QLatin1String("application/x-qt-image"))) {
+ // add all supported image formats
+ QStringList imageFormats = imageWriteMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ if (!realFormats.contains(imageFormats.at(i)))
+ realFormats.append(imageFormats.at(i));
+ }
+ }
+ return realFormats;
+}
+
+bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data)
+{
+
+ bool foundFormat = data->hasFormat(mimeType);
+ if (!foundFormat) {
+ if (mimeType == QLatin1String("application/x-qt-image")) {
+ // check all supported image formats
+ QStringList imageFormats = imageWriteMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ if ((foundFormat = data->hasFormat(imageFormats.at(i))))
+ break;
+ }
+ } else if (mimeType.startsWith(QLatin1String("image/"))) {
+ return data->hasImage() && imageWriteMimeFormats().contains(mimeType);
+ }
+ }
+ return foundFormat;
+}
+
+QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data)
+{
+ QByteArray ba;
+ if (mimeType == QLatin1String("application/x-color")) {
+ /* QMimeData can only provide colors as QColor or the name
+ of a color as a QByteArray or a QString. So we need to do
+ the conversion to application/x-color here.
+ The application/x-color format is :
+ type: application/x-color
+ format: 16
+ data[0]: red
+ data[1]: green
+ data[2]: blue
+ data[3]: opacity
+ */
+ ba.resize(8);
+ ushort * colBuf = (ushort *)ba.data();
+ QColor c = qvariant_cast<QColor>(data->colorData());
+ colBuf[0] = ushort(c.redF() * 0xFFFF);
+ colBuf[1] = ushort(c.greenF() * 0xFFFF);
+ colBuf[2] = ushort(c.blueF() * 0xFFFF);
+ colBuf[3] = ushort(c.alphaF() * 0xFFFF);
+ } else {
+ ba = data->data(mimeType);
+ if (ba.isEmpty()) {
+ if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) {
+ QImage image = qvariant_cast<QImage>(data->imageData());
+ QBuffer buf(&ba);
+ buf.open(QBuffer::WriteOnly);
+ // would there not be PNG ??
+ image.save(&buf, "PNG");
+ } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) {
+ QImage image = qvariant_cast<QImage>(data->imageData());
+ QBuffer buf(&ba);
+ buf.open(QBuffer::WriteOnly);
+ image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper());
+ }
+ }
+ }
+ return ba;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qinternalmimedata_p.h b/src/gui/kernel/qinternalmimedata_p.h
new file mode 100644
index 0000000000..aa5e896323
--- /dev/null
+++ b/src/gui/kernel/qinternalmimedata_p.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QINTERNALMIMEDATA_P_H
+#define QINTERNALMIMEDATA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qmimedata.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
+#include <QtCore/qvariant.h>
+#include <QtGui/private/qtguiglobal_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QEventLoop;
+class QMouseEvent;
+class QPlatformDrag;
+
+class Q_GUI_EXPORT QInternalMimeData : public QMimeData
+{
+ Q_OBJECT
+public:
+ QInternalMimeData();
+ ~QInternalMimeData();
+
+ bool hasFormat(const QString &mimeType) const override;
+ QStringList formats() const override;
+ static bool canReadData(const QString &mimeType);
+
+
+ static QStringList formatsHelper(const QMimeData *data);
+ static bool hasFormatHelper(const QString &mimeType, const QMimeData *data);
+ static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data);
+
+protected:
+ QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override;
+
+ virtual bool hasFormat_sys(const QString &mimeType) const = 0;
+ virtual QStringList formats_sys() const = 0;
+ virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QINTERNALMIMEDATA_P_H
diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp
index df78e7d896..bab26f6028 100644
--- a/src/gui/kernel/qplatformcursor.cpp
+++ b/src/gui/kernel/qplatformcursor.cpp
@@ -549,7 +549,7 @@ void QPlatformCursorImage::createSystemCursor(int id)
void QPlatformCursorImage::set(Qt::CursorShape id)
{
QPlatformCursorImage *cursor = 0;
- if (id >= 0 && id <= Qt::LastCursor) {
+ if (unsigned(id) <= unsigned(Qt::LastCursor)) {
if (!systemCursorTable[id])
createSystemCursor(id);
cursor = systemCursorTable[id];
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index fbadb48f70..b456c1ca31 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -664,18 +664,18 @@ QStringList QFileDialogOptions::history() const
void QFileDialogOptions::setLabelText(QFileDialogOptions::DialogLabel label, const QString &text)
{
- if (label >= 0 && label < DialogLabelCount)
+ if (unsigned(label) < unsigned(DialogLabelCount))
d->labels[label] = text;
}
QString QFileDialogOptions::labelText(QFileDialogOptions::DialogLabel label) const
{
- return (label >= 0 && label < DialogLabelCount) ? d->labels[label] : QString();
+ return (unsigned(label) < unsigned(DialogLabelCount)) ? d->labels[label] : QString();
}
bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label)
{
- return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty();
+ return unsigned(label) < unsigned(DialogLabelCount) && !d->labels[label].isEmpty();
}
QUrl QFileDialogOptions::initialDirectory() const
diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp
index 3c23406a6b..b40ddcbfb8 100644
--- a/src/gui/kernel/qplatformdrag.cpp
+++ b/src/gui/kernel/qplatformdrag.cpp
@@ -46,7 +46,6 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DRAGANDDROP
#ifdef QDND_DEBUG
# include <QtCore/QDebug>
#endif
@@ -222,6 +221,4 @@ bool QPlatformDrag::ownsDragObject() const
return false;
}
-#endif // QT_NO_DRAGANDDROP
-
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h
index 54e6a667fe..9d4e352b4b 100644
--- a/src/gui/kernel/qplatformdrag.h
+++ b/src/gui/kernel/qplatformdrag.h
@@ -52,9 +52,9 @@
#include <QtGui/qtguiglobal.h>
#include <QtGui/QPixmap>
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(draganddrop);
-#ifndef QT_NO_DRAGANDDROP
+QT_BEGIN_NAMESPACE
class QMimeData;
class QMouseEvent;
@@ -112,8 +112,6 @@ private:
Q_DISABLE_COPY(QPlatformDrag)
};
-#endif // QT_NO_DRAGANDDROP
-
QT_END_NAMESPACE
#endif
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 2aaa4c8510..dfb8f60915 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -45,8 +45,11 @@
#include <qpa/qplatformtheme.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qpixmap_raster_p.h>
+
+#if QT_CONFIG(draganddrop)
#include <private/qdnd_p.h>
#include <private/qsimpledrag_p.h>
+#endif
#ifndef QT_NO_SESSIONMANAGER
# include <qpa/qplatformsessionmanager.h>
@@ -92,7 +95,7 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const
#endif
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
/*!
Accessor for the platform integration's drag object.
@@ -107,7 +110,7 @@ QPlatformDrag *QPlatformIntegration::drag() const
}
return drag;
}
-#endif
+#endif // QT_CONFIG(draganddrop)
QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
{
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index d88f818920..efb1481f6d 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -130,7 +130,7 @@ public:
#ifndef QT_NO_CLIPBOARD
virtual QPlatformClipboard *clipboard() const;
#endif
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
virtual QPlatformDrag *drag() const;
#endif
virtual QPlatformInputContext *inputContext() const;
diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h
index 477938867c..072e7c6aea 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow_p.h
+++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h
@@ -55,6 +55,8 @@
#include <QtGui/QRasterWindow>
#include <QtGui/QPixmap>
+QT_REQUIRE_CONFIG(draganddrop);
+
QT_BEGIN_NAMESPACE
class QShapedPixmapWindow : public QRasterWindow
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index ed96584597..35896514b0 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -68,8 +68,6 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DRAGANDDROP
-
Q_LOGGING_CATEGORY(lcDnd, "qt.gui.dnd")
static QWindow* topLevelAt(const QPoint &pos)
@@ -449,6 +447,4 @@ void QSimpleDrag::drop(const QPoint &nativeGlobalPos, Qt::MouseButtons buttons,
}
}
-#endif // QT_NO_DRAGANDDROP
-
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h
index 44b8ee2488..ddd32bc5a5 100644
--- a/src/gui/kernel/qsimpledrag_p.h
+++ b/src/gui/kernel/qsimpledrag_p.h
@@ -56,9 +56,9 @@
#include <QtCore/QObject>
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(draganddrop);
-#ifndef QT_NO_DRAGANDDROP
+QT_BEGIN_NAMESPACE
class QMouseEvent;
class QWindow;
@@ -136,8 +136,6 @@ protected:
virtual void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
};
-#endif // QT_NO_DRAGANDDROP
-
QT_END_NAMESPACE
#endif
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index ef00ce5adc..2258027979 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -55,7 +55,9 @@
# include "qaccessible.h"
#endif
#include "qhighdpiscaling_p.h"
+#if QT_CONFIG(draganddrop)
#include "qshapedpixmapdndwindow_p.h"
+#endif // QT_CONFIG(draganddrop)
#include <private/qevent_p.h>
@@ -383,7 +385,11 @@ void QWindowPrivate::setVisible(bool visible)
QGuiApplicationPrivate::hideModalWindow(q);
// QShapedPixmapWindow is used on some platforms for showing a drag pixmap, so don't block
// input to this window as it is performing a drag - QTBUG-63846
- } else if (visible && QGuiApplication::modalWindow() && !qobject_cast<QShapedPixmapWindow *>(q)) {
+ } else if (visible && QGuiApplication::modalWindow()
+#if QT_CONFIG(draganddrop)
+ && !qobject_cast<QShapedPixmapWindow *>(q)
+#endif // QT_CONFIG(draganddrop)
+ ) {
QGuiApplicationPrivate::updateBlockedStatus(q);
}
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index b0f09fcc3b..07ece5689e 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -43,12 +43,15 @@
#include "private/qevent_p.h"
#include "private/qtouchdevice_p.h"
#include <QAbstractEventDispatcher>
-#include <qpa/qplatformdrag.h>
#include <qpa/qplatformintegration.h>
#include <qdebug.h>
#include "qhighdpiscaling_p.h"
#include <QtCore/qscopedvaluerollback.h>
+#if QT_CONFIG(draganddrop)
+#include <qpa/qplatformdrag.h>
+#endif
+
QT_BEGIN_NAMESPACE
@@ -791,7 +794,7 @@ void QWindowSystemInterface::handleThemeChange(QWindow *window)
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
#if QT_DEPRECATED_SINCE(5, 11)
QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData,
const QPoint &p, Qt::DropActions supportedActions)
@@ -831,7 +834,7 @@ QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, cons
auto pos = QHighDpi::fromNativeLocalPosition(p, window);
return QGuiApplicationPrivate::processDrop(window, dropData, pos, supportedActions, buttons, modifiers);
}
-#endif // QT_NO_DRAGANDDROP
+#endif // QT_CONFIG(draganddrop)
/*!
\fn static QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result)
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index ea01fa5c47..6bf6ee645c 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -215,7 +215,7 @@ public:
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false);
-#ifndef QT_NO_DRAGANDDROP
+#if QT_CONFIG(draganddrop)
#if QT_DEPRECATED_SINCE(5, 11)
QT_DEPRECATED static QPlatformDragQtResponse handleDrag(QWindow *window, const QMimeData *dropData,
const QPoint &p, Qt::DropActions supportedActions);
@@ -228,7 +228,7 @@ public:
static QPlatformDropQtResponse handleDrop(QWindow *window, const QMimeData *dropData,
const QPoint &p, Qt::DropActions supportedActions,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
-#endif // QT_NO_DRAGANDDROP
+#endif // QT_CONFIG(draganddrop)
static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);