aboutsummaryrefslogtreecommitdiffstats
path: root/PySide/QtGui/glue
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-02-01 20:34:18 -0300
committerHugo Lima <hugo.lima@openbossa.org>2010-02-02 18:08:41 -0200
commit2cee6b6fca0c9b4188b7fb10643f77a719b792fc (patch)
treeed039eda9431930bbc7a1502bcd7bfb6fab31272 /PySide/QtGui/glue
parent70f80e8ae5bdfe5da2378398c88f1ae4efd2781e (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.h23
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;
+}