Add quick-helper to view extension output from manager dialog

This commit is contained in:
baldurk
2026-08-13 17:46:41 +01:00
parent 02ead51303
commit a995ded466
6 changed files with 127 additions and 1 deletions
+45
View File
@@ -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;
@@ -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())
@@ -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 *);
@@ -222,6 +222,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="output">
<property name="text">
<string>View output</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="debug">
<property name="text">
+43 -1
View File
@@ -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(); });
+8
View File
@@ -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);