Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into dev
This commit is contained in:
commit
8d94841fa3
11 changed files with 153 additions and 94 deletions
src/slic3r/GUI
|
@ -770,7 +770,9 @@ void GUI_App::post_init()
|
|||
// This is ugly but I honestly found no better way to do it.
|
||||
// Neither wxShowEvent nor wxWindowCreateEvent work reliably.
|
||||
if (this->preset_updater) { // G-Code Viewer does not initialize preset_updater.
|
||||
this->check_updates(false);
|
||||
if (! this->check_updates(false))
|
||||
// Configuration is not compatible and reconfigure was refused by the user. Application is closing.
|
||||
return;
|
||||
CallAfter([this] {
|
||||
bool cw_showed = this->config_wizard_startup();
|
||||
this->preset_updater->sync(preset_bundle);
|
||||
|
@ -789,6 +791,10 @@ void GUI_App::post_init()
|
|||
});
|
||||
}
|
||||
|
||||
// Set PrusaSlicer version and save to PrusaSlicer.ini or PrusaSlicerGcodeViewer.ini.
|
||||
app_config->set("version", SLIC3R_VERSION);
|
||||
app_config->save();
|
||||
|
||||
#ifdef _WIN32
|
||||
// Sets window property to mainframe so other instances can indentify it.
|
||||
OtherInstanceMessageHandler::init_windows_properties(mainframe, m_instance_hash_int);
|
||||
|
@ -1033,6 +1039,8 @@ bool GUI_App::OnInit()
|
|||
}
|
||||
}
|
||||
|
||||
static bool update_gui_after_init = true;
|
||||
|
||||
bool GUI_App::on_init_inner()
|
||||
{
|
||||
// Set initialization of image handlers before any UI actions - See GH issue #7469
|
||||
|
@ -1178,12 +1186,10 @@ bool GUI_App::on_init_inner()
|
|||
// supplied as argument to --datadir; in that case we should still run the wizard
|
||||
preset_bundle->setup_directories();
|
||||
|
||||
if (! older_data_dir_path.empty())
|
||||
if (! older_data_dir_path.empty()) {
|
||||
preset_bundle->import_newer_configs(older_data_dir_path);
|
||||
|
||||
// Save PrusaSlicer.ini after possibly copying the config from the alternate location and after all the configs from the alternate location were copied.
|
||||
app_config->set("version", SLIC3R_VERSION);
|
||||
app_config->save();
|
||||
app_config->save();
|
||||
}
|
||||
|
||||
if (is_editor()) {
|
||||
#ifdef __WXMSW__
|
||||
|
@ -1299,13 +1305,8 @@ bool GUI_App::on_init_inner()
|
|||
if (! plater_)
|
||||
return;
|
||||
|
||||
if (app_config->dirty() && app_config->get("autosave") == "1")
|
||||
app_config->save();
|
||||
|
||||
this->obj_manipul()->update_if_dirty();
|
||||
|
||||
static bool update_gui_after_init = true;
|
||||
|
||||
// An ugly solution to GH #5537 in which GUI_App::init_opengl (normally called from events wxEVT_PAINT
|
||||
// and wxEVT_SET_FOCUS before GUI_App::post_init is called) wasn't called before GUI_App::post_init and OpenGL wasn't initialized.
|
||||
#ifdef __linux__
|
||||
|
@ -1319,6 +1320,9 @@ bool GUI_App::on_init_inner()
|
|||
#endif
|
||||
this->post_init();
|
||||
}
|
||||
|
||||
if (! update_gui_after_init && app_config->dirty() && app_config->get("autosave") == "1")
|
||||
app_config->save();
|
||||
});
|
||||
|
||||
m_initialized = true;
|
||||
|
@ -1404,6 +1408,7 @@ void GUI_App::init_label_colours()
|
|||
m_color_highlight_label_default = is_dark_mode ? wxColour(230, 230, 230): wxSystemSettings::GetColour(/*wxSYS_COLOUR_HIGHLIGHTTEXT*/wxSYS_COLOUR_WINDOWTEXT);
|
||||
m_color_highlight_default = is_dark_mode ? wxColour(78, 78, 78) : wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
|
||||
m_color_hovered_btn_label = is_dark_mode ? wxColour(253, 111, 40) : wxColour(252, 77, 1);
|
||||
m_color_default_btn_label = is_dark_mode ? wxColour(255, 181, 100): wxColour(203, 61, 0);
|
||||
m_color_selected_btn_bg = is_dark_mode ? wxColour(95, 73, 62) : wxColour(228, 220, 216);
|
||||
#else
|
||||
m_color_label_default = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
|
@ -1438,12 +1443,22 @@ static bool is_focused(HWND hWnd)
|
|||
HWND hFocusedWnd = ::GetFocus();
|
||||
return hFocusedWnd && hWnd == hFocusedWnd;
|
||||
}
|
||||
|
||||
static bool is_default(wxWindow* win)
|
||||
{
|
||||
wxTopLevelWindow* tlw = find_toplevel_parent(win);
|
||||
if (!tlw)
|
||||
return false;
|
||||
|
||||
return win == tlw->GetDefaultItem();
|
||||
}
|
||||
#endif
|
||||
|
||||
void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool just_font/* = false*/)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
bool is_focused_button = false;
|
||||
bool is_default_button = false;
|
||||
if (wxButton* btn = dynamic_cast<wxButton*>(window)) {
|
||||
if (!(btn->GetWindowStyle() & wxNO_BORDER)) {
|
||||
btn->SetWindowStyle(btn->GetWindowStyle() | wxNO_BORDER);
|
||||
|
@ -1455,7 +1470,7 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
|
|||
if (btn->GetLabel().IsEmpty())
|
||||
btn->SetBackgroundColour(mark ? m_color_selected_btn_bg : highlited ? m_color_highlight_default : m_color_window_default);
|
||||
else
|
||||
btn->SetForegroundColour(mark ? m_color_hovered_btn_label : m_color_label_default);
|
||||
btn->SetForegroundColour(mark ? m_color_hovered_btn_label : (is_default(btn) ? m_color_default_btn_label : m_color_label_default));
|
||||
btn->Refresh();
|
||||
btn->Update();
|
||||
};
|
||||
|
@ -1467,8 +1482,10 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
|
|||
btn->Bind(wxEVT_SET_FOCUS, [mark_button](wxFocusEvent& event) { mark_button(true); event.Skip(); });
|
||||
btn->Bind(wxEVT_KILL_FOCUS, [mark_button](wxFocusEvent& event) { mark_button(false); event.Skip(); });
|
||||
|
||||
if (is_focused_button = is_focused(btn->GetHWND()))
|
||||
mark_button(true);
|
||||
is_focused_button = is_focused(btn->GetHWND());
|
||||
is_default_button = is_default(btn);
|
||||
if (is_focused_button || is_default_button)
|
||||
mark_button(is_focused_button);
|
||||
}
|
||||
}
|
||||
else if (wxTextCtrl* text = dynamic_cast<wxTextCtrl*>(window)) {
|
||||
|
@ -1490,7 +1507,7 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
|
|||
|
||||
if (!just_font)
|
||||
window->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
|
||||
if (!is_focused_button)
|
||||
if (!is_focused_button && !is_default_button)
|
||||
window->SetForegroundColour(m_color_label_default);
|
||||
#endif
|
||||
}
|
||||
|
@ -3003,13 +3020,15 @@ bool GUI_App::config_wizard_startup()
|
|||
return false;
|
||||
}
|
||||
|
||||
void GUI_App::check_updates(const bool verbose)
|
||||
bool GUI_App::check_updates(const bool verbose)
|
||||
{
|
||||
PresetUpdater::UpdateResult updater_result;
|
||||
try {
|
||||
updater_result = preset_updater->config_update(app_config->orig_version(), verbose ? PresetUpdater::UpdateParams::SHOW_TEXT_BOX : PresetUpdater::UpdateParams::SHOW_NOTIFICATION);
|
||||
if (updater_result == PresetUpdater::R_INCOMPAT_EXIT) {
|
||||
mainframe->Close();
|
||||
// Applicaiton is closing.
|
||||
return false;
|
||||
}
|
||||
else if (updater_result == PresetUpdater::R_INCOMPAT_CONFIGURED) {
|
||||
m_app_conf_exists = true;
|
||||
|
@ -3022,6 +3041,8 @@ void GUI_App::check_updates(const bool verbose)
|
|||
catch (const std::exception & ex) {
|
||||
show_error(nullptr, ex.what());
|
||||
}
|
||||
// Applicaiton will continue.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GUI_App::open_browser_with_warning_dialog(const wxString& url, wxWindow* parent/* = nullptr*/, bool force_remember_choice /*= true*/, int flags/* = 0*/)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue