QtQuick.LocalStorage: Make plugin optional
This moves the LocalStorage types into a new library and is meant to make them availabe to the QML compiler at some point in the future. Task-number: QTBUG-90487 Change-Id: I57ae8dc45a9ef3d5221520f656a2475bca2eb453 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
2506938d82
commit
fb6158732b
|
@ -13,6 +13,11 @@ if(QT_FEATURE_qml_worker_script)
|
||||||
add_subdirectory(qmlworkerscript)
|
add_subdirectory(qmlworkerscript)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(TARGET Qt::Sql)
|
||||||
|
add_subdirectory(qmllocalstorage)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(TARGET Qt::Gui AND QT_FEATURE_qml_animation)
|
if(TARGET Qt::Gui AND QT_FEATURE_qml_animation)
|
||||||
add_subdirectory(quick)
|
add_subdirectory(quick)
|
||||||
add_subdirectory(quickshapes)
|
add_subdirectory(quickshapes)
|
||||||
|
|
|
@ -9,15 +9,12 @@ qt_internal_add_qml_module(qmllocalstorageplugin
|
||||||
VERSION "${CMAKE_PROJECT_VERSION}"
|
VERSION "${CMAKE_PROJECT_VERSION}"
|
||||||
CLASSNAME QQmlLocalStoragePlugin
|
CLASSNAME QQmlLocalStoragePlugin
|
||||||
SKIP_TYPE_REGISTRATION
|
SKIP_TYPE_REGISTRATION
|
||||||
GENERATE_QMLTYPES
|
PLUGIN_OPTIONAL
|
||||||
INSTALL_QMLTYPES
|
|
||||||
SOURCES
|
SOURCES
|
||||||
plugin.cpp
|
plugin.cpp
|
||||||
qquicklocalstorage.cpp qquicklocalstorage_p.h
|
|
||||||
PUBLIC_LIBRARIES
|
PUBLIC_LIBRARIES
|
||||||
Qt::CorePrivate
|
Qt::Qml
|
||||||
Qt::QmlPrivate
|
Qt::QmlLocalStoragePrivate
|
||||||
Qt::Sql
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#### Keys ignored in scope 1:.:.:localstorage.pro:<TRUE>:
|
#### Keys ignored in scope 1:.:.:localstorage.pro:<TRUE>:
|
||||||
|
|
|
@ -37,12 +37,10 @@
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qquicklocalstorage_p.h"
|
|
||||||
|
|
||||||
#include <QtQml/qqmlextensionplugin.h>
|
#include <QtQml/qqmlextensionplugin.h>
|
||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
|
|
||||||
extern void qml_register_types_QtQuick_LocalStorage();
|
#include <QtQmlLocalStorage/private/qqmllocalstorageglobal_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
qt_internal_add_module(QmlLocalStorage
|
||||||
|
GENERATE_METATYPES
|
||||||
|
SOURCES
|
||||||
|
qqmllocalstorage.cpp qqmllocalstorage_p.h
|
||||||
|
qqmllocalstorageglobal_p.h
|
||||||
|
DEFINES
|
||||||
|
QT_BUILD_QMLLOCALSTORAGE_LIB
|
||||||
|
PUBLIC_LIBRARIES
|
||||||
|
Qt::CorePrivate
|
||||||
|
Qt::QmlPrivate
|
||||||
|
Qt::Sql
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(QmlLocalStorage PROPERTIES
|
||||||
|
QT_QML_MODULE_INSTALL_QMLTYPES TRUE
|
||||||
|
QT_QML_MODULE_VERSION ${CMAKE_PROJECT_VERSION}
|
||||||
|
QT_QML_MODULE_URI QtQuick.LocalStorage
|
||||||
|
QT_QMLTYPES_FILENAME plugins.qmltypes
|
||||||
|
QT_QML_MODULE_INSTALL_DIR "${INSTALL_QMLDIR}/QtQuick/LocalStorage"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
qt6_qml_type_registration(QmlLocalStorage)
|
|
@ -37,7 +37,7 @@
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qquicklocalstorage_p.h"
|
#include "qqmllocalstorage_p.h"
|
||||||
|
|
||||||
#include <QtQml/private/qqmlengine_p.h>
|
#include <QtQml/private/qqmlengine_p.h>
|
||||||
#include <QtQml/private/qv4global_p.h>
|
#include <QtQml/private/qv4global_p.h>
|
||||||
|
@ -714,7 +714,7 @@ Returns the created database object.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args)
|
void QQmlLocalStorage::openDatabaseSync(QQmlV4Function *args)
|
||||||
{
|
{
|
||||||
#if QT_CONFIG(settings)
|
#if QT_CONFIG(settings)
|
||||||
QV4::Scope scope(args->v4engine());
|
QV4::Scope scope(args->v4engine());
|
|
@ -37,8 +37,10 @@
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef QQUICKLOCALSTORAGE_P_H
|
#ifndef QQMLLOCALSTORAGE_P_H
|
||||||
#define QQUICKLOCALSTORAGE_P_H
|
#define QQMLLOCALSTORAGE_P_H
|
||||||
|
|
||||||
|
#include "qqmllocalstorageglobal_p.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// W A R N I N G
|
// W A R N I N G
|
||||||
|
@ -57,7 +59,7 @@
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QQuickLocalStorage : public QObject
|
class Q_QMLLOCALSTORAGE_PRIVATE_EXPORT QQmlLocalStorage : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
QML_NAMED_ELEMENT(LocalStorage)
|
QML_NAMED_ELEMENT(LocalStorage)
|
||||||
|
@ -65,12 +67,12 @@ class QQuickLocalStorage : public QObject
|
||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QQuickLocalStorage(QObject *parent = nullptr) : QObject(parent) {}
|
QQmlLocalStorage(QObject *parent = nullptr) : QObject(parent) {}
|
||||||
~QQuickLocalStorage() override = default;
|
~QQmlLocalStorage() override = default;
|
||||||
|
|
||||||
Q_INVOKABLE void openDatabaseSync(QQmlV4Function* args);
|
Q_INVOKABLE void openDatabaseSync(QQmlV4Function* args);
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QQUICKLOCALSTORAGE_P_H
|
#endif // QQMLLOCALSTORAGE_P_H
|
|
@ -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 QQMLLOCALSTORAGEGLOBAL_P_H
|
||||||
|
#define QQMLLOCALSTORAGEGLOBAL_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_QMLLOCALSTORAGE_LIB)
|
||||||
|
# define Q_QMLLOCALSTORAGE_EXPORT Q_DECL_EXPORT
|
||||||
|
# else
|
||||||
|
# define Q_QMLLOCALSTORAGE_EXPORT Q_DECL_IMPORT
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# define Q_QMLLOCALSTORAGE_EXPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define Q_QMLLOCALSTORAGE_PRIVATE_EXPORT Q_QMLLOCALSTORAGE_EXPORT
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
void Q_QMLLOCALSTORAGE_PRIVATE_EXPORT qml_register_types_QtQuick_LocalStorage();
|
||||||
|
|
||||||
|
#endif // QQMLLOCALSTORAGEGLOBAL_P_H
|
|
@ -12,6 +12,7 @@
|
||||||
"QtQmlCompiler" => "$basedir/src/qmlcompiler",
|
"QtQmlCompiler" => "$basedir/src/qmlcompiler",
|
||||||
"QtQmlDom" => "$basedir/src/qmldom",
|
"QtQmlDom" => "$basedir/src/qmldom",
|
||||||
"QtQuickLayouts" => "$basedir/src/quicklayouts",
|
"QtQuickLayouts" => "$basedir/src/quicklayouts",
|
||||||
|
"QtQmlLocalStorage" => "$basedir/src/qmllocalstorage"
|
||||||
);
|
);
|
||||||
%inject_headers = (
|
%inject_headers = (
|
||||||
"$basedir/src/qml" => [ "^qqmljsgrammar_p.h", "^qqmljsparser_p.h", "^qml_compile_hash_p.h" ],
|
"$basedir/src/qml" => [ "^qqmljsgrammar_p.h", "^qqmljsparser_p.h", "^qml_compile_hash_p.h" ],
|
||||||
|
|
Loading…
Reference in New Issue