Skip to content

Commit 63222ad

Browse files
BenJulelanewei120
authored andcommitted
feat: show unsaved-changes indicator (*) in the window title (#9987)
Prepend "* " to the project title while the project has unsaved changes, on all platforms: the custom topbar and window/taskbar title on Windows, and the native window title on macOS/Linux (all already show the project name via Plater::priv::set_project_name). The existing idle handler keeps it in sync as the dirty state changes; a cached last-applied title avoids redundant title updates. Closes #9987
1 parent 045e0a6 commit 63222ad

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎src/slic3r/GUI/MainFrame.cpp‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,9 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
805805
m_topbar->EnableUndoItem(m_plater->can_undo());
806806
m_topbar->EnableRedoItem(m_plater->can_redo());
807807
}
808+
// Keep the unsaved-changes "*" in the title in sync on all platforms (#9987).
809+
if (m_plater)
810+
update_title();
808811
}));
809812
#ifdef _MSW_DARK_MODE
810813
wxGetApp().UpdateDarkUIWin(this);
@@ -1154,7 +1157,29 @@ void MainFrame::update_filament_tab_ui()
11541157

11551158
void MainFrame::update_title()
11561159
{
1157-
return;
1160+
if (!m_plater)
1161+
return;
1162+
// Prepend "* " while the project has unsaved changes (#9987), on top of the project name
1163+
// that is already shown: in the custom topbar on Windows, and in the native window title
1164+
// on macOS/Linux (both set by Plater::priv::set_project_name).
1165+
const wxString name = m_plater->get_project_name();
1166+
const wxString title = (m_plater->is_project_dirty() && !name.IsEmpty()) ? ("* " + name) : name;
1167+
if (title == m_title_cache)
1168+
return;
1169+
m_title_cache = title;
1170+
#ifdef __WINDOWS__
1171+
if (m_topbar)
1172+
m_topbar->SetTitle(title);
1173+
// Also reflect the "*" in the window/taskbar title, which set_project_name builds
1174+
// as "<name> - BambuStudio".
1175+
SetTitle(title + " - BambuStudio");
1176+
#else
1177+
SetTitle(title);
1178+
#ifdef __APPLE__
1179+
if (!title.IsEmpty())
1180+
update_title_colour_after_set_title();
1181+
#endif
1182+
#endif
11581183
}
11591184

11601185
void MainFrame::show_calibration_button(bool show, bool is_BBL)

‎src/slic3r/GUI/MainFrame.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class MainFrame : public DPIFrame
9696
#endif
9797
bool m_loaded {false};
9898
wxTimer* m_reset_title_text_colour_timer{ nullptr };
99+
wxString m_title_cache; // last value applied by update_title(), avoids redundant SetTitle
99100

100101
wxString m_qs_last_input_file = wxEmptyString;
101102
wxString m_qs_last_output_file = wxEmptyString;

0 commit comments

Comments
 (0)