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