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
qdesigner_dnditem.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3// Qt-Security score:significant reason:default
4
7#include <QtDesigner/private/ui4_p.h>
8
9#include <QtGui/qpainter.h>
10#include <QtGui/qbitmap.h>
11#include <QtGui/qpixmap.h>
12#include <QtGui/qimage.h>
13#include <QtWidgets/qlabel.h>
14#include <QtGui/qdrag.h>
15#include <QtGui/qcursor.h>
16#include <QtGui/qevent.h>
17#include <QtGui/qrgb.h>
18
19#include <QtCore/qmap.h>
20
22
23namespace qdesigner_internal {
24
27 m_type(type),
28 m_dom_ui(nullptr),
29 m_widget(nullptr),
30 m_decoration(nullptr)
31{
32}
33
46
48{
49 if (m_decoration != nullptr)
51 delete m_dom_ui;
52}
53
55{
56 return m_dom_ui;
57}
58
60{
61 return m_decoration;
62}
63
65{
66 return m_hot_spot;
67}
68
70{
71 return m_widget;
72}
73
78
80{
81 return m_source;
82}
83
85{
86 delete m_dom_ui;
88}
89
90// ---------- QDesignerMimeData
91
92// Make pixmap transparent on Windows only. Mac is transparent by default, Unix usually does not work.
93#ifdef Q_OS_WIN
94# define TRANSPARENT_DRAG_PIXMAP
95#endif
96
99{
100 enum { Alpha = 200 };
102 switch (m_items.size()) {
103 case 0:
104 break;
105 case 1: {
108 const QPixmap widgetPixmap = deco->grab(QRect(0, 0, -1, -1));
109#ifdef TRANSPARENT_DRAG_PIXMAP
115 painter.end();
118#else
120#endif
121 }
122 break;
123 default: {
124 // determine size of drag decoration by uniting all geometries
125 const auto cend = m_items.cend();
126 auto it = m_items.cbegin();
129 for (++it; it != cend; ++it )
131
132 // paint with offset. At the same time, create a mask bitmap, containing widget rectangles.
139 mask.clear();
140 // paint with offset, determine action
144 for (auto *item : std::as_const(m_items)) {
145 QWidget *w = item->decoration();
146 const QPixmap wp = w->grab(QRect(0, 0, -1, -1));
147 const QPoint pos = w->pos() - decorationTopLeft;
150 }
151 painter.end();
153#ifdef TRANSPARENT_DRAG_PIXMAP
155#endif
159 }
160 break;
161 }
162 // determine hot spot and reconstruct the exact starting position as form window
163 // introduces some offset when detecting DnD
167
168 drag->setMimeData(this);
169}
170
175
177{
179}
180
182{
183 if (items.isEmpty())
184 return Qt::IgnoreAction;
185
186 QDrag *drag = new QDrag(dragSource);
188
189 // Store pointers to widgets that are to be re-shown if a move operation is canceled
191 for (auto *item : items) {
192 if (QWidget *w = item->widget()) {
195 }
196 }
197
199
202 w->show();
203 }
204
205 return executedAction;
206}
207
208
210{
212 for (auto *item : m_items) {
213 QWidget *w = item->decoration();
214 w->move(w->pos() + relativeDistance);
215 }
216}
217
219{
221 // Find moved widgets per form
222 for (auto *item : items) {
224 if (QWidget *w = item->widget()) {
227 }
228 }
229 }
230
231 const auto &formWindows = formWidgetMap.uniqueKeys();
234}
235
245
250
252{
253 const int height = image.height();
254 for (int l = 0; l < height; l++) {
255 QRgb *line = reinterpret_cast<QRgb *>(image.scanLine(l));
256 QRgb *lineEnd = line + image.width();
257 for ( ; line < lineEnd; line++) {
258 const QRgb rgba = *line;
260 }
261 }
262}
263
264} // namespace qdesigner_internal
265
266QT_END_NAMESPACE
Combined button and popup list for selecting options.
Auxiliary methods to store/retrieve settings.