diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-10-11 14:55:22 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-10-11 18:31:06 +0000 |
commit | 3c77475375209125a53f2950c2413cec7f18c8c5 (patch) | |
tree | adc043acd615924946a4fedcbb449d1585f4cd0c | |
parent | cfe10ede7fe7669705c2ae5d2604084cdcfc5511 (diff) |
PySide6: Add qmlRegister functions taking a library URL
Fixes: PYSIDE-1631
Change-Id: I082c3576c24f772190cc103da787311b43acf88c
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
(cherry picked from commit 87d1bb58877bb956e8fe15e262d173ddaa011b08)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | sources/pyside6/PySide6/QtQml/typesystem_qml.xml | 2 | ||||
-rw-r--r-- | sources/pyside6/tests/QtQml/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sources/pyside6/tests/QtQml/ModuleType.qml | 33 | ||||
-rw-r--r-- | sources/pyside6/tests/QtQml/registerqmlfile.py | 55 |
4 files changed, 91 insertions, 0 deletions
diff --git a/sources/pyside6/PySide6/QtQml/typesystem_qml.xml b/sources/pyside6/PySide6/QtQml/typesystem_qml.xml index bd6b2b41d..901240266 100644 --- a/sources/pyside6/PySide6/QtQml/typesystem_qml.xml +++ b/sources/pyside6/PySide6/QtQml/typesystem_qml.xml @@ -123,6 +123,8 @@ <function signature="qmlProtectModule(const char*,int)"/> <function signature="qmlRegisterModule(const char*,int,int)"/> <function signature="qmlTypeId(const char*,int,int,const char*)"/> + <function signature="qmlRegisterType(const QUrl &,const char *,int,int,const char *)"/> + <function signature="qmlRegisterSingletonType(const QUrl &,const char *,int,int,const char *)"/> <function signature="qmlRegisterUncreatableMetaObject(const QMetaObject&,const char*,int,int, const char*,const QString&)"/> <enum-type identified-by-value="QML_HAS_ATTACHED_PROPERTIES"> diff --git a/sources/pyside6/tests/QtQml/CMakeLists.txt b/sources/pyside6/tests/QtQml/CMakeLists.txt index e35831f25..6208825b0 100644 --- a/sources/pyside6/tests/QtQml/CMakeLists.txt +++ b/sources/pyside6/tests/QtQml/CMakeLists.txt @@ -16,6 +16,7 @@ PYSIDE_TEST(qqmlnetwork_test.py) PYSIDE_TEST(qquickview_test.py) PYSIDE_TEST(connect_python_qml.py) PYSIDE_TEST(registertype.py) +PYSIDE_TEST(registerqmlfile.py) PYSIDE_TEST(registeruncreatabletype.py) PYSIDE_TEST(registersingletontype.py) PYSIDE_TEST(javascript_exceptions.py) diff --git a/sources/pyside6/tests/QtQml/ModuleType.qml b/sources/pyside6/tests/QtQml/ModuleType.qml new file mode 100644 index 000000000..9319f3a41 --- /dev/null +++ b/sources/pyside6/tests/QtQml/ModuleType.qml @@ -0,0 +1,33 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of Qt for Python. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** 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-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml + +QtObject { + objectName: "moduleType" +} diff --git a/sources/pyside6/tests/QtQml/registerqmlfile.py b/sources/pyside6/tests/QtQml/registerqmlfile.py new file mode 100644 index 000000000..41d76d247 --- /dev/null +++ b/sources/pyside6/tests/QtQml/registerqmlfile.py @@ -0,0 +1,55 @@ +############################################################################# +## +## Copyright (C) 2021 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of Qt for Python. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## 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 General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## 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-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +import os +import sys +import unittest + +from pathlib import Path +sys.path.append(os.fspath(Path(__file__).resolve().parents[1])) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import QDir, QUrl +from PySide6.QtGui import QGuiApplication +from PySide6.QtQml import qmlRegisterType + + +class TestQmlSupport(unittest.TestCase): + + def testIt(self): + app = QGuiApplication([]) + + file = os.fspath(Path(__file__).resolve().parent / 'ModuleType.qml') + url = QUrl.fromLocalFile(QDir.fromNativeSeparators(file)) + result = qmlRegisterType(url, "CustomModule", 1, 0, "ModuleType") + self.assertTrue(result != -1) + + +if __name__ == '__main__': + unittest.main() |