Skip to content

Commit

Permalink
[Gui] Change Preference page lookup to by name instead of index
Browse files Browse the repository at this point in the history
  • Loading branch information
Syres916 authored Dec 15, 2024
1 parent 8d16e2f commit 302b713
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/Gui/ApplicationPy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1362,16 +1362,39 @@ PyObject* Application::sShowDownloads(PyObject * /*self*/, PyObject *args)
Py_Return;
}

PyObject* Application::sShowPreferences(PyObject * /*self*/, PyObject *args)
PyObject* Application::sShowPreferences(PyObject* /*self*/, PyObject* args)
{
char *pstr = nullptr;
int idx=0;
if (!PyArg_ParseTuple(args, "|si", &pstr, &idx))
char* pstr = nullptr;
int idx = 0;
if (!PyArg_ParseTuple(args, "|si", &pstr, &idx)) {
return nullptr;
}

Gui::Dialog::DlgPreferencesImp cDlg(getMainWindow());
if (pstr) {
cDlg.activateGroupPage(QString::fromUtf8(pstr), idx);
}

WaitCursor wc;
wc.restoreCursor();
cDlg.exec();
wc.setWaitCursor();

Py_Return;
}

PyObject* Application::sShowPreferencesByName(PyObject* /*self*/, PyObject* args)
{
char* pstr = nullptr;
const char* prefType = "";
if (!PyArg_ParseTuple(args, "s|s", &pstr, &prefType)) {
return nullptr;
}

Gui::Dialog::DlgPreferencesImp cDlg(getMainWindow());
if (pstr)
cDlg.activateGroupPage(QString::fromUtf8(pstr),idx);
if (pstr && prefType) {
cDlg.activateGroupPageByPageName(QString::fromUtf8(pstr), QString::fromUtf8(prefType));
}

WaitCursor wc;
wc.restoreCursor();
Expand Down

0 comments on commit 302b713

Please sign in to comment.