diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 3fb590d35e..ea81b61bb3 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -90,6 +90,23 @@ using Config::Snapshot; using Config::SnapshotDB; + +ConfigWizardLoadingDialog::ConfigWizardLoadingDialog(wxWindow* parent, const wxString& message) + : wxDialog(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxFRAME_FLOAT_ON_PARENT) +{ + auto* text = new wxStaticText(this, wxID_ANY, message, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); + auto* vsizer = new wxBoxSizer(wxVERTICAL); + auto *top_sizer = new wxBoxSizer(wxVERTICAL); + vsizer->Add(text, 1, wxEXPAND); + top_sizer->Add(vsizer, 1, wxEXPAND | wxALL, 15); + SetSizer(top_sizer); + #ifdef _WIN32 + wxGetApp().UpdateDlgDarkUI(this); + #endif + Fit(); +} + + // Configuration data structures extensions needed for the wizard bool Bundle::load(fs::path source_path, BundleLocation location, bool ais_prusa_bundle) diff --git a/src/slic3r/GUI/ConfigWizard.hpp b/src/slic3r/GUI/ConfigWizard.hpp index 1425b7cfa4..9156d3dfee 100644 --- a/src/slic3r/GUI/ConfigWizard.hpp +++ b/src/slic3r/GUI/ConfigWizard.hpp @@ -25,6 +25,12 @@ class PresetUpdater; namespace GUI { +class ConfigWizardLoadingDialog : public wxDialog +{ +public: + ConfigWizardLoadingDialog(wxWindow* parent, const wxString& message); +}; + namespace DownloaderUtils { class Worker : public wxBoxSizer { diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 2003b8aaa4..6d166403da 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3224,9 +3224,19 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage #endif // 0 plater()->get_preset_archive_database()->sync_blocking(); + // ConfigWizard can take some time to start. Because it is a wxWidgets window, it has to be done in UI thread, + // so displaying a nice modal dialog and letting the CW start in a worker thread is not an option. + // Let's at least show a modeless dialog before the UI thread freezes. + auto cw_loading_dlg = new ConfigWizardLoadingDialog(mainframe, _L("Loading Configuration Wizard...")); + cw_loading_dlg->CenterOnParent(); + cw_loading_dlg->Show(); + wxYield(); auto wizard = new ConfigWizard(mainframe); + cw_loading_dlg->Close(); + const bool res = wizard->run(reason, start_page); + // !!! Deallocate memory after close ConfigWizard. // Note, that mainframe is a parent of ConfigWizard. // So, wizard will be destroyed only during destroying of mainframe