mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-10 08:17:51 -06:00
Follow-up of 908c48ae6a
-> Fixed update after switching tab after editing custom g-code in settings tabs (#6258)
This commit is contained in:
parent
991fa67fd1
commit
4496e2a8ce
3 changed files with 17 additions and 32 deletions
|
@ -525,7 +525,13 @@ void MainFrame::init_tabpanel()
|
||||||
m_tabpanel->Hide();
|
m_tabpanel->Hide();
|
||||||
m_settings_dialog.set_tabpanel(m_tabpanel);
|
m_settings_dialog.set_tabpanel(m_tabpanel);
|
||||||
|
|
||||||
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxEvent&) {
|
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxBookCtrlEvent& e) {
|
||||||
|
#if ENABLE_VALIDATE_CUSTOM_GCODE
|
||||||
|
Tab* old_tab = dynamic_cast<Tab*>(m_tabpanel->GetPage(e.GetOldSelection()));
|
||||||
|
if (old_tab)
|
||||||
|
old_tab->validate_custom_gcodes();
|
||||||
|
#endif // ENABLE_VALIDATE_CUSTOM_GCODE
|
||||||
|
|
||||||
wxWindow* panel = m_tabpanel->GetCurrentPage();
|
wxWindow* panel = m_tabpanel->GetCurrentPage();
|
||||||
Tab* tab = dynamic_cast<Tab*>(panel);
|
Tab* tab = dynamic_cast<Tab*>(panel);
|
||||||
|
|
||||||
|
@ -544,19 +550,6 @@ void MainFrame::init_tabpanel()
|
||||||
select_tab(size_t(0)); // select Plater
|
select_tab(size_t(0)); // select Plater
|
||||||
});
|
});
|
||||||
|
|
||||||
#if ENABLE_VALIDATE_CUSTOM_GCODE
|
|
||||||
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGING, [this](wxBookCtrlEvent& evt) {
|
|
||||||
wxWindow* panel = m_tabpanel->GetCurrentPage();
|
|
||||||
if (panel != nullptr) {
|
|
||||||
Tab* tab = dynamic_cast<Tab*>(panel);
|
|
||||||
if (tab != nullptr)
|
|
||||||
tab->validate_custom_gcodes();
|
|
||||||
// if (tab != nullptr && !tab->validate_custom_gcodes())
|
|
||||||
// evt.Veto();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
#endif // ENABLE_VALIDATE_CUSTOM_GCODE
|
|
||||||
|
|
||||||
m_plater = new Plater(this, this);
|
m_plater = new Plater(this, this);
|
||||||
m_plater->Hide();
|
m_plater->Hide();
|
||||||
|
|
||||||
|
|
|
@ -1738,7 +1738,7 @@ bool Tab::validate_custom_gcode(const wxString& title, const std::string& gcode)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void validate_custom_gcode_cb(Tab* tab, ConfigOptionsGroupShp opt_group, const t_config_option_key& opt_key, const boost::any& value) {
|
static void validate_custom_gcode_cb(Tab* tab, ConfigOptionsGroupShp opt_group, const t_config_option_key& opt_key, const boost::any& value) {
|
||||||
Tab::validate_custom_gcode(opt_group->title, boost::any_cast<std::string>(value));
|
tab->validate_custom_gcodes_was_shown = !Tab::validate_custom_gcode(opt_group->title, boost::any_cast<std::string>(value));
|
||||||
tab->update_dirty();
|
tab->update_dirty();
|
||||||
tab->on_value_change(opt_key, value);
|
tab->on_value_change(opt_key, value);
|
||||||
}
|
}
|
||||||
|
@ -3837,27 +3837,18 @@ bool Tab::validate_custom_gcodes()
|
||||||
if (m_active_page->title() != L("Custom G-code"))
|
if (m_active_page->title() != L("Custom G-code"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// When we switch Settings tab after editing of the custom g-code, then warning message could ba already shown after KillFocus event
|
||||||
|
// and then it's no need to show it again
|
||||||
|
if (validate_custom_gcodes_was_shown) {
|
||||||
|
validate_custom_gcodes_was_shown = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
for (auto opt_group : m_active_page->m_optgroups) {
|
for (auto opt_group : m_active_page->m_optgroups) {
|
||||||
assert(opt_group->opt_map().size() == 1);
|
assert(opt_group->opt_map().size() == 1);
|
||||||
std::string key = opt_group->opt_map().begin()->first;
|
std::string key = opt_group->opt_map().begin()->first;
|
||||||
std::string value = boost::any_cast<std::string>(opt_group->get_value(key));
|
valid &= validate_custom_gcode(opt_group->title, boost::any_cast<std::string>(opt_group->get_value(key)));
|
||||||
std::string config_value = m_type == Preset::TYPE_FILAMENT ? m_config->opt_string(key, 0u) : m_config->opt_string(key);
|
|
||||||
valid &= validate_custom_gcode(opt_group->title, value);
|
|
||||||
Field* field = opt_group->get_field(key);
|
|
||||||
TextCtrl* text_ctrl = dynamic_cast<TextCtrl*>(field);
|
|
||||||
if (text_ctrl != nullptr && text_ctrl->m_on_change != nullptr && !text_ctrl->m_disable_change_event) {
|
|
||||||
Slic3r::GUI::t_change callback = opt_group->m_on_change;
|
|
||||||
// temporary disable the opt_group->m_on_change callback to avoid multiple validations
|
|
||||||
opt_group->m_on_change = nullptr;
|
|
||||||
text_ctrl->m_on_change(key, value);
|
|
||||||
// restore the opt_group->m_on_change callback
|
|
||||||
opt_group->m_on_change = callback;
|
|
||||||
|
|
||||||
update_dirty();
|
|
||||||
on_value_change(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!valid)
|
if (!valid)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,6 +351,7 @@ public:
|
||||||
#if ENABLE_VALIDATE_CUSTOM_GCODE
|
#if ENABLE_VALIDATE_CUSTOM_GCODE
|
||||||
static bool validate_custom_gcode(const wxString& title, const std::string& gcode);
|
static bool validate_custom_gcode(const wxString& title, const std::string& gcode);
|
||||||
bool validate_custom_gcodes();
|
bool validate_custom_gcodes();
|
||||||
|
bool validate_custom_gcodes_was_shown { false };
|
||||||
#endif // ENABLE_VALIDATE_CUSTOM_GCODE
|
#endif // ENABLE_VALIDATE_CUSTOM_GCODE
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue