/**************************************************************************** ** ** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtQuick module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qquickitemsmodule_p.h" #include "qquickitem.h" #include "qquickitem_p.h" #include "qquickevents_p_p.h" #include "qquickrectangle_p.h" #include "qquickfocusscope_p.h" #include "qquicktext_p.h" #include "qquicktextinput_p.h" #include "qquicktextedit_p.h" #include "qquicktextdocument.h" #include "qquickimage_p.h" #include "qquickborderimage_p.h" #include "qquickscalegrid_p_p.h" #include "qquickmousearea_p.h" #include "qquickpincharea_p.h" #include "qquickflickable_p.h" #include "qquickflickable_p_p.h" #if QT_CONFIG(quick_listview) #include "qquicklistview_p.h" #endif #if QT_CONFIG(quick_gridview) #include "qquickgridview_p.h" #endif #if QT_CONFIG(quick_pathview) #include "qquickpathview_p.h" #endif #if QT_CONFIG(quick_tableview) #include "qquicktableview_p.h" #endif #if QT_CONFIG(quick_viewtransitions) #include "qquickitemviewtransition_p.h" #endif #if QT_CONFIG(quick_path) #include #include #endif #if QT_CONFIG(quick_positioners) #include "qquickpositioners_p.h" #endif #if QT_CONFIG(quick_repeater) #include "qquickrepeater_p.h" #endif #include "qquickloader_p.h" #if QT_CONFIG(quick_animatedimage) #include "qquickanimatedimage_p.h" #endif #if QT_CONFIG(quick_flipable) #include "qquickflipable_p.h" #endif #include "qquicktranslate_p.h" #include "qquickstateoperations_p.h" #include "qquickitemanimation_p.h" //#include #if QT_CONFIG(quick_canvas) #include #include #endif #include "qquickitemgrabresult.h" #if QT_CONFIG(quick_sprite) #include "qquicksprite_p.h" #include "qquickspritesequence_p.h" #include "qquickanimatedsprite_p.h" #endif #if QT_CONFIG(opengl) # include "qquickopenglinfo_p.h" #endif #include "qquickgraphicsinfo_p.h" #if QT_CONFIG(quick_shadereffect) #include #include "qquickshadereffect_p.h" #include "qquickshadereffectmesh_p.h" #endif #if QT_CONFIG(quick_draganddrop) #include "qquickdrag_p.h" #include "qquickdroparea_p.h" #endif #include "qquickmultipointtoucharea_p.h" #include #include "handlers/qquickdraghandler_p.h" #include "handlers/qquickhoverhandler_p.h" #include "handlers/qquickpinchhandler_p.h" #include "handlers/qquickpointhandler_p.h" #include "handlers/qquicktaphandler_p.h" #include "handlers/qquickwheelhandler_p.h" QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(lcTransient) QT_END_NAMESPACE static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject *parent) { // When setting a parent (especially during dynamic object creation) in QML, // also try to set up the analogous item/window relationship. if (QQuickItem *parentItem = qmlobject_cast(parent)) { QQuickItem *item = qmlobject_cast(obj); if (item) { // An Item has another Item item->setParentItem(parentItem); return QQmlPrivate::Parented; } else if (parentItem->window()) { QQuickWindow *win = qmlobject_cast(obj); if (win) { // A Window inside an Item should be transient for that item's window qCDebug(lcTransient) << win << "is transient for" << parentItem->window(); win->setTransientParent(parentItem->window()); return QQmlPrivate::Parented; } } else if (QQuickPointerHandler *handler = qmlobject_cast(obj)) { QQuickItemPrivate::get(parentItem)->addPointerHandler(handler); handler->setParent(parent); return QQmlPrivate::Parented; } return QQmlPrivate::IncompatibleObject; } else if (QQuickWindow *parentWindow = qmlobject_cast(parent)) { QQuickWindow *win = qmlobject_cast(obj); if (win) { // A Window inside a Window should be transient for it qCDebug(lcTransient) << win << "is transient for" << parentWindow; win->setTransientParent(parentWindow); return QQmlPrivate::Parented; } else if (QQuickItem *item = qmlobject_cast(obj)) { // The parent of an Item inside a Window is actually the implicit content Item item->setParentItem(parentWindow->contentItem()); return QQmlPrivate::Parented; } else if (QQuickPointerHandler *handler = qmlobject_cast(obj)) { QQuickItemPrivate::get(parentWindow->contentItem())->addPointerHandler(handler); handler->setParent(parentWindow->contentItem()); return QQmlPrivate::Parented; } return QQmlPrivate::IncompatibleObject; } else if (qmlobject_cast(obj)) { return QQmlPrivate::IncompatibleParent; } return QQmlPrivate::IncompatibleObject; } static void qt_quickitems_defineModule(const char *uri, int major, int minor) { QQmlPrivate::RegisterAutoParent autoparent = { 0, &qquickitem_autoParent }; QQmlPrivate::qmlregister(QQmlPrivate::AutoParentRegistration, &autoparent); // Register the latest version, even if there are no new types or new revisions for existing types yet. qmlRegisterModule(uri, 2, QT_VERSION_MINOR); #if !QT_CONFIG(quick_animatedimage) qmlRegisterTypeNotAvailable(uri,major,minor,"AnimatedImage", QCoreApplication::translate("QQuickAnimatedImage","Qt was built without support for QMovie")); #else qmlRegisterType(uri,major,minor,"AnimatedImage"); #endif qmlRegisterType(uri,major,minor,"BorderImage"); qmlRegisterType(uri,major,minor,"Flickable"); #if QT_CONFIG(quick_flipable) qmlRegisterType(uri,major,minor,"Flipable"); #endif // qmlRegisterType(uri,major,minor,"FocusPanel"); qmlRegisterType(uri,major,minor,"FocusScope"); qmlRegisterType(uri,major,minor,"Gradient"); qmlRegisterType(uri,major,minor,"GradientStop"); #if QT_CONFIG(quick_positioners) qmlRegisterType(uri,major,minor,"Column"); qmlRegisterType(uri,major,minor,"Flow"); qmlRegisterType(uri,major,minor,"Grid"); qmlRegisterUncreatableType(uri,major,minor,"Positioner", QStringLiteral("Positioner is an abstract type that is only available as an attached property.")); qmlRegisterType(uri,major,minor,"Row"); #endif #if QT_CONFIG(quick_gridview) qmlRegisterType(uri,major,minor,"GridView"); #endif qmlRegisterType(uri,major,minor,"Image"); qmlRegisterType(uri,major,minor,"Item"); #if QT_CONFIG(quick_listview) qmlRegisterType(uri,major,minor,"ListView"); qmlRegisterType(uri,major,minor,"ViewSection"); #endif qmlRegisterType(uri,major,minor,"Loader"); qmlRegisterType(uri,major,minor,"MouseArea"); #if QT_CONFIG(quick_path) qmlRegisterType(uri,major,minor,"Path"); qmlRegisterType(uri,major,minor,"PathAttribute"); qmlRegisterType(uri,major,minor,"PathCubic"); qmlRegisterType(uri,major,minor,"PathLine"); qmlRegisterType(uri,major,minor,"PathPercent"); qmlRegisterType(uri,major,minor,"PathQuad"); qmlRegisterType("QtQuick",2,0,"PathCurve"); qmlRegisterType("QtQuick",2,0,"PathArc"); qmlRegisterType("QtQuick",2,0,"PathSvg"); qmlRegisterType(uri, 2, 14, "Path"); qmlRegisterType("QtQuick", 2, 14, "PathPolyline"); qmlRegisterType("QtQuick", 2, 14, "PathMultiline"); #endif #if QT_CONFIG(quick_pathview) qmlRegisterType(uri,major,minor,"PathView"); #endif qmlRegisterType(uri,major,minor,"Rectangle"); #if QT_CONFIG(quick_repeater) qmlRegisterType(uri,major,minor,"Repeater"); #endif qmlRegisterType(uri,major,minor,"Translate"); qmlRegisterType(uri,major,minor,"Rotation"); qmlRegisterType(uri,major,minor,"Scale"); qmlRegisterType(uri,2,3,"Matrix4x4"); qmlRegisterType(uri,major,minor,"Text"); qmlRegisterType(uri,major,minor,"TextEdit"); qmlRegisterType(uri,2,1,"TextEdit"); qmlRegisterType(uri,major,minor,"TextInput"); qmlRegisterType(uri,2,2,"TextInput"); qmlRegisterType(uri,2,4,"TextInput"); qmlRegisterAnonymousType(uri, major); #if QT_CONFIG(quick_shadereffect) qmlRegisterAnonymousType(uri, major); #endif qmlRegisterAnonymousType(uri, major); qmlRegisterAnonymousType(uri, major); qmlRegisterAnonymousType(uri, major); qmlRegisterAnonymousType(uri, major); qmlRegisterAnonymousType(uri, major); qmlRegisterAnonymousType(uri, major); #if QT_CONFIG(quick_path) qmlRegisterAnonymousType(uri, major); qmlRegisterAnonymousType(uri, major); #endif qmlRegisterAnonymousType(uri, major); qmlRegisterAnonymousType(uri, major); qmlRegisterAnonymousType(uri, major); qmlRegisterAnonymousType(uri, major); qRegisterMetaType("QQuickAnchorLine"); qmlRegisterAnonymousType(uri, major); qmlRegisterUncreatableType(uri,major,minor,"KeyNavigation",QQuickKeyNavigationAttached::tr("KeyNavigation is only available via attached properties")); qmlRegisterUncreatableType(uri,major,minor,"Keys",QQuickKeysAttached::tr("Keys is only available via attached properties")); qmlRegisterUncreatableType(uri,major,minor,"LayoutMirroring", QQuickLayoutMirroringAttached::tr("LayoutMirroring is only available via attached properties")); #if QT_CONFIG(quick_viewtransitions) qmlRegisterUncreatableType(uri,major,minor,"ViewTransition",QQuickViewTransitionAttached::tr("ViewTransition is only available via attached properties")); #endif qmlRegisterType(uri,major,minor,"PinchArea"); qmlRegisterType(uri,major,minor,"Pinch"); qmlRegisterAnonymousType(uri, major); #if QT_CONFIG(quick_shadereffect) qmlRegisterType("QtQuick", 2, 0, "ShaderEffectSource"); qmlRegisterUncreatableType("QtQuick", 2, 0, "ShaderEffectMesh", QQuickShaderEffectMesh::tr("Cannot create instance of abstract class ShaderEffectMesh.")); qmlRegisterType("QtQuick", 2, 0, "GridMesh"); qmlRegisterType("QtQuick", 2, 0, "ShaderEffect"); #endif qmlRegisterUncreatableType("QtQuick", 2, 0, "PaintedItem", QQuickPaintedItem::tr("Cannot create instance of abstract class PaintedItem")); #if QT_CONFIG(quick_canvas) qmlRegisterType("QtQuick", 2, 0, "Canvas"); #endif #if QT_CONFIG(quick_sprite) qmlRegisterType("QtQuick", 2, 0, "Sprite"); qmlRegisterType("QtQuick", 2, 0, "AnimatedSprite"); qmlRegisterType("QtQuick", 2, 0, "SpriteSequence"); #endif qmlRegisterType(uri, major, minor,"ParentChange"); qmlRegisterType(uri, major, minor,"AnchorChanges"); qmlRegisterAnonymousType(uri, major); qmlRegisterType(uri, major, minor,"AnchorAnimation"); qmlRegisterType(uri, major, minor,"ParentAnimation"); #if QT_CONFIG(quick_path) qmlRegisterType("QtQuick",2,0,"PathAnimation"); qmlRegisterType("QtQuick",2,0,"PathInterpolator"); #endif #if QT_CONFIG(quick_draganddrop) qmlRegisterType("QtQuick", 2, 0, "DropArea"); qmlRegisterAnonymousType(uri, 2); qmlRegisterAnonymousType(uri, 2); qmlRegisterUncreatableType("QtQuick", 2, 0, "Drag", QQuickDragAttached::tr("Drag is only available via attached properties")); #endif qmlRegisterType("QtQuick", 2, 0, "MultiPointTouchArea"); qmlRegisterType("QtQuick", 2, 0, "TouchPoint"); qmlRegisterUncreatableType(uri,major,minor, "GestureEvent", QQuickMouseEvent::tr("GestureEvent is only available in the context of handling the gestureStarted signal from MultiPointTouchArea")); #if QT_CONFIG(accessibility) qmlRegisterUncreatableType("QtQuick", 2, 0, "Accessible",QQuickAccessibleAttached::tr("Accessible is only available via attached properties")); #endif qmlRegisterType(uri, 2, 1,"Item"); #if QT_CONFIG(quick_positioners) qmlRegisterType(uri, 2, 1, "Grid"); #endif #if QT_CONFIG(quick_itemview) const char *itemViewName = "ItemView"; const QString itemViewMessage = QQuickItemView::tr("ItemView is an abstract base class"); qmlRegisterUncreatableType(uri, 2, 1, itemViewName, itemViewMessage); qmlRegisterUncreatableType(uri, 2, 3, itemViewName, itemViewMessage); #endif #if QT_CONFIG(quick_listview) qmlRegisterType(uri, 2, 1, "ListView"); #endif #if QT_CONFIG(quick_gridview) qmlRegisterType(uri, 2, 1, "GridView"); #endif qmlRegisterType(uri, 2, 1, "TextEdit"); qmlRegisterType(uri, 2, 2, "Text"); qmlRegisterType(uri, 2, 2, "TextEdit"); qmlRegisterType(uri, 2, 3, "Text"); qmlRegisterType(uri, 2, 3, "TextEdit"); qmlRegisterType(uri, 2, 3,"Image"); qmlRegisterType(uri, 2, 4, "Item"); #if QT_CONFIG(quick_listview) qmlRegisterType(uri, 2, 4, "ListView"); #endif qmlRegisterType(uri, 2, 4, "MouseArea"); #if QT_CONFIG(quick_shadereffect) qmlRegisterType(uri, 2, 4, "ShaderEffect"); #endif #if QT_CONFIG(opengl) qmlRegisterUncreatableType(uri, 2, 4,"OpenGLInfo", QQuickOpenGLInfo::tr("OpenGLInfo is only available via attached properties")); #endif qmlRegisterType(uri, 2, 5,"PinchArea"); qmlRegisterType(uri, 2, 5,"Image"); qmlRegisterType(uri, 2, 5, "MouseArea"); qmlRegisterType(uri, 2, 6, "Text"); qmlRegisterType(uri, 2, 6, "TextEdit"); qmlRegisterType(uri, 2, 6, "TextInput"); #if QT_CONFIG(quick_positioners) qmlRegisterUncreatableType(uri, 2, 6, "Positioner", QStringLiteral("Positioner is an abstract type that is only available as an attached property.")); qmlRegisterType(uri, 2, 6, "Column"); qmlRegisterType(uri, 2, 6, "Row"); qmlRegisterType(uri, 2, 6, "Grid"); qmlRegisterType(uri, 2, 6, "Flow"); #endif qmlRegisterUncreatableType(uri, 2, 6, "EnterKey", QQuickEnterKeyAttached::tr("EnterKey is only available via attached properties")); #if QT_CONFIG(quick_shadereffect) qmlRegisterType(uri, 2, 6, "ShaderEffectSource"); #endif qmlRegisterType(uri, 2, 7, "Item"); #if QT_CONFIG(quick_listview) qmlRegisterType(uri, 2, 7, "ListView"); #endif #if QT_CONFIG(quick_gridview) qmlRegisterType(uri, 2, 7, "GridView"); #endif qmlRegisterType(uri, 2, 7, "TextInput"); qmlRegisterType(uri, 2, 7, "TextEdit"); #if QT_CONFIG(quick_pathview) qmlRegisterType(uri, 2, 7, "PathView"); #endif #if QT_CONFIG(quick_itemview) qmlRegisterUncreatableType(uri, 2, 7, itemViewName, itemViewMessage); #endif qmlRegisterUncreatableType(uri, 2, 7, nullptr, QQuickMouseEvent::tr("MouseEvent is only available within handlers in MouseArea")); qmlRegisterUncreatableType(uri, 2, 8,"GraphicsInfo", QQuickGraphicsInfo::tr("GraphicsInfo is only available via attached properties")); #if QT_CONFIG(quick_shadereffect) qmlRegisterType("QtQuick", 2, 8, "BorderImageMesh"); #endif qmlRegisterType(uri, 2, 9, "Flickable"); qmlRegisterType(uri, 2, 9, "MouseArea"); #if QT_CONFIG(quick_path) qmlRegisterType(uri, 2, 9, "PathArc"); qmlRegisterType(uri, 2, 9, "PathMove"); #endif qmlRegisterType(uri, 2, 9, "Text"); qmlRegisterType(uri, 2, 9, "TextInput"); qmlRegisterType(uri, 2, 9, "TouchPoint"); qRegisterMetaType("QPointingDeviceUniqueId"); qmlRegisterUncreatableType(uri, 2, 9, "PointingDeviceUniqueId", QQuickTouchPoint::tr("PointingDeviceUniqueId is only available via read-only properties")); #if QT_CONFIG(quick_positioners) qmlRegisterUncreatableType(uri, 2, 9, "Positioner", QStringLiteral("Positioner is an abstract type that is only available as an attached property.")); #endif #if QT_CONFIG(quick_shadereffect) qmlRegisterType(uri, 2, 9, "ShaderEffectSource"); #endif qmlRegisterType(uri, 2, 10, "Flickable"); qmlRegisterType(uri, 2, 10, "TextEdit"); qmlRegisterType(uri, 2, 10, "Text"); #if QT_CONFIG(quick_path) qmlRegisterType(uri, 2, 11, "PathAngleArc"); #endif #if QT_CONFIG(quick_animatedimage) qmlRegisterType(uri, 2, 11,"AnimatedImage"); #endif qmlRegisterType(uri, 2, 11,"Item"); qmlRegisterType(uri, 2, 12, "Flickable"); // classes related to Input Handlers which are newly exposed since 5.12 qmlRegisterUncreatableType(uri, 2, 12, "PointerEvent", QQuickPointerHandler::tr("PointerEvent is only available as a parameter of several signals in PointerHandler")); qmlRegisterUncreatableType(uri, 2, 12, "PointerMouseEvent", QQuickPointerHandler::tr("PointerMouseEvent is only available as a parameter of several signals in PointerHandler")); qmlRegisterUncreatableType(uri, 2, 12, "PointerTouchEvent", QQuickPointerHandler::tr("PointerTouchEvent is only available as a parameter of several signals in PointerHandler")); qmlRegisterUncreatableType(uri, 2, 12, "EventPoint", QQuickPointerHandler::tr("EventPoint is only available as a member of PointerEvent")); qmlRegisterUncreatableType(uri, 2, 12, "EventTouchPoint", QQuickPointerHandler::tr("EventTouchPoint is only available as a member of PointerEvent")); qmlRegisterUncreatableType(uri, 2, 12, "PointerDevice", QQuickPointerHandler::tr("PointerDevice is only available as a property of PointerEvent")); // Input Handlers are part of QtQuick, not a separate module, since 5.12 qmlRegisterUncreatableType(uri, 2, 12, "PointerHandler", QQuickPointerHandler::tr("PointerHandler is an abstract base class")); qmlRegisterType(uri, 2, 12, "PointHandler"); qmlRegisterType(uri, 2, 12, "DragHandler"); qmlRegisterUncreatableType(uri, 2, 12, "DragAxis", QQuickDragHandler::tr("DragAxis is only available as a grouped property of DragHandler")); qmlRegisterType(uri, 2, 12, "HoverHandler"); qmlRegisterType(uri, 2, 12, "PinchHandler"); qmlRegisterType(uri, 2, 12, "TapHandler"); qRegisterMetaType(); // The rest of the 5.12 revisions #if QT_CONFIG(quick_sprite) qmlRegisterType("QtQuick", 2, 12, "AnimatedSprite"); #endif qmlRegisterType(uri, 2, 12, "Gradient"); qmlRegisterType(uri, 2, 12, "Flickable"); qmlRegisterType(uri, 2, 12, "Text"); #if QT_CONFIG(quick_tableview) qmlRegisterType(uri, 2, 12, "TableView"); #endif #if QT_CONFIG(quick_itemview) qmlRegisterUncreatableType(uri, 2, 13, itemViewName, itemViewMessage); #endif #if QT_CONFIG(quick_pathview) qmlRegisterType(uri, 2, 13, "PathView"); #endif #if QT_CONFIG(quick_gridview) qmlRegisterType(uri, 2, 13, "GridView"); #endif #if QT_CONFIG(quick_tableview) qmlRegisterType(uri, 2, 14, "TableView"); #endif #if QT_CONFIG(wheelevent) qmlRegisterType(uri, 2, 14, "WheelHandler"); #endif qmlRegisterUncreatableType(uri, 2, 14, "ImageBase", QQuickPointerHandler::tr("ImageBase is an abstract base class")); qmlRegisterType(uri, 2, 14, "Image"); qmlRegisterType(uri, 2, 14, "DragHandler"); } static void initResources() { Q_INIT_RESOURCE(items); } QT_BEGIN_NAMESPACE void QQuickItemsModule::defineModule() { initResources(); QByteArray name = "QtQuick"; int majorVersion = 2; int minorVersion = 0; qt_quickitems_defineModule(name, majorVersion, minorVersion); } QT_END_NAMESPACE