Quick.Layouts: Make plugin optional

This moves the Layouts types into a new library and is meant to make
them availabe to the QML compiler at some point in the future.

Change-Id: I9b2b31a78b0e9ca8b6c0db1fc9272d9941c61814
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Fabian Kosmale 2021-01-15 10:45:18 +01:00
parent 704df6f141
commit 12115bbda2
16 changed files with 120 additions and 22 deletions

View File

@ -16,6 +16,7 @@ endif()
if(TARGET Qt::Gui AND QT_FEATURE_qml_animation)
add_subdirectory(quick)
add_subdirectory(quickshapes)
add_subdirectory(quicklayouts)
find_package(Qt6 ${PROJECT_VERSION} CONFIG COMPONENTS Test) # special case
if(QT_FEATURE_testlib AND TARGET Qt::Test) # special case

View File

@ -4,30 +4,24 @@
## qquicklayoutsplugin Plugin:
#####################################################################
qt_internal_add_qml_module(qquicklayoutsplugin
URI "QtQuick.Layouts"
VERSION "${CMAKE_PROJECT_VERSION}"
DESIGNER_SUPPORTED
CLASSNAME QtQuickLayoutsPlugin
SKIP_TYPE_REGISTRATION
GENERATE_QMLTYPES
INSTALL_QMLTYPES
PLUGIN_OPTIONAL
SOURCES
plugin.cpp
qquickgridlayoutengine.cpp qquickgridlayoutengine_p.h
qquicklayout.cpp qquicklayout_p.h
qquicklayoutstyleinfo.cpp qquicklayoutstyleinfo_p.h
qquicklinearlayout.cpp qquicklinearlayout_p.h
qquickstacklayout.cpp qquickstacklayout_p.h
PUBLIC_LIBRARIES
Qt::Core
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
Qt::QmlPrivate
Qt::QuickPrivate
Qt::Qml
Qt::QuickLayoutsPrivate
)
#### Keys ignored in scope 1:.:.:layouts.pro:<TRUE>:
# CXX_MODULE = "qml"
# QML_IMPORT_VERSION = "$$QT_VERSION"

View File

@ -38,11 +38,7 @@
****************************************************************************/
#include <QtQml/qqmlextensionplugin.h>
#include "qquicklinearlayout_p.h"
#include "qquickstacklayout_p.h"
extern void qml_register_types_QtQuick_Layouts();
#include <QtQuickLayouts/private/qquicklayoutglobal_p.h>
QT_BEGIN_NAMESPACE

View File

@ -0,0 +1,28 @@
qt_internal_add_module(QuickLayouts
GENERATE_METATYPES
SOURCES
qquickgridlayoutengine.cpp qquickgridlayoutengine_p.h
qquicklayout.cpp qquicklayout_p.h
qquicklayoutstyleinfo.cpp qquicklayoutstyleinfo_p.h
qquicklinearlayout.cpp qquicklinearlayout_p.h
qquickstacklayout.cpp qquickstacklayout_p.h
qquicklayoutglobal_p.h
DEFINES
QT_BUILD_QUICKLAYOUTS_LIB
PUBLIC_LIBRARIES
Qt::Core
Qt::GuiPrivate
Qt::QuickPrivate
Qt::Qml
)
set_target_properties(QuickLayouts PROPERTIES
QT_QML_MODULE_INSTALL_QMLTYPES TRUE
QT_QML_MODULE_VERSION ${CMAKE_PROJECT_VERSION}
QT_QML_MODULE_URI QtQuick.Layouts
QT_QMLTYPES_FILENAME plugins.qmltypes
QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/QtQuick/Layouts"
)
qt6_qml_type_registration(QuickLayouts)

View File

@ -42,6 +42,7 @@
#include <QPointer>
#include <QQuickItem>
#include <QtQuickLayouts/private/qquicklayoutglobal_p.h>
#include <private/qquickitem_p.h>
#include <QtQuick/private/qquickitemchangelistener_p.h>
#include <QtGui/private/qlayoutpolicy_p.h>
@ -52,7 +53,7 @@ class QQuickLayoutAttached;
Q_DECLARE_LOGGING_CATEGORY(lcQuickLayouts)
class QQuickLayoutPrivate;
class QQuickLayout : public QQuickItem, public QQuickItemChangeListener
class Q_QUICKLAYOUT_PRIVATE_EXPORT QQuickLayout : public QQuickItem, public QQuickItemChangeListener
{
Q_OBJECT

View File

@ -0,0 +1,75 @@
/****************************************************************************
**
** Copyright (C) 2021 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$
**
****************************************************************************/
#ifndef QQUICKLAYOUTGLOBAL_P_H
#define QQUICKLAYOUTGLOBAL_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
#if !defined(QT_STATIC)
# if defined(QT_BUILD_QUICKLAYOUTS_LIB)
# define Q_QUICKLAYOUT_EXPORT Q_DECL_EXPORT
# else
# define Q_QUICKLAYOUT_EXPORT Q_DECL_IMPORT
# endif
#else
# define Q_QUICKLAYOUT_EXPORT
#endif
#define Q_QUICKLAYOUT_PRIVATE_EXPORT Q_QUICKLAYOUT_EXPORT
QT_END_NAMESPACE
void Q_QUICKLAYOUT_PRIVATE_EXPORT qml_register_types_QtQuick_Layouts();
#endif // QQUICKLAYOUTGLOBAL_P_H

View File

@ -40,6 +40,7 @@
#ifndef QQUICKLINEARLAYOUT_P_H
#define QQUICKLINEARLAYOUT_P_H
#include <QtQuickLayouts/private/qquicklayoutglobal_p.h>
#include "qquicklayout_p.h"
#include "qquickgridlayoutengine_p.h"
@ -52,7 +53,7 @@ QT_BEGIN_NAMESPACE
**/
class QQuickGridLayoutBasePrivate;
class QQuickGridLayoutBase : public QQuickLayout
class Q_QUICKLAYOUT_PRIVATE_EXPORT QQuickGridLayoutBase : public QQuickLayout
{
Q_OBJECT
@ -136,7 +137,7 @@ public:
**
**/
class QQuickGridLayoutPrivate;
class QQuickGridLayout : public QQuickGridLayoutBase
class Q_QUICKLAYOUT_PRIVATE_EXPORT QQuickGridLayout : public QQuickGridLayoutBase
{
Q_OBJECT
@ -227,7 +228,7 @@ public:
** QQuickRowLayout
**
**/
class QQuickRowLayout : public QQuickLinearLayout
class Q_QUICKLAYOUT_PRIVATE_EXPORT QQuickRowLayout : public QQuickLinearLayout
{
Q_OBJECT
QML_NAMED_ELEMENT(RowLayout)
@ -244,7 +245,7 @@ public:
** QQuickColumnLayout
**
**/
class QQuickColumnLayout : public QQuickLinearLayout
class Q_QUICKLAYOUT_PRIVATE_EXPORT QQuickColumnLayout : public QQuickLinearLayout
{
Q_OBJECT
QML_NAMED_ELEMENT(ColumnLayout)

View File

@ -40,6 +40,7 @@
#ifndef QQUICKSTACKLAYOUT_H
#define QQUICKSTACKLAYOUT_H
#include <QtQuickLayouts/private/qquicklayoutglobal_p.h>
#include <qquicklayout_p.h>
QT_BEGIN_NAMESPACE
@ -47,7 +48,7 @@ QT_BEGIN_NAMESPACE
class QQuickStackLayoutPrivate;
class QQuickStackLayoutAttached;
class QQuickStackLayout : public QQuickLayout
class Q_QUICKLAYOUT_PRIVATE_EXPORT QQuickStackLayout : public QQuickLayout
{
Q_OBJECT
Q_PROPERTY(int count READ count NOTIFY countChanged)

View File

@ -11,6 +11,7 @@
"QtQmlWorkerScript" => "$basedir/src/qmlworkerscript",
"QtQmlCompiler" => "$basedir/src/qmlcompiler",
"QtQmlDom" => "$basedir/src/qmldom",
"QtQuickLayouts" => "$basedir/src/quicklayouts",
);
%inject_headers = (
"$basedir/src/qml" => [ "^qqmljsgrammar_p.h", "^qqmljsparser_p.h", "^qml_compile_hash_p.h" ],