Mark unsaved project title with * (#5910)

* Mark unsaved project title with *
This commit is contained in:
Vovodroid 2024-06-29 17:13:57 +03:00 committed by GitHub
parent b47810435a
commit 5ff93fe103
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 3 deletions

View file

@ -1999,6 +1999,9 @@ void MainFrame::update_slice_print_status(SlicePrintEventType event, bool can_sl
m_slice_btn->Enable(enable_slice);
m_slice_enable = enable_slice;
m_print_enable = enable_print;
if (wxGetApp().mainframe)
wxGetApp().plater()->update_title_dirty_status();
}

View file

@ -2572,6 +2572,7 @@ struct Plater::priv
//BBS store bbs project name
wxString get_project_name();
void set_project_name(const wxString& project_name);
void update_title_dirty_status();
// Call after plater and Canvas#D is initialized
void init_notification_manager();
@ -7649,6 +7650,25 @@ void Plater::priv::set_project_name(const wxString& project_name)
#endif
}
void Plater::priv::update_title_dirty_status()
{
if (m_project_name.empty())
return;
wxString title;
if (is_project_dirty())
title = "*" + m_project_name;
else
title = m_project_name;
#ifdef __WINDOWS__
wxGetApp().mainframe->topbar()->SetTitle(title);
#else
wxGetApp().mainframe->SetTitle(title);
wxGetApp().mainframe->update_title_colour_after_set_title();
#endif
}
void Plater::priv::set_project_filename(const wxString& filename)
{
boost::filesystem::path full_path = into_path(filename);
@ -8525,6 +8545,7 @@ void Plater::priv::undo_redo_to(std::vector<UndoRedo::Snapshot>::const_iterator
}
dirty_state.update_from_undo_redo_stack(m_undo_redo_stack_main.project_modified());
update_title_dirty_status();
}
void Plater::priv::update_after_undo_redo(const UndoRedo::Snapshot& snapshot, bool /* temp_snapshot_was_taken */)
@ -8941,6 +8962,7 @@ int Plater::save_project(bool saveAs)
}
catch (...) {}
update_title_dirty_status();
return wxID_YES;
}
@ -12778,8 +12800,10 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
if (update_scheduled)
update();
if (p->main_frame->is_loaded())
if (p->main_frame->is_loaded()) {
this->p->schedule_background_process();
update_title_dirty_status();
}
}
void Plater::set_bed_shape() const
@ -14282,6 +14306,11 @@ bool Plater::PopupObjectTableBySelection()
return p->PopupObjectTable(obj_idx, vol_idx, pos);
}
void Plater::update_title_dirty_status()
{
p->update_title_dirty_status();
}
wxMenu* Plater::plate_menu() { return p->menus.plate_menu(); }
wxMenu* Plater::object_menu() { return p->menus.object_menu(); }

View file

@ -654,6 +654,7 @@ public:
bool need_update() const;
void set_need_update(bool need_update);
void update_title_dirty_status();
// ROII wrapper for suppressing the Undo / Redo snapshot to be taken.
class SuppressSnapshots

View file

@ -17,8 +17,7 @@ namespace GUI {
void ProjectDirtyStateManager::update_from_undo_redo_stack(bool dirty)
{
if (!m_plater_dirty)
m_plater_dirty = dirty;
m_plater_dirty = dirty;
if (const Plater *plater = wxGetApp().plater(); plater && wxGetApp().initialized())
wxGetApp().mainframe->update_title();
}