mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 00:37:51 -06:00
A part of code related to loads after App::OnInit() call is moved from PrusaSlicer.cpp to GUI_App.cpp
Splash Screen under OSX requires a call of wxYeild() for update. But wxYield() furthers a case, when CallAfter() in CLI::run() was called at the wrong time, before some of the GUI was created. So, there is workaround: Parameters needed for later loads are encapsulated to GUI_App::AFTER_INIT_LOADS structure and are used in GUI_App::AFTER_INIT_LOADS::on_loads which is called just ones after wxEVT_IDLE
This commit is contained in:
parent
1fb400a091
commit
48f775decb
3 changed files with 83 additions and 1 deletions
|
@ -123,6 +123,10 @@ public:
|
|||
|
||||
memDC.SelectObject(wxNullBitmap);
|
||||
set_bitmap(bitmap);
|
||||
#ifdef __WXOSX__
|
||||
// without this code splash screen wouldn't be updated under OSX
|
||||
wxYield();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -531,6 +535,41 @@ static void generic_exception_handle()
|
|||
}
|
||||
}
|
||||
|
||||
void GUI_App::AFTER_INIT_LOADS::on_loads(GUI_App* gui)
|
||||
{
|
||||
if (!gui->initialized())
|
||||
return;
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
if (m_start_as_gcodeviewer) {
|
||||
if (!m_input_files.empty())
|
||||
gui->plater()->load_gcode(wxString::FromUTF8(m_input_files[0].c_str()));
|
||||
}
|
||||
else {
|
||||
#endif // ENABLE_GCODE_VIEWER_AS
|
||||
#if 0
|
||||
// Load the cummulative config over the currently active profiles.
|
||||
//FIXME if multiple configs are loaded, only the last one will have an effect.
|
||||
// We need to decide what to do about loading of separate presets (just print preset, just filament preset etc).
|
||||
// As of now only the full configs are supported here.
|
||||
if (!m_print_config.empty())
|
||||
gui->mainframe->load_config(m_print_config);
|
||||
#endif
|
||||
if (!m_load_configs.empty())
|
||||
// Load the last config to give it a name at the UI. The name of the preset may be later
|
||||
// changed by loading an AMF or 3MF.
|
||||
//FIXME this is not strictly correct, as one may pass a print/filament/printer profile here instead of a full config.
|
||||
gui->mainframe->load_config_file(m_load_configs.back());
|
||||
// If loading a 3MF file, the config is loaded from the last one.
|
||||
if (!m_input_files.empty())
|
||||
gui->plater()->load_files(m_input_files, true, true);
|
||||
if (!m_extra_config.empty())
|
||||
gui->mainframe->load_config(m_extra_config);
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
|
||||
IMPLEMENT_APP(GUI_App)
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
|
@ -696,7 +735,6 @@ bool GUI_App::on_init_inner()
|
|||
// create splash screen with updated bmp
|
||||
scrn = new SplashScreen(bmp.IsOk() ? bmp : create_scaled_bitmap("prusa_slicer_logo", nullptr, 400),
|
||||
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 4000, splashscreen_pos, is_decorated);
|
||||
wxYield();
|
||||
scrn->SetText(_L("Loading configuration..."));
|
||||
}
|
||||
|
||||
|
@ -785,6 +823,13 @@ bool GUI_App::on_init_inner()
|
|||
|
||||
this->obj_manipul()->update_if_dirty();
|
||||
|
||||
static bool update_gui_after_init = true;
|
||||
if (update_gui_after_init)
|
||||
{
|
||||
update_gui_after_init = false;
|
||||
m_after_init_loads.on_loads(this);
|
||||
}
|
||||
|
||||
// Preset updating & Configwizard are done after the above initializations,
|
||||
// and after MainFrame is created & shown.
|
||||
// The extra CallAfter() is needed because of Mac, where this is the only way
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue