aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2021-01-20 11:25:25 +0100
committerMaximilian Goldstein <max.goldstein@qt.io>2021-01-20 15:20:52 +0100
commitfb6158732b6615d26e7800a2a7821fe854363d29 (patch)
tree7ca4a7a9db0302a1572258a6644d291f02bf24b5 /src
parent2506938d829bf146e45e121116f870942c0453e1 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt5
-rw-r--r--src/imports/localstorage/CMakeLists.txt9
-rw-r--r--src/imports/localstorage/plugin.cpp4
-rw-r--r--src/qmllocalstorage/CMakeLists.txt23
-rw-r--r--src/qmllocalstorage/qqmllocalstorage.cpp (renamed from src/imports/localstorage/qquicklocalstorage.cpp)4
-rw-r--r--src/qmllocalstorage/qqmllocalstorage_p.h (renamed from src/imports/localstorage/qquicklocalstorage_p.h)14
-rw-r--r--src/qmllocalstorage/qqmllocalstorageglobal_p.h75
7 files changed, 117 insertions, 17 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 25c2be3648..41efafb6d8 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -13,6 +13,11 @@ if(QT_FEATURE_qml_worker_script)
add_subdirectory(qmlworkerscript)
endif()
+if(TARGET Qt::Sql)
+ add_subdirectory(qmllocalstorage)
+ endif()
+
+
if(TARGET Qt::Gui AND QT_FEATURE_qml_animation)
add_subdirectory(quick)
add_subdirectory(quickshapes)
diff --git a/src/imports/localstorage/CMakeLists.txt b/src/imports/localstorage/CMakeLists.txt
index 305d9ad178..9d7cd13fe0 100644
--- a/src/imports/localstorage/CMakeLists.txt
+++ b/src/imports/localstorage/CMakeLists.txt
@@ -9,15 +9,12 @@ qt_internal_add_qml_module(qmllocalstorageplugin
VERSION "${CMAKE_PROJECT_VERSION}"
CLASSNAME QQmlLocalStoragePlugin
SKIP_TYPE_REGISTRATION
- GENERATE_QMLTYPES
- INSTALL_QMLTYPES
+ PLUGIN_OPTIONAL
SOURCES
plugin.cpp
- qquicklocalstorage.cpp qquicklocalstorage_p.h
PUBLIC_LIBRARIES
- Qt::CorePrivate
- Qt::QmlPrivate
- Qt::Sql
+ Qt::Qml
+ Qt::QmlLocalStoragePrivate
)
#### Keys ignored in scope 1:.:.:localstorage.pro:<TRUE>:
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index e488b3d43c..766469e4f6 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -37,12 +37,10 @@
**
****************************************************************************/
-#include "qquicklocalstorage_p.h"
-
#include <QtQml/qqmlextensionplugin.h>
#include <QtQml/qqml.h>
-extern void qml_register_types_QtQuick_LocalStorage();
+#include <QtQmlLocalStorage/private/qqmllocalstorageglobal_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/qmllocalstorage/CMakeLists.txt b/src/qmllocalstorage/CMakeLists.txt
new file mode 100644
index 0000000000..7c6846dce1
--- /dev/null
+++ b/src/qmllocalstorage/CMakeLists.txt
@@ -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)
diff --git a/src/imports/localstorage/qquicklocalstorage.cpp b/src/qmllocalstorage/qqmllocalstorage.cpp
index 0124598e83..56b48189ba 100644
--- a/src/imports/localstorage/qquicklocalstorage.cpp
+++ b/src/qmllocalstorage/qqmllocalstorage.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qquicklocalstorage_p.h"
+#include "qqmllocalstorage_p.h"
#include <QtQml/private/qqmlengine_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)
QV4::Scope scope(args->v4engine());
diff --git a/src/imports/localstorage/qquicklocalstorage_p.h b/src/qmllocalstorage/qqmllocalstorage_p.h
index f90d6bad28..ad0ac57278 100644
--- a/src/imports/localstorage/qquicklocalstorage_p.h
+++ b/src/qmllocalstorage/qqmllocalstorage_p.h
@@ -37,8 +37,10 @@
**
****************************************************************************/
-#ifndef QQUICKLOCALSTORAGE_P_H
-#define QQUICKLOCALSTORAGE_P_H
+#ifndef QQMLLOCALSTORAGE_P_H
+#define QQMLLOCALSTORAGE_P_H
+
+#include "qqmllocalstorageglobal_p.h"
//
// W A R N I N G
@@ -57,7 +59,7 @@
QT_BEGIN_NAMESPACE
-class QQuickLocalStorage : public QObject
+class Q_QMLLOCALSTORAGE_PRIVATE_EXPORT QQmlLocalStorage : public QObject
{
Q_OBJECT
QML_NAMED_ELEMENT(LocalStorage)
@@ -65,12 +67,12 @@ class QQuickLocalStorage : public QObject
QML_SINGLETON
public:
- QQuickLocalStorage(QObject *parent = nullptr) : QObject(parent) {}
- ~QQuickLocalStorage() override = default;
+ QQmlLocalStorage(QObject *parent = nullptr) : QObject(parent) {}
+ ~QQmlLocalStorage() override = default;
Q_INVOKABLE void openDatabaseSync(QQmlV4Function* args);
};
QT_END_NAMESPACE
-#endif // QQUICKLOCALSTORAGE_P_H
+#endif // QQMLLOCALSTORAGE_P_H
diff --git a/src/qmllocalstorage/qqmllocalstorageglobal_p.h b/src/qmllocalstorage/qqmllocalstorageglobal_p.h
new file mode 100644
index 0000000000..5eb13cce68
--- /dev/null
+++ b/src/qmllocalstorage/qqmllocalstorageglobal_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