| 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 | if (QQuickItem *parentItem = qmlobject_cast<QQuickItem *>(parent)) { |
| 97 | if (QQuickItem *item = qmlobject_cast<QQuickItem *>(obj)) { |
| 98 | // An Item has another Item |
| 99 | item->setParentItem(parentItem); |
| 100 | return QQmlPrivate::Parented; |
| 101 | } else if (QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj)) { |
| 102 | QQuickItemPrivate::get(item: parentItem)->addPointerHandler(h: handler); |
| 103 | handler->setParent(parent); |
| 104 | return QQmlPrivate::Parented; |
| 105 | } |
| 106 | return QQmlPrivate::IncompatibleObject; |
| 107 | } else if (QQuickWindow *parentWindow = qmlobject_cast<QQuickWindow *>(parent)) { |
| 108 | if (QQuickItem *item = qmlobject_cast<QQuickItem *>(obj)) { |
| 109 | // The parent of an Item inside a Window is actually the implicit content Item |
| 110 | item->setParentItem(parentWindow->contentItem()); |
| 111 | return QQmlPrivate::Parented; |
| 112 | } else if (QQuickPointerHandler *handler = qmlobject_cast<QQuickPointerHandler *>(obj)) { |
| 113 | QQuickItemPrivate::get(item: parentWindow->contentItem())->addPointerHandler(h: handler); |
| 114 | handler->setParent(parentWindow->contentItem()); |
| 115 | return QQmlPrivate::Parented; |
| 116 | } |
| 117 | return QQmlPrivate::IncompatibleObject; |
| 118 | } else if (qmlobject_cast<QQuickItem *>(obj)) { |
| 119 | return QQmlPrivate::IncompatibleParent; |
| 120 | } |
| 121 | return QQmlPrivate::IncompatibleObject; |
| 122 | } |
| 123 | |
| 124 | static void qt_quickitems_defineModule() |
| 125 | { |
| 126 | QQmlPrivate::RegisterAutoParent autoparent = { .structVersion: 0, .function: &qquickitem_autoParent }; |
| 127 | QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent); |
| 128 | |
| 129 | qRegisterMetaType<QQuickAnchorLine>(typeName: "QQuickAnchorLine" ); |
| 130 | qRegisterMetaType<QQuickHandlerPoint>(); |
| 131 | } |
| 132 | |
| 133 | //static void initResources() |
| 134 | //{ |
| 135 | // Q_INIT_RESOURCE(items); |
| 136 | //} |
| 137 | |
| 138 | QT_BEGIN_NAMESPACE |
| 139 | |
| 140 | void QQuickItemsModule::defineModule() |
| 141 | { |
| 142 | // initResources(); |
| 143 | qt_quickitems_defineModule(); |
| 144 | } |
| 145 | |
| 146 | /*! |
| 147 | \qmltype PointerEvent |
| 148 | \nativetype QPointerEvent |
| 149 | \inqmlmodule QtQuick |
| 150 | \brief QML equivalent for \l QPointerEvent. |
| 151 | |
| 152 | PointerEvent is the QML name of the QPointerEvent class. |
| 153 | */ |
| 154 | |
| 155 | /*! |
| 156 | \qmltype PointerDevice |
| 157 | \nativetype QPointingDevice |
| 158 | \inqmlmodule QtQuick |
| 159 | \brief QML equivalent for \l QPointingDevice. |
| 160 | |
| 161 | PointerDevice is the QML name of the QPointingDevice class. |
| 162 | It has the same properties and enums as \l QPointingDevice. |
| 163 | */ |
| 164 | |
| 165 | /*! |
| 166 | \qmlproperty enumeration PointerDevice::deviceType |
| 167 | |
| 168 | This property tells the type of device that generated a PointerEvent. |
| 169 | |
| 170 | Valid values are: |
| 171 | |
| 172 | \value PointerDevice.Unknown The device cannot be identified. |
| 173 | \value PointerDevice.Mouse A mouse. |
| 174 | \value PointerDevice.TouchScreen A touchscreen. |
| 175 | \value PointerDevice.TouchPad A touchpad or trackpad. |
| 176 | \value PointerDevice.Stylus A stylus on a graphics tablet. |
| 177 | \value PointerDevice.Airbrush An airbrush on a graphics tablet. |
| 178 | \value PointerDevice.Puck A digitizer with crosshairs, on a graphics tablet. |
| 179 | |
| 180 | \sa QInputDevice::DeviceType, PointerDeviceHandler::acceptedDevices |
| 181 | */ |
| 182 | |
| 183 | /*! |
| 184 | \qmlproperty enumeration PointerDevice::pointerType |
| 185 | |
| 186 | This property tells what is interacting with the PointerDevice. |
| 187 | |
| 188 | There is some redundancy between this property and \l deviceType. |
| 189 | For example, if a touchscreen is used, then \c deviceType is |
| 190 | \c TouchScreen and \c pointerType is \c Finger. But on a graphics |
| 191 | tablet, it's often possible for both ends of the stylus to be used, |
| 192 | and programs need to distinguish them. |
| 193 | \l PointerDeviceHandler::acceptedDevices and |
| 194 | \l PointerDeviceHandler::acceptedPointerTypes can be used in combination |
| 195 | to filter the subset of events that a particular handler should react to. |
| 196 | |
| 197 | Valid values are: |
| 198 | |
| 199 | \value PointerDevice.Unknown The device cannot be identified. |
| 200 | \value PointerDevice.Generic A mouse or a device that emulates a mouse. |
| 201 | \value PointerDevice.Finger A finger on a touchscreen. |
| 202 | \value PointerDevice.Pen A stylus on a graphics tablet. |
| 203 | \value PointerDevice.Eraser An eraser on a graphics tablet. |
| 204 | \value PointerDevice.Cursor A digitizer with crosshairs, on a graphics tablet. |
| 205 | |
| 206 | \sa QPointingDevice::PointerType, PointerDeviceHandler::acceptedPointerTypes |
| 207 | */ |
| 208 | |
| 209 | /*! |
| 210 | \qmlproperty int PointerDevice::maximumPoints |
| 211 | |
| 212 | This property tells the maximum number of simultaneous touch points |
| 213 | (fingers) that can be detected. |
| 214 | */ |
| 215 | |
| 216 | /*! |
| 217 | \qmlproperty int PointerDevice::buttonCount |
| 218 | |
| 219 | This property tells the maximum number of on-device buttons that can be |
| 220 | detected. |
| 221 | */ |
| 222 | |
| 223 | /*! |
| 224 | \qmltype pointingDeviceUniqueId |
| 225 | \nativetype QPointingDeviceUniqueId |
| 226 | \inqmlmodule QtQuick |
| 227 | \brief QML equivalent for \l QPointingDeviceUniqueId. |
| 228 | |
| 229 | pointingDeviceUniqueId is the QML name of the QPointingDeviceUniqueId class. |
| 230 | */ |
| 231 | |
| 232 | /*! |
| 233 | \qmlproperty qint64 pointingDeviceUniqueId::numericId |
| 234 | |
| 235 | This property gives the numeric ID of the \l PointerDevice, if available; |
| 236 | otherwise it is \c -1. |
| 237 | */ |
| 238 | |
| 239 | /*! |
| 240 | \qmlproperty pointingDeviceUniqueId PointerDevice::uniqueId |
| 241 | |
| 242 | This property may provide a unique ID for the device, if available. For |
| 243 | example, a graphics tablet stylus device may have a unique serial number. |
| 244 | |
| 245 | \sa eventPoint, QEventPoint::uniqueId() |
| 246 | */ |
| 247 | |
| 248 | /*! |
| 249 | \qmlsignal PointerDevice::grabChanged(QtObject grabber, enumeration transition, PointerEvent event, eventPoint point) |
| 250 | |
| 251 | This signal is emitted when the \a grabber object gains or loses an |
| 252 | exclusive or passive grab of \a point during delivery of \a event. |
| 253 | The \a transition tells what happened, from the perspective of the |
| 254 | \c grabber object, which may be either an \l Item or an |
| 255 | \l {Qt Quick Input Handlers}{Input Handler}. |
| 256 | |
| 257 | Valid values for \a transition are: |
| 258 | |
| 259 | \value PointerDevice.GrabExclusive |
| 260 | The \a grabber has taken primary responsibility for handling the \a point. |
| 261 | \value PointerDevice.UngrabExclusive |
| 262 | The \a grabber has given up its previous exclusive grab. |
| 263 | \value PointerDevice.CancelGrabExclusive |
| 264 | The exclusive grab of \a grabber has been taken over or cancelled. |
| 265 | \value PointerDevice.GrabPassive |
| 266 | The \a grabber has acquired a passive grab, to monitor the \a point. |
| 267 | \value PointerDevice.UngrabPassive |
| 268 | The \a grabber has given up its previous passive grab. |
| 269 | \value PointerDevice.CancelGrabPassive |
| 270 | The previous passive grab has terminated abnormally. |
| 271 | |
| 272 | \note A grab transition from one object to another results in two signals, |
| 273 | to notify that one object has lost its grab, and to notify that there is |
| 274 | another grabber. In other cases, when transitioning to or from a non-grabbing |
| 275 | state, only one signal is emitted. |
| 276 | |
| 277 | \sa QPointerEvent::setExclusiveGrabber(), QPointerEvent::addPassiveGrabber(), |
| 278 | QPointerEvent::removePassiveGrabber(), PointerHandler::grabChanged() |
| 279 | */ |
| 280 | |
| 281 | QT_END_NAMESPACE |
| 282 | |