aboutsummaryrefslogtreecommitdiffstats
path: root/src/labs
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-06-02 16:54:21 +1000
committerCraig Scott <craig.scott@qt.io>2021-06-04 16:54:52 +1000
commit1c4ba17015fe99da48ce73fab75ecc60cf9cb975 (patch)
tree1311d8cebc4007d43888477045ca534404f2f7ca /src/labs
parent6432e00b954beec7d0c6bc9b70fed6191b87bd38 (diff)
Refactor and update qml CMake API
The existing CMake API for qml modules had a number of shortcomings. Refactor it to achieve the following: - Clearly separate public and internal aspects. - Re-use code from qtbase for adding plugins and module targets rather than reimplementing close variations. - Provide more robust and complete support for qmllint, qmlcachegen and automatic generation of qmldir files. - Reduce the steps needed for more common scenarios. - Encourage the use of separate backing library and plugin targets. - Automatically generate the plugin class .cpp file where possible. - Specify .qml files directly through qml-specific API elements rather than assuming they can be extracted out of a set of resources. [ChangeLog][QtQml] The qml CMake API has changed from 6.1 and is now out of Technical Preview status. The most notable change is that .qml files should no longer be specified as resources, there is dedicated handling for them in the qt6_add_qml_module(). A related change is that the qt6_target_qml_files() command has been replaced by qt6_target_qml_sources(). More complete integration with qmlcachegen, qmllint and qmldir generation is also part of the CMake API. Fixes: QTBUG-91621 Task-number: QTBUG-82598 Task-number: QTBUG-88763 Task-number: QTBUG-89274 Task-number: QTBUG-91444 Change-Id: I25aae1b0e89890394dfe2ba2824008164b2ca8d9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/labs')
-rw-r--r--src/labs/animation/CMakeLists.txt32
-rw-r--r--src/labs/animation/doc/src/qmlanimation.qdoc42
-rw-r--r--src/labs/folderlistmodel/CMakeLists.txt23
-rw-r--r--src/labs/models/CMakeLists.txt29
-rw-r--r--src/labs/models/doc/src/qmllabsmodels.qdoc42
-rw-r--r--src/labs/settings/CMakeLists.txt16
-rw-r--r--src/labs/sharedimage/CMakeLists.txt28
-rw-r--r--src/labs/sharedimage/doc/src/qsharedimage.qdoc83
-rw-r--r--src/labs/sharedimage/qsharedimageplugin.cpp68
-rw-r--r--src/labs/wavefrontmesh/CMakeLists.txt27
10 files changed, 297 insertions, 93 deletions
diff --git a/src/labs/animation/CMakeLists.txt b/src/labs/animation/CMakeLists.txt
index 2985139bf0..88e756f3a6 100644
--- a/src/labs/animation/CMakeLists.txt
+++ b/src/labs/animation/CMakeLists.txt
@@ -1,20 +1,14 @@
-qt_internal_add_module(LabsAnimation
- SOURCES
- qquickboundaryrule.cpp qquickboundaryrule_p.h
- qqmlanimationglobal_p.h
- DEFINES
- QT_BUILD_LABSANIMATION_LIB
- PUBLIC_LIBRARIES
- Qt::QmlPrivate
- Qt::QuickPrivate
+qt_internal_add_qml_module(LabsAnimation
+ URI "Qt.labs.animation"
+ VERSION "${PROJECT_VERSION}"
+ PLUGIN_TARGET labsanimationplugin
+ CLASS_NAME QtLabsAnimationPlugin
+ SOURCES
+ qquickboundaryrule.cpp qquickboundaryrule_p.h
+ qqmlanimationglobal_p.h
+ DEFINES
+ QT_BUILD_LABSANIMATION_LIB
+ PUBLIC_LIBRARIES
+ Qt::QmlPrivate
+ Qt::QuickPrivate
)
-
-set_target_properties(LabsAnimation PROPERTIES
- QT_QML_MODULE_INSTALL_QMLTYPES TRUE
- QT_QML_MODULE_VERSION ${PROJECT_VERSION}
- QT_QML_MODULE_URI Qt.labs.animation
- QT_QMLTYPES_FILENAME plugins.qmltypes
- QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/Qt/labs/animation"
-)
-
-qt6_qml_type_registration(LabsAnimation)
diff --git a/src/labs/animation/doc/src/qmlanimation.qdoc b/src/labs/animation/doc/src/qmlanimation.qdoc
new file mode 100644
index 0000000000..c8d949b27b
--- /dev/null
+++ b/src/labs/animation/doc/src/qmlanimation.qdoc
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmlmodule Qt.labs.animation 1.0
+ \title Qt Quick experimental animation types
+ \ingroup qmlmodules
+ \brief Provides QML experimental types for animation
+ \since 5.14
+
+ This QML module contains experimental QML types related to animation.
+
+ To use the types in this module, import the module with the following line:
+
+ \code
+ import Qt.labs.animation
+ \endcode
+*/
diff --git a/src/labs/folderlistmodel/CMakeLists.txt b/src/labs/folderlistmodel/CMakeLists.txt
index fb6e47e154..8f49d691dd 100644
--- a/src/labs/folderlistmodel/CMakeLists.txt
+++ b/src/labs/folderlistmodel/CMakeLists.txt
@@ -1,23 +1,16 @@
-qt_internal_add_module(LabsFolderListModel
- SOURCES
+qt_internal_add_qml_module(LabsFolderListModel
+ URI "Qt.labs.folderlistmodel"
+ VERSION "${PROJECT_VERSION}"
+ PLUGIN_TARGET qmlfolderlistmodelplugin
+ CLASS_NAME QmlFolderListModelPlugin
+ SOURCES
fileinfothread.cpp fileinfothread_p.h
fileproperty_p.h
qquickfolderlistmodel.cpp qquickfolderlistmodel_p.h
qquickfolderlistmodelglobal_p.h
- DEFINES
+ DEFINES
QT_BUILD_LABSFOLDERMODEL_LIB
- PUBLIC_LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::QmlPrivate
)
-
-set_target_properties(LabsFolderListModel PROPERTIES
- QT_QML_MODULE_INSTALL_QMLTYPES TRUE
- QT_QML_MODULE_VERSION ${PROJECT_VERSION}
- QT_QML_MODULE_URI Qt.labs.folderlistmodel
- QT_QMLTYPES_FILENAME plugins.qmltypes
- QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/Qt/labs/folderlistmodel"
-)
-
-
-qt6_qml_type_registration(LabsFolderListModel)
diff --git a/src/labs/models/CMakeLists.txt b/src/labs/models/CMakeLists.txt
index 98fdf0aa74..e417013ea6 100644
--- a/src/labs/models/CMakeLists.txt
+++ b/src/labs/models/CMakeLists.txt
@@ -1,12 +1,16 @@
-qt_internal_add_module(LabsQmlModels
- SOURCES
- qqmlmodelsglobal_p.h
- DEFINES
- QT_BUILD_LABSQMLMODELS_LIB
- PUBLIC_LIBRARIES
+qt_internal_add_qml_module(LabsQmlModels
+ URI "Qt.labs.qmlmodels"
+ VERSION "${PROJECT_VERSION}"
+ PLUGIN_TARGET labsmodelsplugin
+ CLASS_NAME QtQmlLabsModelsPlugin
+ SOURCES
+ qqmlmodelsglobal_p.h
+ DEFINES
+ QT_BUILD_LABSQMLMODELS_LIB
+ PUBLIC_LIBRARIES
Qt::QmlModelsPrivate
Qt::QmlPrivate
- )
+)
qt_internal_extend_target(LabsQmlModels CONDITION QT_FEATURE_qml_table_model
SOURCES
@@ -18,14 +22,3 @@ qt_internal_extend_target(LabsQmlModels CONDITION QT_FEATURE_qml_delegate_model
SOURCES
qqmldelegatecomponent.cpp qqmldelegatecomponent_p.h
)
-
-set_target_properties(LabsQmlModels PROPERTIES
- QT_QML_MODULE_INSTALL_QMLTYPES TRUE
- QT_QML_MODULE_VERSION ${PROJECT_VERSION}
- QT_QML_MODULE_URI Qt.labs.qmlmodels
- QT_QMLTYPES_FILENAME plugins.qmltypes
- QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/Qt/labs/qmlmodels"
-
-)
-
-qt6_qml_type_registration(LabsQmlModels)
diff --git a/src/labs/models/doc/src/qmllabsmodels.qdoc b/src/labs/models/doc/src/qmllabsmodels.qdoc
new file mode 100644
index 0000000000..f780a75687
--- /dev/null
+++ b/src/labs/models/doc/src/qmllabsmodels.qdoc
@@ -0,0 +1,42 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmlmodule Qt.labs.qmlmodels 1.0
+ \title Qt QML Models experimental QML Types
+ \ingroup qmlmodules
+ \brief Provides QML experimental types for data models.
+ \since 5.12
+
+ This QML module contains experimental QML types related to data models.
+
+ To use the types in this module, import the module with the following line:
+
+ \code
+ import Qt.labs.qmlmodels
+ \endcode
+*/
diff --git a/src/labs/settings/CMakeLists.txt b/src/labs/settings/CMakeLists.txt
index c323e6f9ce..e40e727f98 100644
--- a/src/labs/settings/CMakeLists.txt
+++ b/src/labs/settings/CMakeLists.txt
@@ -1,4 +1,8 @@
-qt_internal_add_module(LabsSettings
+qt_internal_add_qml_module(LabsSettings
+ URI "Qt.labs.settings"
+ VERSION "${PROJECT_VERSION}"
+ PLUGIN_TARGET qmlsettingsplugin
+ CLASS_NAME QmlSettingsPlugin
SOURCES
qqmlsettings.cpp qqmlsettings_p.h
qqmlsettingsglobal_p.h
@@ -8,13 +12,3 @@ qt_internal_add_module(LabsSettings
Qt::Core
Qt::Qml
)
-
-set_target_properties(LabsSettings PROPERTIES
- QT_QML_MODULE_INSTALL_QMLTYPES TRUE
- QT_QML_MODULE_VERSION ${PROJECT_VERSION}
- QT_QML_MODULE_URI Qt.labs.settings
- QT_QMLTYPES_FILENAME plugins.qmltypes
- QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/Qt/labs/settings"
-)
-
-qt6_qml_type_registration(LabsSettings)
diff --git a/src/labs/sharedimage/CMakeLists.txt b/src/labs/sharedimage/CMakeLists.txt
index e1b4706043..b59c30d905 100644
--- a/src/labs/sharedimage/CMakeLists.txt
+++ b/src/labs/sharedimage/CMakeLists.txt
@@ -1,23 +1,25 @@
-qt_internal_add_module(LabsSharedImage
- SOURCES
+qt_internal_add_qml_module(LabsSharedImage
+ URI "Qt.labs.sharedimage"
+ VERSION "${PROJECT_VERSION}"
+ PLUGIN_TARGET sharedimageplugin
+ NO_PLUGIN_OPTIONAL
+ NO_GENERATE_PLUGIN_SOURCE
+ CLASS_NAME QtQuickSharedImagePlugin
+ SOURCES
qsharedimageloader.cpp qsharedimageloader_p.h
qsharedimageprovider.cpp qsharedimageprovider_p.h
qtlabssharedimageglobal_p.h
- DEFINES
+ DEFINES
QT_BUILD_LABSSHAREDIMAGE_LIB
- PUBLIC_LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
Qt::QuickPrivate
)
-
-set_target_properties(LabsSharedImage PROPERTIES
- QT_QML_MODULE_INSTALL_QMLTYPES TRUE
- QT_QML_MODULE_VERSION ${PROJECT_VERSION}
- QT_QML_MODULE_URI Qt.labs.sharedimage
- QT_QMLTYPES_FILENAME plugins.qmltypes
- QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/Qt/labs/sharedimage"
+# We need to do additional initialization, so we have to provide our own
+# plugin class rather than using the generated one
+qt_internal_extend_target(sharedimageplugin
+ SOURCES qsharedimageplugin.cpp
+ LIBRARIES Qt::LabsSharedImagePrivate
)
-
-qt6_qml_type_registration(LabsSharedImage)
diff --git a/src/labs/sharedimage/doc/src/qsharedimage.qdoc b/src/labs/sharedimage/doc/src/qsharedimage.qdoc
new file mode 100644
index 0000000000..119f49bf91
--- /dev/null
+++ b/src/labs/sharedimage/doc/src/qsharedimage.qdoc
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2021 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** 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 Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \qmlmodule Qt.labs.sharedimage 1
+ \title Qt Quick Shared Image Provider
+ \ingroup qmlmodules
+ \brief Adds an image provider which utilizes shared CPU memory
+
+ \section2 Summary
+
+ This module provides functionality to save memory in use cases where
+ several Qt Quick applications use the same local image files. It does this
+ by placing the decoded QImage data in shared system memory, making it
+ accessible to all the processes (see QSharedMemory).
+
+ This module only shares CPU memory. It does not provide sharing of GPU
+ memory or textures.
+
+ \section2 Usage
+
+ To use this module, import it like this:
+ \code
+ import Qt.labs.sharedimage
+ \endcode
+
+ The sharing functionality is provided through a QQuickImageProvider. Use
+ the "image:" scheme for the URL source of the image, followed by the
+ identifier \e shared, followed by the image file path. For example:
+
+ \code
+ Image { source: "image://shared/usr/share/wallpapers/mybackground.jpg" }
+ \endcode
+
+ This will look for the file \e /usr/share/wallpapers/mybackground.jpg.
+ The first process that does this will read the image file
+ using normal Qt image loading. The decoded image data will then be placed
+ in shared memory, using the full file path as key. Later processes
+ requesting the same image will discover that the data is already available
+ in shared memory. They will then use that instead of loading the image file
+ again.
+
+ The shared image data will be kept available until the last process has deleted
+ its last reference to the shared image, at which point it is automatically released.
+
+ If system memory sharing is not available, the shared image provider falls
+ back to normal, unshared image loading.
+
+ The file path must be absolute. To use a relative path, make it absolute
+ using \e Qt.resolvedUrl() and replace the URL scheme. For example:
+
+ \code
+ ...
+ property string imagePrefix: Qt.resolvedUrl("../myimages/").replace("file://", "image://shared/")
+ Image { source: imagePrefix + "myimage.png" }
+ \endcode
+
+ The shared image module does not provide any directly usable QML types.
+*/
diff --git a/src/labs/sharedimage/qsharedimageplugin.cpp b/src/labs/sharedimage/qsharedimageplugin.cpp
new file mode 100644
index 0000000000..dab68410f3
--- /dev/null
+++ b/src/labs/sharedimage/qsharedimageplugin.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins 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 <QtLabsSharedImage/private/qtlabssharedimageglobal_p.h>
+#include <QtLabsSharedImage/private/qsharedimageprovider_p.h>
+
+#include <qqmlextensionplugin.h>
+#include <qqmlengine.h>
+
+QT_BEGIN_NAMESPACE
+
+class QtQuickSharedImagePlugin : public QQmlEngineExtensionPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlEngineExtensionInterface_iid)
+public:
+ QtQuickSharedImagePlugin(QObject *parent = nullptr) : QQmlEngineExtensionPlugin(parent)
+ {
+ volatile auto registration = &qml_register_types_Qt_labs_sharedimage;
+ Q_UNUSED(registration);
+ }
+
+ void initializeEngine(QQmlEngine *engine, const char *uri) override
+ {
+ Q_UNUSED(uri);
+ engine->addImageProvider("shared", new SharedImageProvider);
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "qsharedimageplugin.moc"
diff --git a/src/labs/wavefrontmesh/CMakeLists.txt b/src/labs/wavefrontmesh/CMakeLists.txt
index 718bf09624..7a6c7a5cc0 100644
--- a/src/labs/wavefrontmesh/CMakeLists.txt
+++ b/src/labs/wavefrontmesh/CMakeLists.txt
@@ -1,22 +1,15 @@
-qt_internal_add_module(LabsWavefrontMesh
- SOURCES
- qwavefrontmesh.cpp qwavefrontmesh_p.h
- qqmlwavefrontmeshglobal_p.h
- DEFINES
+qt_internal_add_qml_module(LabsWavefrontMesh
+ URI "Qt.labs.wavefrontmesh"
+ VERSION "${PROJECT_VERSION}"
+ PLUGIN_TARGET qmlwavefrontmeshplugin
+ CLASS_NAME QmlWavefrontMeshPlugin
+ SOURCES
+ qwavefrontmesh.cpp qwavefrontmesh_p.h
+ qqmlwavefrontmeshglobal_p.h
+ DEFINES
QT_BUILD_LABSWAVEFRONTMESH_LIB
- PUBLIC_LIBRARIES
+ PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
Qt::QuickPrivate
)
-
-
-set_target_properties(LabsWavefrontMesh PROPERTIES
- QT_QML_MODULE_INSTALL_QMLTYPES TRUE
- QT_QML_MODULE_VERSION ${PROJECT_VERSION}
- QT_QML_MODULE_URI Qt.labs.wavefrontmesh
- QT_QMLTYPES_FILENAME plugins.qmltypes
- QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/Qt/labs/wavefrontmesh"
-)
-
-qt6_qml_type_registration(LabsWavefrontMesh)