1 | // Copyright (C) 2020 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 | #include "qquickitemsmodule_p.h" |
5 | |
6 | #include "qquickitem.h" |
7 | #include "qquickitem_p.h" |
8 | #include "qquickevents_p_p.h" |
9 | #include "qquickrectangle_p.h" |
10 | #include "qquickfocusscope_p.h" |
11 | #include "qquicktext_p.h" |
12 | #include "qquicktextinput_p.h" |
13 | #include "qquicktextedit_p.h" |
14 | #include "qquicktextdocument.h" |
15 | #include "qquickimage_p.h" |
16 | #include "qquickborderimage_p.h" |
17 | #include "qquickscalegrid_p_p.h" |
18 | #include "qquickmousearea_p.h" |
19 | #include "qquickpincharea_p.h" |
20 | #include "qquickflickable_p.h" |
21 | #include "qquickflickable_p_p.h" |
22 | #if QT_CONFIG(quick_listview) |
23 | #include "qquicklistview_p.h" |
24 | #endif |
25 | #if QT_CONFIG(quick_gridview) |
26 | #include "qquickgridview_p.h" |
27 | #endif |
28 | #if QT_CONFIG(quick_pathview) |
29 | #include "qquickpathview_p.h" |
30 | #endif |
31 | #if QT_CONFIG(quick_tableview) |
32 | #include "qquicktableview_p.h" |
33 | #endif |
34 | #if QT_CONFIG(quick_viewtransitions) |
35 | #include "qquickitemviewtransition_p.h" |
36 | #endif |
37 | #if QT_CONFIG(quick_path) |
38 | #include <private/qquickpath_p.h> |
39 | #include <private/qquickpathinterpolator_p.h> |
40 | #endif |
41 | #if QT_CONFIG(quick_positioners) |
42 | #include "qquickpositioners_p.h" |
43 | #endif |
44 | #if QT_CONFIG(quick_repeater) |
45 | #include "qquickrepeater_p.h" |
46 | #endif |
47 | #include "qquickloader_p.h" |
48 | #if QT_CONFIG(quick_animatedimage) |
49 | #include "qquickanimatedimage_p.h" |
50 | #endif |
51 | #if QT_CONFIG(quick_flipable) |
52 | #include "qquickflipable_p.h" |
53 | #endif |
54 | #include "qquicktranslate_p.h" |
55 | #include "qquickstateoperations_p.h" |
56 | #include "qquickitemanimation_p.h" |
57 | //#include <private/qquickpincharea_p.h> |
58 | #if QT_CONFIG(quick_canvas) |
59 | #include <QtQuick/private/qquickcanvasitem_p.h> |
60 | #include <QtQuick/private/qquickcontext2d_p.h> |
61 | #endif |
62 | #include "qquickitemgrabresult.h" |
63 | #if QT_CONFIG(quick_sprite) |
64 | #include "qquicksprite_p.h" |
65 | #include "qquickspritesequence_p.h" |
66 | #include "qquickanimatedsprite_p.h" |
67 | #endif |
68 | #include "qquickgraphicsinfo_p.h" |
69 | #if QT_CONFIG(quick_shadereffect) |
70 | #include <QtQuick/private/qquickshadereffectsource_p.h> |
71 | #include "qquickshadereffect_p.h" |
72 | #include "qquickshadereffectmesh_p.h" |
73 | #endif |
74 | #if QT_CONFIG(quick_draganddrop) |
75 | #include "qquickdrag_p.h" |
76 | #include "qquickdroparea_p.h" |
77 | #endif |
78 | #include "qquickmultipointtoucharea_p.h" |
79 | #include <QtQuick/private/qquickaccessibleattached_p.h> |
80 | |
81 | #include "handlers/qquickdraghandler_p.h" |
82 | #include "handlers/qquickhoverhandler_p.h" |
83 | #include "handlers/qquickpinchhandler_p.h" |
84 | #include "handlers/qquickpointhandler_p.h" |
85 | #include "handlers/qquicktaphandler_p.h" |
86 | #include "handlers/qquickwheelhandler_p.h" |
87 | |
88 | QT_BEGIN_NAMESPACE |
89 | Q_DECLARE_LOGGING_CATEGORY(lcTransient) |
90 | QT_END_NAMESPACE |
91 | |
92 | #include "moc_qquickitemsmodule_p.cpp" |
93 | |
94 | static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject *parent) |
95 | { |
96 | // When setting a parent (especially during dynamic object creation) in QML, |
97 | // also try to set up the analogous item/window relationship. |
98 | if (QQuickItem *parentItem = qmlobject_cast<QQuickItem *>(parent)) { |
99 | QQuickItem *item = qmlobject_cast<QQuickItem *>(obj); |
100 | if (item) { |
101 | // An Item has another Item |
102 | item->setParentItem(parentItem); |
103 | return QQmlPrivate::Parented; |
104 | } else if (parentItem->window()) { |
105 | QQuickWindow *win = qmlobject_cast<QQuickWindow *>(obj); |
106 | if (win) { |
107 | // A Window inside an Item should be transient for that item's window |
108 | qCDebug(lcTransient) << win << "is transient for" << parentItem->window(); |
109 | win->setTransientParent(parentItem->window()); |
110 | return QQmlPrivate::Parented; |
111 | } |
112 | } else if (QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj)) { |
113 | QQuickItemPrivate::get(item: parentItem)->addPointerHandler(h: handler); |
114 | handler->setParent(parent); |
115 | return QQmlPrivate::Parented; |
116 | } |
117 | return QQmlPrivate::IncompatibleObject; |
118 | } else if (QQuickWindow *parentWindow = qmlobject_cast<QQuickWindow *>(parent)) { |
119 | QQuickWindow *win = qmlobject_cast<QQuickWindow *>(obj); |
120 | if (win) { |
121 | // A Window inside a Window should be transient for it |
122 | qCDebug(lcTransient) << win << "is transient for" << parentWindow; |
123 | win->setTransientParent(parentWindow); |
124 | return QQmlPrivate::Parented; |
125 | } else if (QQuickItem *item = qmlobject_cast<QQuickItem *>(obj)) { |
126 | // The parent of an Item inside a Window is actually the implicit content Item |
127 | item->setParentItem(parentWindow->contentItem()); |
128 | return QQmlPrivate::Parented; |
129 | } else if (QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj)) { |
130 | QQuickItemPrivate::get(item: parentWindow->contentItem())->addPointerHandler(h: handler); |
131 | handler->setParent(parentWindow->contentItem()); |
132 | return QQmlPrivate::Parented; |
133 | } |
134 | return QQmlPrivate::IncompatibleObject; |
135 | } else if (qmlobject_cast<QQuickItem *>(obj)) { |
136 | return QQmlPrivate::IncompatibleParent; |
137 | } |
138 | return QQmlPrivate::IncompatibleObject; |
139 | } |
140 | |
141 | static void qt_quickitems_defineModule() |
142 | { |
143 | QQmlPrivate::RegisterAutoParent autoparent = { .structVersion: 0, .function: &qquickitem_autoParent }; |
144 | QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent); |
145 | |
146 | qRegisterMetaType<QQuickAnchorLine>(typeName: "QQuickAnchorLine" ); |
147 | qRegisterMetaType<QQuickHandlerPoint>(); |
148 | } |
149 | |
150 | //static void initResources() |
151 | //{ |
152 | // Q_INIT_RESOURCE(items); |
153 | //} |
154 | |
155 | QT_BEGIN_NAMESPACE |
156 | |
157 | void QQuickItemsModule::defineModule() |
158 | { |
159 | // initResources(); |
160 | qt_quickitems_defineModule(); |
161 | } |
162 | |
163 | /*! |
164 | \qmltype PointerEvent |
165 | \instantiates QPointerEvent |
166 | \inqmlmodule QtQuick |
167 | \brief QML equivalent for \l QPointerEvent. |
168 | |
169 | PointerEvent is the QML name of the QPointerEvent class. |
170 | */ |
171 | |
172 | /*! |
173 | \qmltype PointerDevice |
174 | \instantiates QPointingDevice |
175 | \inqmlmodule QtQuick |
176 | \brief QML equivalent for \l QPointingDevice. |
177 | |
178 | PointerDevice is the QML name of the QPointingDevice class. |
179 | It has the same properties and enums as \l QPointingDevice. |
180 | */ |
181 | |
182 | /*! |
183 | \qmlproperty enumeration PointerDevice::deviceType |
184 | |
185 | This property tells the type of device that generated a PointerEvent. |
186 | |
187 | Valid values are: |
188 | |
189 | \value PointerDevice.Unknown The device cannot be identified. |
190 | \value PointerDevice.Mouse A mouse. |
191 | \value PointerDevice.TouchScreen A touchscreen. |
192 | \value PointerDevice.TouchPad A touchpad or trackpad. |
193 | \value PointerDevice.Stylus A stylus on a graphics tablet. |
194 | \value PointerDevice.Airbrush An airbrush on a graphics tablet. |
195 | \value PointerDevice.Puck A digitizer with crosshairs, on a graphics tablet. |
196 | |
197 | \sa QInputDevice::DeviceType, PointerDeviceHandler::acceptedDevices |
198 | */ |
199 | |
200 | /*! |
201 | \qmlproperty enumeration PointerDevice::pointerType |
202 | |
203 | This property tells what is interacting with the PointerDevice. |
204 | |
205 | There is some redundancy between this property and \l deviceType. |
206 | For example, if a touchscreen is used, then \c deviceType is |
207 | \c TouchScreen and \c pointerType is \c Finger. But on a graphics |
208 | tablet, it's often possible for both ends of the stylus to be used, |
209 | and programs need to distinguish them. |
210 | \l PointerDeviceHandler::acceptedDevices and |
211 | \l PointerDeviceHandler::acceptedPointerTypes can be used in combination |
212 | to filter the subset of events that a particular handler should react to. |
213 | |
214 | Valid values are: |
215 | |
216 | \value PointerDevice.Unknown The device cannot be identified. |
217 | \value PointerDevice.Generic A mouse or a device that emulates a mouse. |
218 | \value PointerDevice.Finger A finger on a touchscreen. |
219 | \value PointerDevice.Pen A stylus on a graphics tablet. |
220 | \value PointerDevice.Eraser An eraser on a graphics tablet. |
221 | \value PointerDevice.Cursor A digitizer with crosshairs, on a graphics tablet. |
222 | |
223 | \sa QPointingDevice::PointerType, PointerDeviceHandler::acceptedPointerTypes |
224 | */ |
225 | |
226 | /*! |
227 | \qmlproperty int PointerDevice::maximumPoints |
228 | |
229 | This property tells the maximum number of simultaneous touch points |
230 | (fingers) that can be detected. |
231 | */ |
232 | |
233 | /*! |
234 | \qmlproperty int PointerDevice::buttonCount |
235 | |
236 | This property tells the maximum number of on-device buttons that can be |
237 | detected. |
238 | */ |
239 | |
240 | /*! |
241 | \qmltype pointingDeviceUniqueId |
242 | \instantiates QPointingDeviceUniqueId |
243 | \inqmlmodule QtQuick |
244 | \brief QML equivalent for \l QPointingDeviceUniqueId. |
245 | |
246 | pointingDeviceUniqueId is the QML name of the QPointingDeviceUniqueId class. |
247 | */ |
248 | |
249 | /*! |
250 | \qmlproperty qint64 pointingDeviceUniqueId::numericId |
251 | |
252 | This property gives the numeric ID of the \l PointerDevice, if available; |
253 | otherwise it is \c -1. |
254 | */ |
255 | |
256 | /*! |
257 | \qmlproperty pointingDeviceUniqueId PointerDevice::uniqueId |
258 | |
259 | This property may provide a unique ID for the device, if available. For |
260 | example, a graphics tablet stylus device may have a unique serial number. |
261 | |
262 | \sa eventPoint, QEventPoint::uniqueId() |
263 | */ |
264 | |
265 | /*! |
266 | \qmlsignal PointerDevice::grabChanged(QtObject grabber, enumeration transition, PointerEvent event, eventPoint point) |
267 | |
268 | This signal is emitted when the \a grabber object gains or loses an |
269 | exclusive or passive grab of \a point during delivery of \a event. |
270 | The \a transition tells what happened, from the perspective of the |
271 | \c grabber object, which may be either an \l Item or an |
272 | \l {Qt Quick Input Handlers}{Input Handler}. |
273 | |
274 | Valid values for \a transition are: |
275 | |
276 | \value PointerDevice.GrabExclusive |
277 | The \a grabber has taken primary responsibility for handling the \a point. |
278 | \value PointerDevice.UngrabExclusive |
279 | The \a grabber has given up its previous exclusive grab. |
280 | \value PointerDevice.CancelGrabExclusive |
281 | The exclusive grab of \a grabber has been taken over or cancelled. |
282 | \value PointerDevice.GrabPassive |
283 | The \a grabber has acquired a passive grab, to monitor the \a point. |
284 | \value PointerDevice.UngrabPassive |
285 | The \a grabber has given up its previous passive grab. |
286 | \value PointerDevice.CancelGrabPassive |
287 | The previous passive grab has terminated abnormally. |
288 | |
289 | \note A grab transition from one object to another results in two signals, |
290 | to notify that one object has lost its grab, and to notify that there is |
291 | another grabber. In other cases, when transitioning to or from a non-grabbing |
292 | state, only one signal is emitted. |
293 | |
294 | \sa QPointerEvent::setExclusiveGrabber(), QPointerEvent::addPassiveGrabber(), |
295 | QPointerEvent::removePassiveGrabber(), PointerHandler::grabChanged() |
296 | */ |
297 | |
298 | QT_END_NAMESPACE |
299 | |