diff options
author | Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2018-10-11 17:45:43 +0200 |
---|---|---|
committer | Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> | 2018-11-22 17:00:11 +0000 |
commit | a57a202a70801f766094c3ed11664b03c9a6a3e4 (patch) | |
tree | 73c2c1f4fc902ccbc10b73811bbf299a2c555728 /sources/pyside2/PySide2/QtUiTools | |
parent | f93a7369657814206bfbce49817c8fbd9a1bfcba (diff) |
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 <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside2/PySide2/QtUiTools')
-rw-r--r-- | sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml b/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml index 4fded3479..648a38cd5 100644 --- a/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml +++ b/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml @@ -41,20 +41,18 @@ --> <typesystem package="PySide2.QtUiTools"> - <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no" /> - <load-typesystem name="QtXml/typesystem_xml.xml" generate="no" /> + <load-typesystem name="QtWidgets/typesystem_widgets.xml" generate="no"/> + <load-typesystem name="QtXml/typesystem_xml.xml" generate="no"/> <object-type name="QUiLoader"> <extra-includes> <include file-name="glue/plugins.h" location="local"/> </extra-includes> <inject-code class="native" position="beginning" file="glue/uitools_loadui.cpp"/> - <inject-code> - Q_IMPORT_PLUGIN(PyCustomWidgets); - </inject-code> + <inject-code file="../glue/qtuitools.cpp" snippet="quiloader"/> <add-function signature="registerCustomWidget(PyObject*)" return-type="void"> <modify-argument index="1"> - <rename to="customWidgetType" /> + <rename to="customWidgetType"/> </modify-argument> <inject-documentation format="target" mode="append"> Registers a Python created custom widget to QUiLoader, so it can be recognized when @@ -87,10 +85,7 @@ # ... </inject-documentation> - <inject-code class="target" position="beginning"> - registerCustomWidget(%PYARG_1); - %CPPSELF.addPluginPath(""); // force reload widgets - </inject-code> + <inject-code class="target" position="beginning" file="../glue/qtuitools.cpp" snippet="quiloader-registercustomwidget"/> </add-function> <modify-function signature="createAction(QObject*,const QString&)"> <modify-argument index="return"> @@ -119,31 +114,25 @@ <modify-function signature="load(QIODevice*,QWidget*)"> <modify-argument index="2"> - <replace-default-expression with="0" /> - <rename to="parentWidget" /> + <replace-default-expression with="0"/> + <rename to="parentWidget"/> </modify-argument> <modify-argument index="return"> <define-ownership class="target" owner="target"/> </modify-argument> - <inject-code> - // Avoid calling the original function: %CPPSELF.%FUNCTION_NAME() - %PYARG_0 = QUiLoadedLoadUiFromDevice(%CPPSELF, %1, %2); - </inject-code> + <inject-code file="../glue/qtuitools.cpp" snippet="quiloader-load-1"/> </modify-function> <!-- Syntax sugar --> <add-function signature="load(QString,QWidget*)" return-type="QWidget*"> <modify-argument index="2"> - <replace-default-expression with="0" /> - <rename to="parentWidget" /> + <replace-default-expression with="0"/> + <rename to="parentWidget"/> </modify-argument> <modify-argument index="return"> <define-ownership class="target" owner="target"/> </modify-argument> - <inject-code> - // Avoid calling the original function: %CPPSELF.%FUNCTION_NAME() - %PYARG_0 = QUiLoaderLoadUiFromFileName(%CPPSELF, %1, %2); - </inject-code> + <inject-code file="../glue/qtuitools.cpp" snippet="quiloader-load-2"/> </add-function> </object-type> |