diff options
author | Christian Tismer <ctismer@gmail.com> | 2015-09-21 11:52:58 +0200 |
---|---|---|
committer | Christian Tismer <ctismer@gmail.com> | 2015-09-21 11:52:58 +0200 |
commit | a7cc0e453ce09031e18bd10ff391997e2814e389 (patch) | |
tree | 5c0149aefe247b54958a2b217ec9bb7984bc014f /PySide2/QtUiTools/typesystem_uitools.xml | |
parent | de9c4b39d1adc988a8178e60060ea9d0286161b4 (diff) |
huge change on project layout.
The intention is to have PySide2 and Shiboken2 as project names, to
allow for co-existence of PySide and PySide2.
This is the first version that builds with these settings on OS X:
$ python3 setup.py build --debug --no-examples --ignore-git --qmake=/usr/local/Cellar/qt5/5.5.0/bin/qmake --jobs=9
This is not yet tested.
Diffstat (limited to 'PySide2/QtUiTools/typesystem_uitools.xml')
-rw-r--r-- | PySide2/QtUiTools/typesystem_uitools.xml | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/PySide2/QtUiTools/typesystem_uitools.xml b/PySide2/QtUiTools/typesystem_uitools.xml new file mode 100644 index 000000000..16039c9ec --- /dev/null +++ b/PySide2/QtUiTools/typesystem_uitools.xml @@ -0,0 +1,128 @@ +<?xml version="1.0"?> +<!-- + This file is part of PySide project. + Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + Contact: PySide team <contact@pyside.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +--> +<typesystem package="PySide.QtUiTools"> + <load-typesystem name="typesystem_widgets.xml" generate="no" /> + <load-typesystem name="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(uiplugin); + </inject-code> + <add-function signature="registerCustomWidget(PyObject*)" return-type="void"> + <modify-argument index="1"> + <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 + loading a `.ui` file. The custom widget type is passed via the ``customWidgetType`` argument. + This is needed when you want to override a virtual method of some widget in the interface, + since duck punching will not work with widgets created by QUiLoader based on the contents + of the `.ui` file. + + (Remember that `duck punching virtual methods is an invitation for your own demise! + <http://www.pyside.org/docs/shiboken/wordsofadvice.html#duck-punching-and-virtual-methods>`_) + + Let's see an obvious example. If you want to create a new widget it's probable you'll end up + overriding :class:`~PySide.QtGui.QWidget`'s :meth:`~PySide.QtGui.QWidget.paintEvent` method. + + .. code-block:: python + + class Circle(QWidget): + def paintEvent(self, event): + painter = QPainter(self) + painter.setPen(self.pen) + painter.setBrush(QBrush(self.color)) + painter.drawEllipse(event.rect().center(), 20, 20) + + # ... + + loader = QUiLoader() + loader.registerCustomWidget(Circle) + circle = loader.load('circle.ui') + circle.show() + + # ... + </inject-documentation> + <inject-code class="target" position="beginning"> + registerCustomWidget(%PYARG_1); + %CPPSELF.addPluginPath(""); // force reload widgets + </inject-code> + </add-function> + <modify-function signature="createAction(QObject*, const QString&)"> + <modify-argument index="return"> + <parent index="1" action="add"/> + </modify-argument> + </modify-function> + + <modify-function signature="createActionGroup(QObject*, const QString&)"> + <modify-argument index="return"> + <parent index="1" action="add"/> + </modify-argument> + </modify-function> + + <modify-function signature="createLayout(const QString&, QObject*, const QString&)"> + <modify-argument index="return"> + <parent index="2" action="add"/> + </modify-argument> + </modify-function> + + <modify-function signature="createWidget(const QString&, QWidget*, const QString&)"> + <modify-argument index="return"> + <parent index="2" action="add"/> + <define-ownership class="target" owner="default"/> + </modify-argument> + </modify-function> + + <modify-function signature="load(QIODevice*, QWidget*)"> + <modify-argument index="2"> + <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> + </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" /> + </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> + </add-function> + </object-type> + +</typesystem> |