summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2023-02-02 08:43:05 +0100
committerMichal Klocek <michal.klocek@qt.io>2023-02-03 13:37:42 +0100
commit48d2066d6c9b38f29368e5205a5b7f49ab3fa857 (patch)
treec40f1f840b7450248e1a0549c0caa75b6d536dd9
parent165ecd37b44e6c96c0e85afc5ea4a1bc392e035e (diff)
downloadqtwebchannel-48d2066d6c9b38f29368e5205a5b7f49ab3fa857.tar.gz
Fix project structure and auto registry
Create QtWebChannelQuick and move the required sources, so auto registry works and qml types files and friends are auto generated. This makes things inline what other modules do. This change has a side effect as qqmlwebchannel.h will change its module, however this is semi-pulibc header, hopefully only used by QtWebEngine. [ChangeLog] Created new QtWebChannelQuick which holds qml sources. Task-number: QTBUG-110795 Fixes: QTBUG-99959 Change-Id: Ic8aa72f070d6a9e23d918a1210f4df62df739397 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/imports/CMakeLists.txt6
-rw-r--r--src/imports/webchannel/CMakeLists.txt32
-rw-r--r--src/imports/webchannel/dependencies.json2
-rw-r--r--src/imports/webchannel/plugin.cpp35
-rw-r--r--src/imports/webchannel/plugins.qmltypes67
-rw-r--r--src/imports/webchannel/qmldir4
-rw-r--r--src/webchannel/CMakeLists.txt48
-rw-r--r--src/webchannel/doc/qtwebchannel.qdocconf4
-rw-r--r--src/webchannel/qwebchannel_p.h2
-rw-r--r--src/webchannel/signalhandler_p.h1
-rw-r--r--src/webchannelquick/CMakeLists.txt15
-rw-r--r--src/webchannelquick/qqmlwebchannel.cpp (renamed from src/webchannel/qqmlwebchannel.cpp)63
-rw-r--r--src/webchannelquick/qqmlwebchannel.h (renamed from src/webchannel/qqmlwebchannel.h)21
-rw-r--r--src/webchannelquick/qqmlwebchannelattached.cpp (renamed from src/webchannel/qqmlwebchannelattached.cpp)17
-rw-r--r--src/webchannelquick/qqmlwebchannelattached_p.h (renamed from src/webchannel/qqmlwebchannelattached_p.h)15
-rw-r--r--src/webchannelquick/qwebchannelquickglobal.h10
-rw-r--r--tests/auto/qml/CMakeLists.txt14
-rw-r--r--tests/auto/qml/testwebchannel.cpp4
-rw-r--r--tests/auto/qml/testwebchannel.h2
-rw-r--r--tests/auto/webchannel/CMakeLists.txt11
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp6
22 files changed, 105 insertions, 276 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fa1d28d..8eee8c5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,5 +5,5 @@
add_subdirectory(webchannel)
if(TARGET Qt::Quick)
- add_subdirectory(imports)
+ add_subdirectory(webchannelquick)
endif()
diff --git a/src/imports/CMakeLists.txt b/src/imports/CMakeLists.txt
deleted file mode 100644
index e3c2e04..0000000
--- a/src/imports/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-# Generated from imports.pro.
-
-add_subdirectory(webchannel)
diff --git a/src/imports/webchannel/CMakeLists.txt b/src/imports/webchannel/CMakeLists.txt
deleted file mode 100644
index 52405c8..0000000
--- a/src/imports/webchannel/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-# Generated from webchannel.pro.
-
-#####################################################################
-## webchannel Plugin:
-#####################################################################
-
-qt_internal_add_qml_module(webchannel
- URI "QtWebChannel"
- VERSION "${PROJECT_VERSION}"
- PAST_MAJOR_VERSIONS 1
- CLASS_NAME QWebChannelPlugin
- PLUGIN_TARGET webchannel
- NO_PLUGIN_OPTIONAL
- NO_GENERATE_PLUGIN_SOURCE
- NO_GENERATE_QMLTYPES
- INSTALL_SOURCE_QMLTYPES "plugins.qmltypes"
- SOURCES
- plugin.cpp
- INCLUDE_DIRECTORIES
- ../../webchannel
- LIBRARIES
- Qt::Core
- Qt::Quick
- Qt::WebChannelPrivate
-)
-
-#### Keys ignored in scope 1:.:.:webchannel.pro:<TRUE>:
-# IMPORT_VERSION = "1.$$QT_MINOR_VERSION"
-# TARGETPATH = "QtWebChannel"
diff --git a/src/imports/webchannel/dependencies.json b/src/imports/webchannel/dependencies.json
deleted file mode 100644
index 0d4f101..0000000
--- a/src/imports/webchannel/dependencies.json
+++ /dev/null
@@ -1,2 +0,0 @@
-[
-]
diff --git a/src/imports/webchannel/plugin.cpp b/src/imports/webchannel/plugin.cpp
deleted file mode 100644
index 2914bb4..0000000
--- a/src/imports/webchannel/plugin.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
-
-#include <qqml.h>
-#include <QtQml/QQmlExtensionPlugin>
-
-#include <qqmlwebchannel.h>
-#include <qqmlwebchannelattached_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWebChannelPlugin : public QQmlExtensionPlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
-
-public:
- QWebChannelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { }
- void registerTypes(const char *uri) override;
-};
-
-void QWebChannelPlugin::registerTypes(const char *uri)
-{
- int major = 1;
- int minor = 0;
- qmlRegisterType<QQmlWebChannel>(uri, major, minor, "WebChannel");
-
- // The minor version used to be the current Qt 5 minor. For compatibility it is the last
- // Qt 5 release.
- qmlRegisterModule(uri, major, 15);
-}
-
-QT_END_NAMESPACE
-
-#include "plugin.moc"
diff --git a/src/imports/webchannel/plugins.qmltypes b/src/imports/webchannel/plugins.qmltypes
deleted file mode 100644
index 68378d6..0000000
--- a/src/imports/webchannel/plugins.qmltypes
+++ /dev/null
@@ -1,67 +0,0 @@
-import QtQuick.tooling 1.2
-
-// This file describes the plugin-supplied types contained in the library.
-// It is used for QML tooling purposes only.
-//
-// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtWebChannel 1.15'
-
-Module {
- dependencies: []
- Component {
- name: "QQmlWebChannel"
- prototype: "QWebChannel"
- exports: ["QtWebChannel/WebChannel 1.0"]
- exportMetaObjectRevisions: [0]
- attachedType: "QQmlWebChannelAttached"
- Property { name: "transports"; type: "QObject"; isList: true; isReadonly: true }
- Property { name: "registeredObjects"; type: "QObject"; isList: true; isReadonly: true }
- Method {
- name: "registerObjects"
- Parameter { name: "objects"; type: "QVariantMap" }
- }
- Method {
- name: "connectTo"
- Parameter { name: "transport"; type: "QObject"; isPointer: true }
- }
- Method {
- name: "disconnectFrom"
- Parameter { name: "transport"; type: "QObject"; isPointer: true }
- }
- }
- Component {
- name: "QQmlWebChannelAttached"
- prototype: "QObject"
- Property { name: "id"; type: "string" }
- Signal {
- name: "idChanged"
- Parameter { name: "id"; type: "string" }
- }
- }
- Component {
- name: "QWebChannel"
- prototype: "QObject"
- Property { name: "blockUpdates"; type: "bool" }
- Signal {
- name: "blockUpdatesChanged"
- Parameter { name: "block"; type: "bool" }
- }
- Method {
- name: "connectTo"
- Parameter { name: "transport"; type: "QWebChannelAbstractTransport"; isPointer: true }
- }
- Method {
- name: "disconnectFrom"
- Parameter { name: "transport"; type: "QWebChannelAbstractTransport"; isPointer: true }
- }
- Method {
- name: "registerObject"
- Parameter { name: "id"; type: "string" }
- Parameter { name: "object"; type: "QObject"; isPointer: true }
- }
- Method {
- name: "deregisterObject"
- Parameter { name: "object"; type: "QObject"; isPointer: true }
- }
- }
-}
diff --git a/src/imports/webchannel/qmldir b/src/imports/webchannel/qmldir
deleted file mode 100644
index c521f2f..0000000
--- a/src/imports/webchannel/qmldir
+++ /dev/null
@@ -1,4 +0,0 @@
-module QtWebChannel
-classname QWebChannelPlugin
-plugin declarative_webchannel
-typeinfo plugins.qmltypes
diff --git a/src/webchannel/CMakeLists.txt b/src/webchannel/CMakeLists.txt
index 9354973..fd5c08b 100644
--- a/src/webchannel/CMakeLists.txt
+++ b/src/webchannel/CMakeLists.txt
@@ -1,13 +1,8 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from webchannel.pro.
-
-#####################################################################
-## WebChannel Module:
-#####################################################################
-
qt_internal_add_module(WebChannel
+ GENERATE_CPP_EXPORTS
SOURCES
qmetaobjectpublisher.cpp qmetaobjectpublisher_p.h
qwebchannel.cpp qwebchannel.h qwebchannel_p.h
@@ -16,49 +11,26 @@ qt_internal_add_module(WebChannel
qwebchannelglobal.h
LIBRARIES
Qt::CorePrivate
- PUBLIC_LIBRARIES
- Qt::Core
- PRIVATE_MODULE_INTERFACE
- Qt::CorePrivate
- GENERATE_CPP_EXPORTS
)
-# Resources:
-set_source_files_properties("../../examples/webchannel/shared/qwebchannel.js"
- PROPERTIES QT_RESOURCE_ALIAS "qwebchannel.js"
-)
-set(resources_resource_files
- "../../examples/webchannel/shared/qwebchannel.js"
+set(resource_file "../../examples/webchannel/shared/qwebchannel.js")
+set_source_files_properties(${resource_file} PROPERTIES
+ QT_RESOURCE_ALIAS "qwebchannel.js"
)
-set_source_files_properties(${resources_resource_files} PROPERTIES QT_SKIP_QUICKCOMPILER 1)
-
qt_internal_add_resource(WebChannel "resources"
PREFIX
"/qtwebchannel/"
FILES
- ${resources_resource_files}
+ ${resource_file}
)
+if(TARGET Qt::Qml)
+ qt_internal_extend_target(WebChannel PUBLIC_LIBRARIES Qt::Qml)
+else()
+ qt_internal_extend_target(WebChannel DEFINES QT_NO_JSVALUE)
+endif()
-#### Keys ignored in scope 1:.:.:webchannel.pro:<TRUE>:
-# OTHER_FILES = "qwebchannel.js"
-
-## Scopes:
-#####################################################################
-
-qt_internal_extend_target(WebChannel CONDITION TARGET Qt::Qml
- SOURCES
- qqmlwebchannel.cpp qqmlwebchannel.h
- qqmlwebchannelattached.cpp qqmlwebchannelattached_p.h
- PUBLIC_LIBRARIES
- Qt::Qml
-)
-
-qt_internal_extend_target(WebChannel CONDITION NOT TARGET Qt::Qml
- DEFINES
- QT_NO_JSVALUE
-)
qt_internal_add_docs(WebChannel
doc/qtwebchannel.qdocconf
)
diff --git a/src/webchannel/doc/qtwebchannel.qdocconf b/src/webchannel/doc/qtwebchannel.qdocconf
index 766e73f..b77d5f3 100644
--- a/src/webchannel/doc/qtwebchannel.qdocconf
+++ b/src/webchannel/doc/qtwebchannel.qdocconf
@@ -40,10 +40,10 @@ tagfile = ../../../doc/qtwebchannel/
depends += qtcore qtquick qtqml qtdoc qtwebengine qtwebsockets qmake qtcmake
headerdirs += .. \
- ../../imports
+ ../../webchannelquick
sourcedirs += .. \
- ../../imports
+ ../../webchannelquick
imagedirs += images
diff --git a/src/webchannel/qwebchannel_p.h b/src/webchannel/qwebchannel_p.h
index 7aad0ab..71cf4a7 100644
--- a/src/webchannel/qwebchannel_p.h
+++ b/src/webchannel/qwebchannel_p.h
@@ -17,7 +17,7 @@
#include "qwebchannelglobal.h"
-#include <private/qobject_p.h>
+#include <QtCore/private/qobject_p.h>
#include <QList>
QT_BEGIN_NAMESPACE
diff --git a/src/webchannel/signalhandler_p.h b/src/webchannel/signalhandler_p.h
index 3431f1b..022762a 100644
--- a/src/webchannel/signalhandler_p.h
+++ b/src/webchannel/signalhandler_p.h
@@ -21,7 +21,6 @@
#include <QMetaMethod>
#include <QDebug>
#include <QThread>
-#include <private/qglobal_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/webchannelquick/CMakeLists.txt b/src/webchannelquick/CMakeLists.txt
new file mode 100644
index 0000000..0c88145
--- /dev/null
+++ b/src/webchannelquick/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+qt_internal_add_qml_module(WebChannelQuick
+ URI "QtWebChannel"
+ VERSION "${PROJECT_VERSION}"
+ PAST_MAJOR_VERSIONS 1
+ GENERATE_CPP_EXPORTS
+ SOURCES
+ qqmlwebchannel.h qqmlwebchannel.cpp
+ qqmlwebchannelattached_p.h qqmlwebchannelattached.cpp
+ qwebchannelquickglobal.h
+ LIBRARIES
+ Qt::WebChannelPrivate
+)
diff --git a/src/webchannel/qqmlwebchannel.cpp b/src/webchannelquick/qqmlwebchannel.cpp
index c8f8bd8..b0d803d 100644
--- a/src/webchannel/qqmlwebchannel.cpp
+++ b/src/webchannelquick/qqmlwebchannel.cpp
@@ -1,12 +1,11 @@
-// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
+// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author
+// Milian Wolff <milian.wolff@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qqmlwebchannel.h"
-
-#include "qwebchannel_p.h"
-#include "qmetaobjectpublisher_p.h"
-#include "qwebchannelabstracttransport.h"
-
+#include <QtWebChannel/qwebchannelabstracttransport.h>
+#include <QtWebChannel/private/qwebchannel_p.h>
+#include <QtWebChannel/private/qmetaobjectpublisher_p.h>
#include <QtQml/QQmlContext>
#include "qqmlwebchannelattached_p.h"
@@ -71,7 +70,8 @@ public:
void QQmlWebChannelPrivate::_q_objectIdChanged(const QString &newId)
{
Q_Q(QQmlWebChannel);
- const QQmlWebChannelAttached *const attached = qobject_cast<QQmlWebChannelAttached*>(q->sender());
+ const QQmlWebChannelAttached *const attached =
+ qobject_cast<QQmlWebChannelAttached *>(q->sender());
Q_ASSERT(attached);
Q_ASSERT(attached->parent());
Q_ASSERT(registeredObjects.contains(attached->parent()));
@@ -86,15 +86,11 @@ void QQmlWebChannelPrivate::_q_objectIdChanged(const QString &newId)
q->registerObject(newId, object);
}
-QQmlWebChannel::QQmlWebChannel(QObject *parent)
- : QWebChannel(*(new QQmlWebChannelPrivate), parent)
+QQmlWebChannel::QQmlWebChannel(QObject *parent) : QWebChannel(*(new QQmlWebChannelPrivate), parent)
{
}
-QQmlWebChannel::~QQmlWebChannel()
-{
-
-}
+QQmlWebChannel::~QQmlWebChannel() { }
/*!
\qmlmethod void WebChannel::registerObjects(QVariantMap objects)
@@ -104,8 +100,8 @@ QQmlWebChannel::~QQmlWebChannel()
Once registered, all signals and property changes are automatically propagated to the clients.
Public invokable methods, including slots, are also accessible to the clients.
- This imperative API can be used to register objects on the fly. For static objects, the declarative
- registeredObjects property should be preferred.
+ This imperative API can be used to register objects on the fly. For static objects, the
+ declarative registeredObjects property should be preferred.
\sa registeredObjects
*/
@@ -114,7 +110,7 @@ void QQmlWebChannel::registerObjects(const QVariantMap &objects)
Q_D(QQmlWebChannel);
QMap<QString, QVariant>::const_iterator it = objects.constBegin();
for (; it != objects.constEnd(); ++it) {
- QObject *object = it.value().value<QObject*>();
+ QObject *object = it.value().value<QObject *>();
if (!object) {
qWarning("Invalid QObject given to register under name %s", qPrintable(it.key()));
continue;
@@ -140,10 +136,12 @@ QQmlWebChannelAttached *QQmlWebChannel::qmlAttachedProperties(QObject *obj)
*/
void QQmlWebChannel::connectTo(QObject *transport)
{
- if (QWebChannelAbstractTransport *realTransport = qobject_cast<QWebChannelAbstractTransport*>(transport)) {
+ if (QWebChannelAbstractTransport *realTransport =
+ qobject_cast<QWebChannelAbstractTransport *>(transport)) {
QWebChannel::connectTo(realTransport);
} else {
- qWarning() << "Cannot connect to transport" << transport << " - it is not a QWebChannelAbstractTransport.";
+ qWarning() << "Cannot connect to transport" << transport
+ << " - it is not a QWebChannelAbstractTransport.";
}
}
@@ -159,10 +157,12 @@ void QQmlWebChannel::connectTo(QObject *transport)
*/
void QQmlWebChannel::disconnectFrom(QObject *transport)
{
- if (QWebChannelAbstractTransport *realTransport = qobject_cast<QWebChannelAbstractTransport*>(transport)) {
+ if (QWebChannelAbstractTransport *realTransport =
+ qobject_cast<QWebChannelAbstractTransport *>(transport)) {
QWebChannel::disconnectFrom(realTransport);
} else {
- qWarning() << "Cannot disconnect from transport" << transport << " - it is not a QWebChannelAbstractTransport.";
+ qWarning() << "Cannot disconnect from transport" << transport
+ << " - it is not a QWebChannelAbstractTransport.";
}
}
@@ -175,14 +175,15 @@ QQmlListProperty<QObject> QQmlWebChannel::registeredObjects()
void QQmlWebChannel::registeredObjects_append(QQmlListProperty<QObject> *prop, QObject *object)
{
- const QQmlWebChannelAttached *const attached = qobject_cast<QQmlWebChannelAttached*>(
- qmlAttachedPropertiesObject<QQmlWebChannel>(object, false /* don't create */));
+ const QQmlWebChannelAttached *const attached = qobject_cast<QQmlWebChannelAttached *>(
+ qmlAttachedPropertiesObject<QQmlWebChannel>(object, false /* don't create */));
if (!attached) {
const QQmlContext *const context = qmlContext(object);
- qWarning() << "Cannot register object" << context->nameForObject(object) << '(' << object << ") without attached WebChannel.id property. Did you forget to set it?";
+ qWarning() << "Cannot register object" << context->nameForObject(object) << '(' << object
+ << ") without attached WebChannel.id property. Did you forget to set it?";
return;
}
- QQmlWebChannel *channel = static_cast<QQmlWebChannel*>(prop->object);
+ QQmlWebChannel *channel = static_cast<QQmlWebChannel *>(prop->object);
if (!attached->id().isEmpty()) {
// TODO: warning in such cases?
channel->registerObject(attached->id(), object);
@@ -193,17 +194,17 @@ void QQmlWebChannel::registeredObjects_append(QQmlListProperty<QObject> *prop, Q
qsizetype QQmlWebChannel::registeredObjects_count(QQmlListProperty<QObject> *prop)
{
- return static_cast<QQmlWebChannel*>(prop->object)->d_func()->registeredObjects.size();
+ return static_cast<QQmlWebChannel *>(prop->object)->d_func()->registeredObjects.size();
}
QObject *QQmlWebChannel::registeredObjects_at(QQmlListProperty<QObject> *prop, qsizetype index)
{
- return static_cast<QQmlWebChannel*>(prop->object)->d_func()->registeredObjects.at(index);
+ return static_cast<QQmlWebChannel *>(prop->object)->d_func()->registeredObjects.at(index);
}
void QQmlWebChannel::registeredObjects_clear(QQmlListProperty<QObject> *prop)
{
- QQmlWebChannel *channel = static_cast<QQmlWebChannel*>(prop->object);
+ QQmlWebChannel *channel = static_cast<QQmlWebChannel *>(prop->object);
foreach (QObject *object, channel->d_func()->registeredObjects) {
channel->deregisterObject(object);
}
@@ -218,24 +219,24 @@ QQmlListProperty<QObject> QQmlWebChannel::transports()
void QQmlWebChannel::transports_append(QQmlListProperty<QObject> *prop, QObject *transport)
{
- QQmlWebChannel *channel = static_cast<QQmlWebChannel*>(prop->object);
+ QQmlWebChannel *channel = static_cast<QQmlWebChannel *>(prop->object);
channel->connectTo(transport);
}
qsizetype QQmlWebChannel::transports_count(QQmlListProperty<QObject> *prop)
{
- return static_cast<QQmlWebChannel*>(prop->object)->d_func()->transports.size();
+ return static_cast<QQmlWebChannel *>(prop->object)->d_func()->transports.size();
}
QObject *QQmlWebChannel::transports_at(QQmlListProperty<QObject> *prop, qsizetype index)
{
- QQmlWebChannel *channel = static_cast<QQmlWebChannel*>(prop->object);
+ QQmlWebChannel *channel = static_cast<QQmlWebChannel *>(prop->object);
return channel->d_func()->transports.at(index);
}
void QQmlWebChannel::transports_clear(QQmlListProperty<QObject> *prop)
{
- QWebChannel *channel = static_cast<QWebChannel*>(prop->object);
+ QWebChannel *channel = static_cast<QWebChannel *>(prop->object);
foreach (QWebChannelAbstractTransport *transport, channel->d_func()->transports) {
channel->disconnectFrom(transport);
}
diff --git a/src/webchannel/qqmlwebchannel.h b/src/webchannelquick/qqmlwebchannel.h
index f57a510..292ea6c 100644
--- a/src/webchannel/qqmlwebchannel.h
+++ b/src/webchannelquick/qqmlwebchannel.h
@@ -1,11 +1,12 @@
-// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
+// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author
+// Milian Wolff <milian.wolff@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QQMLWEBCHANNEL_H
#define QQMLWEBCHANNEL_H
-#include <QtWebChannel/QWebChannel>
-#include <QtWebChannel/qwebchannelglobal.h>
+#include <QtWebChannelQuick/qwebchannelquickglobal.h>
+#include <QtWebChannel/qwebchannel.h>
#include <QtQml/qqml.h>
#include <QtQml/QQmlListProperty>
@@ -14,14 +15,16 @@ QT_BEGIN_NAMESPACE
class QQmlWebChannelPrivate;
class QQmlWebChannelAttached;
-class Q_WEBCHANNEL_EXPORT QQmlWebChannel : public QWebChannel
+class Q_WEBCHANNELQUICK_EXPORT QQmlWebChannel : public QWebChannel
{
Q_OBJECT
Q_DISABLE_COPY(QQmlWebChannel)
- Q_PROPERTY( QQmlListProperty<QObject> transports READ transports )
- Q_PROPERTY( QQmlListProperty<QObject> registeredObjects READ registeredObjects )
-
+ Q_PROPERTY(QQmlListProperty<QObject> transports READ transports)
+ Q_PROPERTY(QQmlListProperty<QObject> registeredObjects READ registeredObjects)
+ QML_NAMED_ELEMENT(WebChannel)
+ QML_ATTACHED(QQmlWebChannelAttached)
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit QQmlWebChannel(QObject *parent = nullptr);
virtual ~QQmlWebChannel();
@@ -53,7 +56,7 @@ private:
QT_END_NAMESPACE
-QML_DECLARE_TYPE( QQmlWebChannel )
-QML_DECLARE_TYPEINFO( QQmlWebChannel, QML_HAS_ATTACHED_PROPERTIES )
+QML_DECLARE_TYPE(QQmlWebChannel)
+QML_DECLARE_TYPEINFO(QQmlWebChannel, QML_HAS_ATTACHED_PROPERTIES)
#endif // QQMLWEBCHANNEL_H
diff --git a/src/webchannel/qqmlwebchannelattached.cpp b/src/webchannelquick/qqmlwebchannelattached.cpp
index 5019590..5bbd1be 100644
--- a/src/webchannel/qqmlwebchannelattached.cpp
+++ b/src/webchannelquick/qqmlwebchannelattached.cpp
@@ -1,25 +1,20 @@
-// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
+// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author
+// Milian Wolff <milian.wolff@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qqmlwebchannelattached_p.h"
QT_USE_NAMESPACE
-QQmlWebChannelAttached::QQmlWebChannelAttached(QObject *parent)
- : QObject(parent)
-{
-
-}
+QQmlWebChannelAttached::QQmlWebChannelAttached(QObject *parent) : QObject(parent) { }
-QQmlWebChannelAttached::~QQmlWebChannelAttached()
-{
-
-}
+QQmlWebChannelAttached::~QQmlWebChannelAttached() { }
/*!
\qmlattachedproperty QString WebChannel::id
- \brief The identifier under which an object, registered to a WebChannel, is known to remote clients.
+ \brief The identifier under which an object, registered to a WebChannel, is known to remote
+ clients.
This property must be set for every object that should be published over the WebChannel.
While no restrictions are enforced on the format of the id, it is usually a good idea to
diff --git a/src/webchannel/qqmlwebchannelattached_p.h b/src/webchannelquick/qqmlwebchannelattached_p.h
index c4c70fd..c3d715e 100644
--- a/src/webchannel/qqmlwebchannelattached_p.h
+++ b/src/webchannelquick/qqmlwebchannelattached_p.h
@@ -1,4 +1,5 @@
-// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Milian Wolff <milian.wolff@kdab.com>
+// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author
+// Milian Wolff <milian.wolff@kdab.com>
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QQMLWEBCHANNELATTACHED_H
@@ -16,17 +17,17 @@
//
#include <QObject>
-
-#include "qwebchannelglobal.h"
-#include "private/qglobal_p.h"
+#include <QtQml/qqml.h>
+#include <QtWebChannelQuick/qwebchannelquickglobal.h>
QT_BEGIN_NAMESPACE
-class Q_WEBCHANNEL_EXPORT QQmlWebChannelAttached : public QObject
+class Q_WEBCHANNELQUICK_EXPORT QQmlWebChannelAttached : public QObject
{
Q_OBJECT
-
- Q_PROPERTY( QString id READ id WRITE setId NOTIFY idChanged FINAL )
+ Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged FINAL)
+ QML_ANONYMOUS
+ QML_ADDED_IN_VERSION(1, 0)
public:
explicit QQmlWebChannelAttached(QObject *parent = 0);
virtual ~QQmlWebChannelAttached();
diff --git a/src/webchannelquick/qwebchannelquickglobal.h b/src/webchannelquick/qwebchannelquickglobal.h
new file mode 100644
index 0000000..d16a2a8
--- /dev/null
+++ b/src/webchannelquick/qwebchannelquickglobal.h
@@ -0,0 +1,10 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QTWEBCHANNELQUICK_H
+#define QTWEBCHANNELQUICK_H
+
+#include <QtCore/qglobal.h>
+#include <QtWebChannelQuick/qtwebchannelquickexports.h>
+
+#endif // QTWEBCHANNELQUICK_H
diff --git a/tests/auto/qml/CMakeLists.txt b/tests/auto/qml/CMakeLists.txt
index eaac420..3fc18ff 100644
--- a/tests/auto/qml/CMakeLists.txt
+++ b/tests/auto/qml/CMakeLists.txt
@@ -1,11 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qml.pro.
-
-#####################################################################
-## qml Test:
-#####################################################################
# Collect test data
file(GLOB_RECURSE test_data_glob
@@ -13,7 +8,7 @@ file(GLOB_RECURSE test_data_glob
data/*)
list(APPEND test_data ${test_data_glob})
-qt_internal_add_test(tst_qmlwebchannel # special case
+qt_internal_add_test(tst_qmlwebchannel
QMLTEST
QML_IMPORTPATH
"${CMAKE_CURRENT_BINARY_DIR}/../../../qml"
@@ -25,13 +20,8 @@ qt_internal_add_test(tst_qmlwebchannel # special case
testwebchannel.cpp testwebchannel.h
LIBRARIES
Qt::CorePrivate
- Qt::Gui
Qt::WebChannelPrivate
+ Qt::WebChannelQuick
TESTDATA ${test_data}
)
-#### Keys ignored in scope 1:.:.:qml.pro:<TRUE>:
-# DISTFILES = "tst_webchannelseparation.qml"
-# IMPORTPATH = "$$OUT_PWD/../../../qml" "$$PWD"
-# OTHER_FILES = "Client.qml" "WebChannelTest.qml" "tst_webchannel.qml" "tst_metaobjectpublisher.qml" "tst_bench.qml" "tst_multiclient.qml"
-# TEMPLATE = "app"
diff --git a/tests/auto/qml/testwebchannel.cpp b/tests/auto/qml/testwebchannel.cpp
index a353c50..e2f7b20 100644
--- a/tests/auto/qml/testwebchannel.cpp
+++ b/tests/auto/qml/testwebchannel.cpp
@@ -3,8 +3,8 @@
#include "testwebchannel.h"
-#include <private/qwebchannel_p.h>
-#include <private/qmetaobjectpublisher_p.h>
+#include <QtWebChannel/private/qwebchannel_p.h>
+#include <QtWebChannel/private/qmetaobjectpublisher_p.h>
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/qml/testwebchannel.h b/tests/auto/qml/testwebchannel.h
index 4768f99..462e6de 100644
--- a/tests/auto/qml/testwebchannel.h
+++ b/tests/auto/qml/testwebchannel.h
@@ -4,7 +4,7 @@
#ifndef TESTWEBCHANNEL_H
#define TESTWEBCHANNEL_H
-#include <QtWebChannel/QQmlWebChannel>
+#include <QtWebChannelQuick/qqmlwebchannel.h>
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/webchannel/CMakeLists.txt b/tests/auto/webchannel/CMakeLists.txt
index 0dd4c31..ae747bb 100644
--- a/tests/auto/webchannel/CMakeLists.txt
+++ b/tests/auto/webchannel/CMakeLists.txt
@@ -1,25 +1,14 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from webchannel.pro.
-
-#####################################################################
-## tst_webchannel Test:
-#####################################################################
-
qt_internal_add_test(tst_webchannel
SOURCES
tst_webchannel.cpp tst_webchannel.h
- INCLUDE_DIRECTORIES
- ../../../src/webchannel
LIBRARIES
Qt::CorePrivate
Qt::WebChannelPrivate
)
-## Scopes:
-#####################################################################
-
qt_internal_extend_target(tst_webchannel CONDITION TARGET Qt::Qml
DEFINES
WEBCHANNEL_TESTS_CAN_USE_JS_ENGINE
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index 28f1482..7bf04dd 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -4,9 +4,9 @@
#include "tst_webchannel.h"
-#include <qwebchannel.h>
-#include <qwebchannel_p.h>
-#include <qmetaobjectpublisher_p.h>
+#include <QtWebChannel/qwebchannel.h>
+#include <QtWebChannel/private/qwebchannel_p.h>
+#include <QtWebChannel/private/qmetaobjectpublisher_p.h>
#include <QtTest>
#ifdef WEBCHANNEL_TESTS_CAN_USE_JS_ENGINE