Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qandroidplatformdrag.h
Go to the documentation of this file.
1// Copyright (C) 2026 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QANDROIDPLATFORMDRAG_H
6#define QANDROIDPLATFORMDRAG_H
7
8#include <qpa/qplatformdrag.h>
9#include <QtCore/qjnitypes.h>
10#include <QtCore/qjniobject.h>
11#include <QtCore/qjniarray.h>
12#include <QtCore/qstringlist.h>
13
14#include <memory>
15
16#if QT_CONFIG(draganddrop)
17
18QT_BEGIN_NAMESPACE
19
20Q_DECLARE_JNI_CLASS(QtDragManager, "org/qtproject/qt/android/QtDragManager");
21
22class QEventLoop;
23class QJniEnvironment;
24class QMimeData;
25
26class QAndroidPlatformDrag : public QPlatformDrag
27{
28public:
29 QAndroidPlatformDrag();
30 ~QAndroidPlatformDrag();
31
32 Qt::DropAction drag(QDrag *drag) override;
33 void cancelDrag() override;
34 bool ownsDragObject() const override;
35
36 static bool registerNatives(QJniEnvironment &env);
37
38private:
39 static bool handleNativeDragEvent(jlong nativePointer, int viewId, int action, float x,
40 float y, const QStringList &mimeTypes,
41 const QStringList &clipData, bool result);
42 bool deliverDragEvent(int viewId, int action, float x, float y,
43 const QStringList &mimeTypes, const QStringList &clipData,
44 bool result);
45
46 static QString shareableUri(const QString &value);
47
48 static jboolean onDragEvent(JNIEnv *env, jobject obj, jlong nativePointer,
49 jint viewId, jint action, jfloat x, jfloat y,
50 QJniArray<QString> mimeTypes, QJniArray<QString> clipData,
51 jboolean result);
52 Q_DECLARE_JNI_NATIVE_METHOD_IN_CURRENT_SCOPE(onDragEvent)
53
54 QtJniTypes::QtDragManager m_dragManager = nullptr;
55 std::unique_ptr<QMimeData> m_externalMimeData; // Mime data for an incoming cross-process drag
56 Qt::DropAction m_executedAction = Qt::IgnoreAction;
57 QEventLoop *m_dragLoop = nullptr;
58
59 // The live drag handler, touched only on the Qt GUI thread.
60 static QAndroidPlatformDrag *s_currentDrag;
61};
62
63QT_END_NAMESPACE
64
65#endif // QT_CONFIG(draganddrop)
66
67#endif // QANDROIDPLATFORMDRAG_H