Add signal when python extensions are changed

* This avoids repeatedly hitting disk to enumerate current extensions for UI
  updates.
This commit is contained in:
baldurk
2026-09-17 11:44:07 +01:00
parent ac902dc08a
commit 6b9cec797d
5 changed files with 42 additions and 10 deletions
+12 -2
View File
@@ -379,8 +379,7 @@ PythonShell::PythonShell(ICaptureContext &ctx, QWidget *parent)
QObject::connect(m_Watcher, &QFileSystemWatcher::directoryChanged, this,
&PythonShell::updateExtensionProjects);
QTimer *pyStatusTimer = new QTimer(this);
QObject::connect(pyStatusTimer, &QTimer::timeout, [this]() {
QObject::connect(PythonContext::GetExtensionContext(), &PythonContext::extensionsUpdated, [this]() {
QList<QString> curModExts;
for(const ExtensionMetadata &m : m_Ctx.Extensions().GetInstalledExtensions())
@@ -398,7 +397,10 @@ PythonShell::PythonShell(ICaptureContext &ctx, QWidget *parent)
updateExtensionProjects();
m_ModifiedExtensions = curModExts;
}
});
QTimer *pyStatusTimer = new QTimer(this);
QObject::connect(pyStatusTimer, &QTimer::timeout, [this]() {
bool hasDebugger = PythonContext::IsDebuggerConnected();
if(m_DebuggerAttached != hasDebugger)
@@ -1049,6 +1051,8 @@ void PythonShell::updateNonDebugWarning()
edit->setWarning(
tr("External debugger will not work for unsaved files. "
"Save script to disk to allow debugging."));
else
edit->setWarning(QString());
}
else
{
@@ -1933,6 +1937,9 @@ void PythonShell::projectExplorer_contextMenu(const QPoint &pos)
QAction createExtension(tr("Create &New Extension"), this);
createExtension.setIcon(Icons::plugin_add());
QAction refreshExtensionList(tr("&Refresh Extension List"), this);
refreshExtensionList.setIcon(Icons::update());
QObject::connect(&expandAll, &QAction::triggered,
[this, item]() { ui->projectExplorer->expandAllItems(item); });
@@ -2019,8 +2026,11 @@ void PythonShell::projectExplorer_contextMenu(const QPoint &pos)
contextMenu.addSeparator();
contextMenu.addAction(&createExtension);
contextMenu.addAction(&refreshExtensionList);
QObject::connect(&createExtension, &QAction::triggered, [this]() { createExtension_clicked(); });
QObject::connect(&refreshExtensionList, &QAction::triggered,
[this]() { updateExtensionProjects(); });
}
RDDialog::show(&contextMenu, ui->projectExplorer->viewport()->mapToGlobal(pos));