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
qsimpledrag_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QSIMPLEDRAG_P_H
6#define QSIMPLEDRAG_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/private/qtguiglobal_p.h>
20#include <qpa/qplatformdrag.h>
21
22#include <QtCore/QObject>
23#include <QtCore/QPointer>
24#include <QtGui/qdrag.h>
25#include <QtGui/QWindow>
26
28
29QT_BEGIN_NAMESPACE
30
31class QMouseEvent;
32class QEventLoop;
33class QDropData;
34class QShapedPixmapWindow;
35class QScreen;
36
37class Q_GUI_EXPORT QBasicDrag : public QPlatformDrag, public QObject
38{
39public:
40 ~QBasicDrag();
41
42 virtual Qt::DropAction drag(QDrag *drag) override;
43 void cancelDrag() override;
44
45 virtual bool eventFilter(QObject *o, QEvent *e) override;
46
47protected:
48 QBasicDrag();
49
50 virtual void startDrag();
51 virtual void cancel();
52 virtual void move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) = 0;
53 virtual void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) = 0;
54 virtual void endDrag();
55
56
57 void moveShapedPixmapWindow(const QPoint &deviceIndependentPosition);
58 QShapedPixmapWindow *shapedPixmapWindow() const { return m_drag_icon_window; }
59 void recreateShapedPixmapWindow(QScreen *screen, const QPoint &pos);
60 void updateCursor(Qt::DropAction action);
61
62 bool canDrop() const { return m_can_drop; }
63 void setCanDrop(bool c) { m_can_drop = c; }
64
65 bool useCompositing() const { return m_useCompositing; }
66 void setUseCompositing(bool on) { m_useCompositing = on; }
67
68 void setScreen(QScreen *screen) { m_screen = screen; }
69
70 Qt::DropAction executedDropAction() const { return m_executed_drop_action; }
71 void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; }
72
73 QDrag *drag() const { return m_drag; }
74
75protected:
76 QWindow *m_sourceWindow = nullptr;
77 QPointer<QWindow> m_windowUnderCursor = nullptr;
78
79private:
80 void enableEventFilter();
81 void disableEventFilter();
82 void restoreCursor();
83 void exitDndEventLoop();
84
85#ifndef QT_NO_CURSOR
86 bool m_dndHasSetOverrideCursor = false;
87#endif
88 QEventLoop *m_eventLoop = nullptr;
89 Qt::DropAction m_executed_drop_action = Qt::IgnoreAction;
90 bool m_can_drop = false;
91 bool m_dragEndRequested = false;
92 QPointer<QDrag> m_drag;
93 QShapedPixmapWindow *m_drag_icon_window = nullptr;
94 bool m_useCompositing = true;
95 QScreen *m_screen = nullptr;
96 QPoint m_lastPos;
97};
98
99class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag
100{
101public:
102 QSimpleDrag();
103
104protected:
105 virtual void startDrag() override;
106 virtual void cancel() override;
107 virtual void move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
108 virtual void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
109};
110
111QT_END_NAMESPACE
112
113#endif
QBasicDrag is a base class for implementing platform drag and drop.
\inmodule QtCore\reentrant
Definition qpoint.h:30
QSimpleDrag implements QBasicDrag for Drag and Drop operations within the Qt Application itself.
Combined button and popup list for selecting options.
#define qApp
QT_REQUIRE_CONFIG(draganddrop)
static QPoint fromNativeGlobalPixels(const QPoint &point)
static void sendDragLeave(QWindow *window)
static QPoint getNativeMousePos(QEvent *e, QWindow *window)