Merge pull request #624 from ispyisail/feature-window-modified-indicator

Show unsaved-changes state in the main window title (macOS modified dot)
This commit is contained in:
Laurent Trinques
2026-08-08 11:50:46 +02:00
committed by GitHub
2 changed files with 34 additions and 0 deletions
+33
View File
@@ -1303,6 +1303,12 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel)
undo_group.addStack(project -> undoStack()); undo_group.addStack(project -> undoStack());
connect(project, &QETProject::projectModified, this, [this](QETProject *modified_project, bool) {
if (modified_project == currentProject()) {
updateWindowModifiedState();
}
});
m_element_collection_widget->addProject(project); m_element_collection_widget->addProject(project);
// met a jour le panel d'elements // met a jour le panel d'elements
@@ -2597,6 +2603,7 @@ void QETDiagramEditor::subWindowActivated(QMdiSubWindow *subWindows)
slot_updateWindowsMenu(); slot_updateWindowsMenu();
emit syncElementsPanel(); emit syncElementsPanel();
updateUsageTrackersActiveState(); updateUsageTrackersActiveState();
updateWindowModifiedState();
} }
/** /**
@@ -2622,6 +2629,32 @@ void QETDiagramEditor::updateUsageTrackersActiveState()
} }
} }
/**
@brief QETDiagramEditor::updateWindowModifiedState
Reflect the currently active project's unsaved-changes state in the
main window's title and native "document modified" indicator (e.g.
the dot in the close button on macOS). Called whenever the active
project changes, or whenever the active project's own modified state
changes.
The window title's "[*]" placeholder is Qt's own convention: combined
with setWindowModified(), it lets each platform render the modified
indicator its own way (or not at all, on platforms without one)
without QET having to draw anything itself.
*/
void QETDiagramEditor::updateWindowModifiedState()
{
if (QETProject *project = currentProject()) {
setWindowTitle(QString("%1[*] - %2").arg(
project->pathNameTitle(),
tr("QElectroTech", "window title")));
setWindowModified(project->projectOptionsWereModified());
} else {
setWindowTitle(tr("QElectroTech", "window title"));
setWindowModified(false);
}
}
/** /**
@brief QETDiagramEditor::selectionChanged @brief QETDiagramEditor::selectionChanged
This slot is called when a diagram selection was changed. This slot is called when a diagram selection was changed.
+1
View File
@@ -98,6 +98,7 @@ class QETDiagramEditor : public QETMainWindow
ProjectView *findProject(const QString &) const; ProjectView *findProject(const QString &) const;
QMdiSubWindow *subWindowForWidget(QWidget *) const; QMdiSubWindow *subWindowForWidget(QWidget *) const;
void updateUsageTrackersActiveState(); void updateUsageTrackersActiveState();
void updateWindowModifiedState();
signals: signals:
void syncElementsPanel(); void syncElementsPanel();