From 6452e03cdcc47c6d5ccea142f4f89f88d745007f Mon Sep 17 00:00:00 2001 From: ChuckNr11 Date: Sun, 5 Apr 2026 21:56:33 +0200 Subject: [PATCH] refactor: move code to other place for cleaner code connections for projectviews are made in "addProjectView" --- sources/qetdiagrameditor.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index f9cfbd7d0..f4deb45df 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -1168,18 +1168,6 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel) // cree un ProjectView pour visualiser le projet ProjectView *project_view = new ProjectView(project); - //Highlight the current page - connect(project_view, &ProjectView::diagramActivated, this, [this](DiagramView *dv) { - if (dv && dv->diagram() && pa) { - // 1. Find the item in the tree that corresponds to this diagram - QTreeWidgetItem *item = pa->elementsPanel().getItemForDiagram(dv->diagram()); - - // 2. If you find it, select it - if (item) { - pa->elementsPanel().setCurrentItem(item); - } - } - }); addProjectView(project_view); undo_group.addStack(project -> undoStack()); @@ -1840,6 +1828,19 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view) connect(project_view, SIGNAL(errorEncountered(QString)), this, SLOT(showError(const QString &))); + //Highlight the current page + connect(project_view, &ProjectView::diagramActivated, this, [this](DiagramView *dv) { + if (dv && dv->diagram() && pa) { + // 1. Find the item in the tree that corresponds to this diagram + QTreeWidgetItem *item = pa->elementsPanel().getItemForDiagram(dv->diagram()); + + // 2. If you find it, select it + if (item) { + pa->elementsPanel().setCurrentItem(item); + } + } + }); + //We maximise the new window if the current window is inexistent or maximized QWidget *current_window = m_workspace.activeSubWindow(); bool maximise = ((!current_window)