Live mode: find the open project while QElectroTech is not the active window

While the user types to the assistant, QElectroTech is not the active
application, and QMdiArea then reports no active sub-window: status said
no project was open and every run was refused. Make the sub-window it
remembers active again before handling a request; the focus stays where
the user put it. Found with the Windows package under Wine; reproduced on
Linux with another window focused.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-02 11:57:53 +13:00
parent e7b699b59a
commit 7d91e8fdf1
+15 -4
View File
@@ -273,12 +273,23 @@ void LiveServer::handle(const QJsonObject &request)
*/
QETDiagramEditor *LiveServer::editor() const
{
QETDiagramEditor *shown = nullptr;
QETDiagramEditor *chosen = nullptr;
for (QETDiagramEditor *e : QETApp::diagramEditors()) {
if (e->isActiveWindow()) return e;
if (!shown && e->isVisible()) shown = e;
if (e->isActiveWindow()) {
chosen = e;
break;
}
if (!chosen && e->isVisible()) chosen = e;
}
return shown;
//While the user is typing to the assistant, QElectroTech is not
//the active application, and QMdiArea then has no active
//sub-window: every "current project" in the editor reads as none.
//The one it remembers is the project the user was looking at.
if (chosen && !chosen->m_workspace.activeSubWindow()
&& chosen->m_workspace.currentSubWindow()) {
chosen->m_workspace.setActiveSubWindow(chosen->m_workspace.currentSubWindow());
}
return chosen;
}
QJsonObject LiveServer::status()