mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-23 23:16:31 +00:00
Add a settings window entry to add extra python stubs paths
This commit is contained in:
@@ -364,6 +364,12 @@ DECLARE_REFLECTION_STRUCT(BugReport);
|
||||
"type: List[str]"); \
|
||||
CONFIG_SETTING(public, QVariantList, rdcarray<rdcstr>, TextureViewer_ShaderDirs) \
|
||||
\
|
||||
DOCUMENT( \
|
||||
"List of extra directories to write python stubs into.\n" \
|
||||
"\n:" \
|
||||
"type: List[str]"); \
|
||||
CONFIG_SETTING(public, QVariantList, rdcarray<rdcstr>, Python_StubDirs) \
|
||||
\
|
||||
DOCUMENT( \
|
||||
"``True`` if when loading a capture that was originally captured on a remote device but " \
|
||||
"uses an API that can be supported locally, should be loaded locally without prompting to " \
|
||||
|
||||
@@ -401,7 +401,7 @@ void PythonContext::GenerateStubs(const rdcarray<rdcstr> &extraPaths)
|
||||
qInfo() << "Stubs generation processed in" << timer.elapsed() << "ms";
|
||||
}
|
||||
|
||||
void PythonContext::GlobalInit()
|
||||
void PythonContext::GlobalInit(PersistantConfig &config)
|
||||
{
|
||||
// must happen on the UI thread
|
||||
if(qApp->thread() != QThread::currentThread())
|
||||
@@ -417,10 +417,10 @@ void PythonContext::GlobalInit()
|
||||
PyImport_AppendInittab("qrenderdoc", &PyInit_qrenderdoc);
|
||||
|
||||
#if PY_VERSION_HEX > 0x030B0000
|
||||
PyConfig config;
|
||||
PyConfig_InitPythonConfig(&config);
|
||||
config.configure_c_stdio = 0;
|
||||
config.parse_argv = 0;
|
||||
PyConfig pyconfig;
|
||||
PyConfig_InitPythonConfig(&pyconfig);
|
||||
pyconfig.configure_c_stdio = 0;
|
||||
pyconfig.parse_argv = 0;
|
||||
#endif
|
||||
|
||||
#if defined(STATIC_QRENDERDOC)
|
||||
@@ -433,7 +433,7 @@ void PythonContext::GlobalInit()
|
||||
pylibs.toWCharArray(python_home);
|
||||
|
||||
#if PY_VERSION_HEX > 0x030B0000
|
||||
config.home = python_home;
|
||||
pyconfig.home = python_home;
|
||||
#else
|
||||
Py_SetPythonHome(python_home);
|
||||
#endif
|
||||
@@ -441,11 +441,11 @@ void PythonContext::GlobalInit()
|
||||
#endif
|
||||
|
||||
#if PY_VERSION_HEX > 0x030B0000
|
||||
config.program_name = program_name;
|
||||
pyconfig.program_name = program_name;
|
||||
|
||||
config.use_environment = 0;
|
||||
pyconfig.use_environment = 0;
|
||||
|
||||
Py_InitializeFromConfig(&config);
|
||||
Py_InitializeFromConfig(&pyconfig);
|
||||
#else
|
||||
Py_SetProgramName(program_name);
|
||||
|
||||
@@ -477,7 +477,7 @@ void PythonContext::GlobalInit()
|
||||
|
||||
main_dict = PyModule_GetDict(main_module);
|
||||
|
||||
GenerateStubs({});
|
||||
GenerateStubs(config.Python_StubDirs);
|
||||
|
||||
// replace sys.stdout and sys.stderr with our own objects. These have a 'this' pointer of NULL,
|
||||
// which then indicates they need to forward to a global object
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
void PausePythonThreading();
|
||||
void ResumePythonThreading();
|
||||
|
||||
static void GlobalInit();
|
||||
static void GlobalInit(PersistantConfig &config);
|
||||
static void GlobalShutdown();
|
||||
|
||||
static QStringList GetApplicationExtensionsPaths();
|
||||
|
||||
@@ -286,7 +286,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
{
|
||||
QCoreApplication application(argc, mod_argv);
|
||||
PythonContext::GlobalInit();
|
||||
PersistantConfig cfg;
|
||||
PythonContext::GlobalInit(cfg);
|
||||
|
||||
logstream << "Checking python binding consistency.\n";
|
||||
|
||||
@@ -631,7 +632,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
PythonContext::GlobalInit();
|
||||
PythonContext::GlobalInit(config);
|
||||
|
||||
if(updateApplied)
|
||||
{
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <QToolButton>
|
||||
#include "Code/Interface/QRDInterface.h"
|
||||
#include "Code/QRDUtils.h"
|
||||
#include "Code/pyrenderdoc/PythonContext.h"
|
||||
#include "Styles/StyleData.h"
|
||||
#include "Widgets/OrderedListEditor.h"
|
||||
#include "Widgets/ReplayOptionsSelector.h"
|
||||
@@ -793,6 +794,57 @@ void SettingsDialog::on_browseRGPPath_clicked()
|
||||
m_Ctx.Config().Save();
|
||||
}
|
||||
|
||||
void SettingsDialog::on_Python_StubPaths_clicked()
|
||||
{
|
||||
QDialog listEditor;
|
||||
|
||||
listEditor.setWindowTitle(tr("Extra python stubs generation directories"));
|
||||
listEditor.setWindowFlags(listEditor.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
OrderedListEditor list(tr("Stubs Directory"),
|
||||
OrderedItemExtras::BrowseFolder | OrderedItemExtras::Delete);
|
||||
|
||||
QVBoxLayout layout;
|
||||
QDialogButtonBox okCancel;
|
||||
okCancel.setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
||||
layout.addWidget(&list);
|
||||
layout.addWidget(&okCancel);
|
||||
|
||||
QObject::connect(&okCancel, &QDialogButtonBox::accepted, &listEditor, &QDialog::accept);
|
||||
QObject::connect(&okCancel, &QDialogButtonBox::rejected, &listEditor, &QDialog::reject);
|
||||
|
||||
listEditor.setLayout(&layout);
|
||||
|
||||
QStringList items;
|
||||
for(const rdcstr &dir : m_Ctx.Config().Python_StubDirs)
|
||||
{
|
||||
items.append(dir);
|
||||
}
|
||||
|
||||
list.setItems(items);
|
||||
|
||||
int res = RDDialog::show(&listEditor);
|
||||
|
||||
if(res)
|
||||
{
|
||||
items = list.getItems();
|
||||
|
||||
rdcarray<rdcstr> newDirs;
|
||||
newDirs.resize(items.size());
|
||||
for(int i = 0; i < items.size(); i++)
|
||||
{
|
||||
newDirs[i] = items[i];
|
||||
}
|
||||
|
||||
if(newDirs.size() > m_Ctx.Config().Python_StubDirs.size())
|
||||
PythonContext::GenerateStubs(newDirs);
|
||||
|
||||
m_Ctx.Config().Python_StubDirs = newDirs;
|
||||
|
||||
m_Ctx.Config().Save();
|
||||
}
|
||||
}
|
||||
|
||||
// texture viewer
|
||||
void SettingsDialog::on_TextureViewer_PerTexSettings_toggled(bool checked)
|
||||
{
|
||||
@@ -817,7 +869,8 @@ void SettingsDialog::on_TextureViewer_ChooseShaderDirectories_clicked()
|
||||
listEditor.setWindowTitle(tr("Custom shaders search directories"));
|
||||
listEditor.setWindowFlags(listEditor.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
OrderedListEditor list(tr("Shaders Directory"), OrderedItemExtras::BrowseFolder);
|
||||
OrderedListEditor list(tr("Shaders Directory"),
|
||||
OrderedItemExtras::BrowseFolder | OrderedItemExtras::Delete);
|
||||
|
||||
QVBoxLayout layout;
|
||||
QDialogButtonBox okCancel;
|
||||
@@ -852,6 +905,8 @@ void SettingsDialog::on_TextureViewer_ChooseShaderDirectories_clicked()
|
||||
}
|
||||
|
||||
m_Ctx.Config().TextureViewer_ShaderDirs = newDirs;
|
||||
|
||||
m_Ctx.Config().Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,9 @@ private slots:
|
||||
void on_ExternalTool_RadeonGPUProfiler_textEdited(const QString &rgp);
|
||||
void on_browseRGPPath_clicked();
|
||||
|
||||
// python
|
||||
void on_Python_StubPaths_clicked();
|
||||
|
||||
// texture viewer
|
||||
void on_TextureViewer_PerTexSettings_toggled(bool checked);
|
||||
void on_TextureViewer_ResetRange_toggled(bool checked);
|
||||
|
||||
@@ -677,6 +677,67 @@ After interop is enabled you will need to reload any capture.</string>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pythonTab">
|
||||
<attribute name="title">
|
||||
<string>Python</string>
|
||||
</attribute>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_11">
|
||||
<property name="title">
|
||||
<string>Python</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="Python_StubPathsLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Extra python stubs paths</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="Python_StubPaths">
|
||||
<property name="text">
|
||||
<string>Python Stub Paths</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_9">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>387</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="replayTab">
|
||||
<attribute name="title">
|
||||
<string>Replay</string>
|
||||
|
||||
Reference in New Issue
Block a user