+ Support preference pages for Python widget class

This commit is contained in:
wmayer
2015-07-16 00:10:23 +02:00
parent b975c2d60f
commit b5987f0ff4
3 changed files with 170 additions and 11 deletions

View File

@@ -532,20 +532,31 @@ PyObject* Application::sCreateDialog(PyObject * /*self*/, PyObject *args,PyObjec
PyObject* Application::sAddPreferencePage(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)
{
char *fn, *grp;
if (!PyArg_ParseTuple(args, "ss", &fn,&grp)) // convert args: Python->C
return NULL; // NULL triggers exception
if (PyArg_ParseTuple(args, "ss", &fn,&grp)) {
QFileInfo fi(QString::fromUtf8(fn));
if (!fi.exists()) {
PyErr_SetString(PyExc_RuntimeError, "UI file does not exist");
return 0;
}
QFileInfo fi(QString::fromUtf8(fn));
if (!fi.exists()) {
PyErr_SetString(PyExc_RuntimeError, "UI file does not exist");
return 0;
// add to the preferences dialog
new PrefPageUiProducer(fn, grp);
Py_INCREF(Py_None);
return Py_None;
}
PyErr_Clear();
PyObject* dlg;
if (PyArg_ParseTuple(args, "O!s", &PyClass_Type, &dlg, &grp)) {
// add to the preferences dialog
new PrefPagePyProducer(Py::Object(dlg), grp);
Py_INCREF(Py_None);
return Py_None;
}
// add to the preferences dialog
new PrefPageUiProducer(fn, grp);
Py_INCREF(Py_None);
return Py_None;
return 0;
}
PyObject* Application::sActivateWorkbenchHandler(PyObject * /*self*/, PyObject *args,PyObject * /*kwd*/)