aboutsummaryrefslogtreecommitdiffstats
path: root/PySide/QtGui/glue/qmenu_glue.cpp
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-12-11 23:13:12 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:56:21 -0300
commit7bfbbf3cb784f8e22dde74ebe28ba5e5eda4b7db (patch)
tree0bd9c001bd2d6ff30f34c39aaf1a28c6233ffb43 /PySide/QtGui/glue/qmenu_glue.cpp
parentaec20b21a5cfc678c8bd1e017d2300542edfbce7 (diff)
No more training wheels. The last occurrences of the old template Converter where removed.
Also related fixes here and there.
Diffstat (limited to 'PySide/QtGui/glue/qmenu_glue.cpp')
-rw-r--r--PySide/QtGui/glue/qmenu_glue.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/PySide/QtGui/glue/qmenu_glue.cpp b/PySide/QtGui/glue/qmenu_glue.cpp
new file mode 100644
index 000000000..0636dfab0
--- /dev/null
+++ b/PySide/QtGui/glue/qmenu_glue.cpp
@@ -0,0 +1,21 @@
+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 = %CONVERTTOPYTHON[QAction*](act);
+ Shiboken::AutoDecRef result(PyObject_CallMethod(pyAct, "connect", "OsO", pyAct, SIGNAL(triggered()), callback));
+ if (result.isNull()) {
+ Py_DECREF(pyAct);
+ return 0;
+ }
+
+ return pyAct;
+}