From a57a202a70801f766094c3ed11664b03c9a6a3e4 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Thu, 11 Oct 2018 17:45:43 +0200 Subject: Move inject-code snippets to separate files When code must be modified or added to certain functions, we currently have two options: * Write a template and include it into the typesystem, * inject code directly at a certain place of the function entry. The problem with injecting raw code is that since it is an XML file, one need to escape protected symbols, like "<" and "&". Thanks to a couple of complementary commits, now we can place this code snippets on a separate file without triggering a whole module compiling process, since the typesystem itself will not be alterered. All the injected code from the typesystem was removed and placed into a single file per module inside a top-level directory called glue. Some small fixes were included mainly regarding styling of the code. Task-number: PYSIDE-834 Change-Id: I823e92d241a528d75d5940090008db9bf297f49e Reviewed-by: Qt CI Bot Reviewed-by: Friedemann Kleint --- sources/pyside2/PySide2/glue/qtuitools.cpp | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sources/pyside2/PySide2/glue/qtuitools.cpp (limited to 'sources/pyside2/PySide2/glue/qtuitools.cpp') diff --git a/sources/pyside2/PySide2/glue/qtuitools.cpp b/sources/pyside2/PySide2/glue/qtuitools.cpp new file mode 100644 index 000000000..0a2feb262 --- /dev/null +++ b/sources/pyside2/PySide2/glue/qtuitools.cpp @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt for Python. +** +** $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$ +** +****************************************************************************/ + +// @snippet quiloader +Q_IMPORT_PLUGIN(PyCustomWidgets); +// @snippet quiloader + +// @snippet quiloader-registercustomwidget +registerCustomWidget(%PYARG_1); +%CPPSELF.addPluginPath(""); // force reload widgets +// @snippet quiloader-registercustomwidget + +// @snippet quiloader-load-1 +// Avoid calling the original function: %CPPSELF.%FUNCTION_NAME() +%PYARG_0 = QUiLoadedLoadUiFromDevice(%CPPSELF, %1, %2); +// @snippet quiloader-load-1 + +// @snippet quiloader-load-2 +// Avoid calling the original function: %CPPSELF.%FUNCTION_NAME() +%PYARG_0 = QUiLoaderLoadUiFromFileName(%CPPSELF, %1, %2); +// @snippet quiloader-load-2 -- cgit v1.2.3