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/QWindow>
25
27
28QT_BEGIN_NAMESPACE
29
30class QMouseEvent;
31class QEventLoop;
32class QDropData;
33class QShapedPixmapWindow;
34class QScreen;
35
36class Q_GUI_EXPORT QBasicDrag : public QPlatformDrag, public QObject
37{
38public:
39 ~QBasicDrag();
40
41 virtual Qt::DropAction drag(QDrag *drag) override;
42 void cancelDrag() override;
43
44 virtual bool eventFilter(QObject *o, QEvent *e) override;
45
46protected:
47 QBasicDrag();
48
49 virtual void startDrag();
50 virtual void cancel();
51 virtual void move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) = 0;
52 virtual void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) = 0;
53 virtual void endDrag();
54
55
56 void moveShapedPixmapWindow(const QPoint &deviceIndependentPosition);
57 QShapedPixmapWindow *shapedPixmapWindow() const { return m_drag_icon_window; }
58 void recreateShapedPixmapWindow(QScreen *screen, const QPoint &pos);
59 void updateCursor(Qt::DropAction action);
60
61 bool canDrop() const { return m_can_drop; }
62 void setCanDrop(bool c) { m_can_drop = c; }
63
64 bool useCompositing() const { return m_useCompositing; }
65 void setUseCompositing(bool on) { m_useCompositing = on; }
66
67 void setScreen(QScreen *screen) { m_screen = screen; }
68
69 Qt::DropAction executedDropAction() const { return m_executed_drop_action; }
70 void setExecutedDropAction(Qt::DropAction da) { m_executed_drop_action = da; }
71
72 QDrag *drag() const { return m_drag; }
73
74protected:
75 QWindow *m_sourceWindow = nullptr;
76 QPointer<QWindow> m_windowUnderCursor = nullptr;
77
78private:
79 void enableEventFilter();
80 void disableEventFilter();
81 void restoreCursor();
82 void exitDndEventLoop();
83
84#ifndef QT_NO_CURSOR
85 bool m_dndHasSetOverrideCursor = false;
86#endif
87 QEventLoop *m_eventLoop = nullptr;
88 Qt::DropAction m_executed_drop_action = Qt::IgnoreAction;
89 bool m_can_drop = false;
90 QDrag *m_drag = nullptr;
91 QShapedPixmapWindow *m_drag_icon_window = nullptr;
92 bool m_useCompositing = true;
93 QScreen *m_screen = nullptr;
94 QPoint m_lastPos;
95};
96
97class Q_GUI_EXPORT QSimpleDrag : public QBasicDrag
98{
99public:
100 QSimpleDrag();
101
102protected:
103 virtual void startDrag() override;
104 virtual void cancel() override;
105 virtual void move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
106 virtual void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
107};
108
109QT_END_NAMESPACE
110
111#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)