From a995ded4663a28f9484180d349209203a03ad591 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 23 Mar 2026 12:16:47 +0000 Subject: [PATCH] Add quick-helper to view extension output from manager dialog --- qrenderdoc/Code/Interface/QRDInterface.h | 45 +++++++++++++++++++ .../Windows/Dialogs/ExtensionManager.cpp | 23 ++++++++++ qrenderdoc/Windows/Dialogs/ExtensionManager.h | 1 + .../Windows/Dialogs/ExtensionManager.ui | 7 +++ qrenderdoc/Windows/PythonShell.cpp | 44 +++++++++++++++++- qrenderdoc/Windows/PythonShell.h | 8 ++++ 6 files changed, 127 insertions(+), 1 deletion(-) diff --git a/qrenderdoc/Code/Interface/QRDInterface.h b/qrenderdoc/Code/Interface/QRDInterface.h index e6880ca93..959f98d88 100644 --- a/qrenderdoc/Code/Interface/QRDInterface.h +++ b/qrenderdoc/Code/Interface/QRDInterface.h @@ -1255,6 +1255,51 @@ will have the option to cancel, which aborts the run of the script. )"); virtual void DebugScript() = 0; + DOCUMENT(R"(Sets the filter on the output panel to only show output from the given extension. + +If the extension does not exist or is not loaded, no change will be made to the output filter. + +:param str extensionName: The name of the extension to show output from. +)"); + virtual void SetExtensionOutputFilter(const rdcstr &extensionName) = 0; + + DOCUMENT(R"(Sets the filter on the output panel to only show output from scripts run. + +This will hide any output from extensions that are loaded, and only show output that comes from the script +run from inside the python window. +)"); + virtual void SetScriptOutputFilter() = 0; + + DOCUMENT(R"(Sets the filter on the output panel to show output from all python sources. + +This will show output from the running script, as well as any extensions that are loaded. +)"); + virtual void RemoveOutputFilter() = 0; + + DOCUMENT(R"(Raises the script editor. + +This will ensure the panel containing the script editor is visible. +)"); + virtual void ShowScriptEditor() = 0; + + DOCUMENT(R"(Raises the output panel. + +This will ensure the panel showing the output from running python code is visible. +)"); + virtual void ShowOutput() = 0; + + DOCUMENT(R"(Raises the REPL panel. + +This will ensure the panel with the interactive REPL is visible. +)"); + virtual void ShowREPL() = 0; + + DOCUMENT(R"(Raises the help panel. + +This will ensure the panel showing the help browser is visible. +)"); + virtual void ShowHelp() = 0; + protected: IPythonShell() = default; ~IPythonShell() = default; diff --git a/qrenderdoc/Windows/Dialogs/ExtensionManager.cpp b/qrenderdoc/Windows/Dialogs/ExtensionManager.cpp index 239434d15..38fe0fce6 100644 --- a/qrenderdoc/Windows/Dialogs/ExtensionManager.cpp +++ b/qrenderdoc/Windows/Dialogs/ExtensionManager.cpp @@ -162,6 +162,29 @@ void ExtensionManager::on_debug_clicked() } } +void ExtensionManager::on_output_clicked() +{ + m_Ctx.ShowPythonShell(); + m_Ctx.GetPythonShell()->ShowOutput(); + + RDTreeWidgetItem *item = ui->extensions->currentItem(); + if(item) + { + int idx = ui->extensions->indexOfTopLevelItem(item); + + if(idx >= 0 && idx < m_Extensions.count()) + { + const ExtensionMetadata &e = m_Extensions[idx]; + if(!e.package.isEmpty()) + { + m_Ctx.GetPythonShell()->SetExtensionOutputFilter(e.package); + } + } + } + + accept(); +} + void ExtensionManager::on_openLocation_clicked() { if(m_Extensions.empty()) diff --git a/qrenderdoc/Windows/Dialogs/ExtensionManager.h b/qrenderdoc/Windows/Dialogs/ExtensionManager.h index 6829b06c0..93c0eb8ad 100644 --- a/qrenderdoc/Windows/Dialogs/ExtensionManager.h +++ b/qrenderdoc/Windows/Dialogs/ExtensionManager.h @@ -50,6 +50,7 @@ private slots: // automatic slots void on_reload_clicked(); void on_debug_clicked(); + void on_output_clicked(); void on_openLocation_clicked(); void on_alwaysLoad_toggled(bool checked); void on_extensions_currentItemChanged(RDTreeWidgetItem *item, RDTreeWidgetItem *); diff --git a/qrenderdoc/Windows/Dialogs/ExtensionManager.ui b/qrenderdoc/Windows/Dialogs/ExtensionManager.ui index 1168f4a8a..f4a8c56b4 100644 --- a/qrenderdoc/Windows/Dialogs/ExtensionManager.ui +++ b/qrenderdoc/Windows/Dialogs/ExtensionManager.ui @@ -222,6 +222,13 @@ + + + + View output + + + diff --git a/qrenderdoc/Windows/PythonShell.cpp b/qrenderdoc/Windows/PythonShell.cpp index e670528b7..be510fa0c 100644 --- a/qrenderdoc/Windows/PythonShell.cpp +++ b/qrenderdoc/Windows/PythonShell.cpp @@ -1143,13 +1143,55 @@ rdcstr PythonShell::GetScriptText() return scriptEditor->getText(scriptEditor->textLength() + 1).data(); } +void PythonShell::SetExtensionOutputFilter(const rdcstr &extensionName) +{ + if(extensionName.empty()) + return; + + int idx = loadedExtensions.indexOf(extensionName); + if(idx < 0) + return; + + ui->outputContext->setCurrentIndex(FirstExtensionOutputFilter + idx); +} + +void PythonShell::SetScriptOutputFilter() +{ + ui->outputContext->setCurrentIndex(ScriptOutputFilter); +} + +void PythonShell::RemoveOutputFilter() +{ + ui->outputContext->setCurrentIndex(AllOutputFilter); +} + +void PythonShell::ShowScriptEditor() +{ + ToolWindowManager::raiseToolWindow(scriptEditor); +} + +void PythonShell::ShowOutput() +{ + ToolWindowManager::raiseToolWindow(ui->outputGroup); +} + +void PythonShell::ShowREPL() +{ + ToolWindowManager::raiseToolWindow(ui->replGroup); +} + +void PythonShell::ShowHelp() +{ + ToolWindowManager::raiseToolWindow(ui->helpGroup); +} + void PythonShell::runScript(bool debugging) { PythonContext *context = newContext(); ANALYTIC_SET(UIFeatures.PythonInterop, true); - ToolWindowManager::raiseToolWindow(ui->outputGroup); + ShowOutput(); scriptOutputLines.removeIf([](const ScriptOutputLine &l) { return l.extension.isEmpty(); }); diff --git a/qrenderdoc/Windows/PythonShell.h b/qrenderdoc/Windows/PythonShell.h index a73961b60..3d86bd5c7 100644 --- a/qrenderdoc/Windows/PythonShell.h +++ b/qrenderdoc/Windows/PythonShell.h @@ -60,6 +60,14 @@ public: void RunScript() override { runScript(false); } void DebugScript() override { runScript(true); } + void SetExtensionOutputFilter(const rdcstr &extensionName) override; + void SetScriptOutputFilter() override; + void RemoveOutputFilter() override; + void ShowScriptEditor() override; + void ShowOutput() override; + void ShowREPL() override; + void ShowHelp() override; + QVariant persistData(); void setPersistData(const QVariant &persistData);