Ported boost::python inject code for QMenu and QShortcut.
Reviewed by Hugo Parente Lima <hugo.lima@openbossa.org>
This commit is contained in:
parent
70f80e8ae5
commit
2cee6b6fca
2 changed files with 60 additions and 11 deletions
23
PySide/QtGui/glue/qmenu_glue.h
Normal file
23
PySide/QtGui/glue/qmenu_glue.h
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
inline PyObject*
|
||||||
|
addActionWithPyObject(QMenu *self, const QIcon& icon, const QString& text, PyObject *callback, const QKeySequence &shortcut)
|
||||||
|
{
|
||||||
|
QAction *act = new QAction(text, self);
|
||||||
|
|
||||||
|
if (!icon.isNull())
|
||||||
|
act->setIcon(icon);
|
||||||
|
|
||||||
|
if (!shortcut.isEmpty())
|
||||||
|
act->setShortcut(shortcut);
|
||||||
|
|
||||||
|
self->addAction(act);
|
||||||
|
|
||||||
|
PyObject *pyAct = Shiboken::Converter<QAction*>::toPython(act);
|
||||||
|
PyObject* result = PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered(bool)), callback);
|
||||||
|
if (result == 0) {
|
||||||
|
Py_DECREF(pyAct);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pyAct;
|
||||||
|
}
|
||||||
|
|
@ -1382,6 +1382,10 @@
|
||||||
</modify-function>
|
</modify-function>
|
||||||
</object-type>
|
</object-type>
|
||||||
<object-type name="QMenu">
|
<object-type name="QMenu">
|
||||||
|
<extra-includes>
|
||||||
|
<include file-name="glue/qmenu_glue.h" location="local"/>
|
||||||
|
</extra-includes>
|
||||||
|
|
||||||
<modify-function signature="exec()" rename="exec_" allow-thread="yes" />
|
<modify-function signature="exec()" rename="exec_" allow-thread="yes" />
|
||||||
<modify-function signature="exec(const QPoint&, QAction*)" rename="exec_" allow-thread="yes" />
|
<modify-function signature="exec(const QPoint&, QAction*)" rename="exec_" allow-thread="yes" />
|
||||||
<modify-function signature="exec(QList<QAction*>, const QPoint&, QAction*)" rename="exec_" allow-thread="yes" />
|
<modify-function signature="exec(QList<QAction*>, const QPoint&, QAction*)" rename="exec_" allow-thread="yes" />
|
||||||
|
|
@ -1428,9 +1432,27 @@
|
||||||
</modify-argument>
|
</modify-argument>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
<modify-function signature="setNoReplayFor(QWidget*)" remove="all" />
|
<modify-function signature="setNoReplayFor(QWidget*)" remove="all" />
|
||||||
<modify-function signature="addAction(QString,const QObject*,const char*,QKeySequence)" remove="all" />
|
|
||||||
<modify-function signature="addAction(QIcon,QString,const QObject*,const char*,QKeySequence)" remove="all" />
|
<add-function signature="addAction(const QString&, PyObject*, const QKeySequence&)">
|
||||||
|
<modify-argument index="3">
|
||||||
|
<replace-default-expression with="0" />
|
||||||
|
</modify-argument>
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
%PYARG_0 = addActionWithPyObject(%CPPSELF, QIcon(), %1, %2, %3);
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
|
|
||||||
|
<add-function signature="addAction(const QIcon&, const QString&, PyObject*, const QKeySequence&)">
|
||||||
|
<modify-argument index="4">
|
||||||
|
<replace-default-expression with="0" />
|
||||||
|
</modify-argument>
|
||||||
|
<inject-code class="target" position="beginning">
|
||||||
|
%PYARG_0 = addActionWithPyObject(%CPPSELF, %1, %2, %3, %4);
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
|
|
||||||
</object-type>
|
</object-type>
|
||||||
|
|
||||||
<object-type name="QMenuBar">
|
<object-type name="QMenuBar">
|
||||||
<modify-function signature="addAction(const QString&)">
|
<modify-function signature="addAction(const QString&)">
|
||||||
<modify-argument index="return">
|
<modify-argument index="return">
|
||||||
|
|
@ -1513,16 +1535,20 @@
|
||||||
</object-type>
|
</object-type>
|
||||||
|
|
||||||
<object-type name="QShortcut">
|
<object-type name="QShortcut">
|
||||||
<modify-function signature="QShortcut(QKeySequence,QWidget*,const char*,const char*,Qt::ShortcutContext)" remove="all">
|
<add-function signature="QShortcut(const QKeySequence&, QWidget*, PyObject*, Qt::ShortcutContext)">
|
||||||
<!-- <modify-argument index="3">
|
|
||||||
<remove-default-expression/>
|
|
||||||
<replace-type modified-type="const pyqt_slot&"/>
|
|
||||||
</modify-argument>
|
|
||||||
<modify-argument index="4">
|
<modify-argument index="4">
|
||||||
<remove-default-expression/>
|
<replace-default-expression with="Qt::WindowShortcut"/>
|
||||||
<replace-type modified-type="const pyqt_slot&"/>
|
</modify-argument>
|
||||||
</modify-argument>-->
|
<inject-code class="target" position="beginning">
|
||||||
</modify-function>
|
cptr = new QShortcutWrapper(%1, %2);
|
||||||
|
PyObject* result = PyObject_CallMethod(%PYSELF, "connect", "OsO", %PYSELF, SIGNAL(activated()), %PYARG_3);
|
||||||
|
if (result == 0) {
|
||||||
|
delete cptr;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Shiboken::setParent(%PYARG_2, %PYSELF);
|
||||||
|
</inject-code>
|
||||||
|
</add-function>
|
||||||
</object-type>
|
</object-type>
|
||||||
<object-type name="QSizeGrip"/>
|
<object-type name="QSizeGrip"/>
|
||||||
<object-type name="QSound"/>
|
<object-type name="QSound"/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue