diff options
author | Renato Filho <renato.filho@openbossa.org> | 2010-02-01 20:34:18 -0300 |
---|---|---|
committer | Hugo Lima <hugo.lima@openbossa.org> | 2010-02-02 18:08:41 -0200 |
commit | 2cee6b6fca0c9b4188b7fb10643f77a719b792fc (patch) | |
tree | ed039eda9431930bbc7a1502bcd7bfb6fab31272 /PySide/QtGui/glue | |
parent | 70f80e8ae5bdfe5da2378398c88f1ae4efd2781e (diff) |
Ported boost::python inject code for QMenu and QShortcut.
Reviewed by Hugo Parente Lima <hugo.lima@openbossa.org>
Diffstat (limited to 'PySide/QtGui/glue')
-rw-r--r-- | PySide/QtGui/glue/qmenu_glue.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/PySide/QtGui/glue/qmenu_glue.h b/PySide/QtGui/glue/qmenu_glue.h new file mode 100644 index 000000000..9d10d7add --- /dev/null +++ b/PySide/QtGui/glue/qmenu_glue.h @@ -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; +} |