Fixed serialization of position and size of the non modal settings dialog

This commit is contained in:
enricoturri1966 2020-06-10 09:00:17 +02:00
parent 1e3290fee1
commit 3b061fb4be
2 changed files with 11 additions and 10 deletions

View file

@ -715,24 +715,16 @@ void GUI_App::update_ui_from_settings()
void GUI_App::persist_window_geometry(wxTopLevelWindow *window, bool default_maximized)
{
const std::string name = into_u8(window->GetName());
wxTopLevelWindow* settings_dlg = dynamic_cast<MainFrame*>(window)->m_settings_dialog;
const std::string settings_dlg_name = "settings_dialog";
window->Bind(wxEVT_CLOSE_WINDOW, [=](wxCloseEvent &event) {
window_pos_save(window, name);
if (settings_dlg)
window_pos_save(settings_dlg, settings_dlg_name);
event.Skip();
});
window_pos_restore(window, name, default_maximized);
if (settings_dlg)
window_pos_restore(settings_dlg, settings_dlg_name, default_maximized);
on_window_geometry(window, [=]() {
window_pos_sanitize(window);
if (settings_dlg)
window_pos_sanitize(settings_dlg);
});
}

View file

@ -205,6 +205,8 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
});
wxGetApp().persist_window_geometry(this, true);
if (m_settings_dialog != nullptr)
wxGetApp().persist_window_geometry(m_settings_dialog, true);
update_ui_from_settings(); // FIXME (?)
@ -244,8 +246,14 @@ void MainFrame::shutdown()
// In addition, there were some crashes due to the Paint events sent to already destructed windows.
this->Show(false);
if (m_settings_dialog)
if (m_settings_dialog != nullptr)
{
if (m_settings_dialog->IsShown())
// call Close() to trigger call to lambda defined into GUI_App::persist_window_geometry()
m_settings_dialog->Close();
m_settings_dialog->Destroy();
}
// Stop the background thread (Windows and Linux).
// Disconnect from a 3DConnextion driver (OSX).
@ -1444,7 +1452,8 @@ std::string MainFrame::get_dir_name(const wxString &full_name) const
// ----------------------------------------------------------------------------
SettingsDialog::SettingsDialog(MainFrame* mainframe)
: DPIDialog(nullptr, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings")),
: DPIDialog(nullptr, wxID_ANY, wxString(SLIC3R_APP_NAME) + " - " + _L("Settings"), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxDIALOG_NO_PARENT, "settings_dialog"),
m_main_frame(mainframe)
{
this->SetFont(wxGetApp().normal_font());