mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-26 02:11:18 +00:00
Fix Printer Agent preset undo (#15645)
Co-authored-by: Rodrigo Faselli <162915171+RF47@users.noreply.github.com>
This commit is contained in:
co-authored by
Rodrigo Faselli
parent
aef9ca2efb
commit
fd63164268
+5
-39
@@ -5029,28 +5029,12 @@ void TabPrinter::build_fff()
|
||||
auto registered_printer_agents = NetworkAgentFactory::get_registered_printer_agents();
|
||||
if (!registered_printer_agents.empty())
|
||||
{
|
||||
ConfigOptionDef def;
|
||||
def.type = coString;
|
||||
def.gui_type = ConfigOptionDef::GUIType::printer_agent_select;
|
||||
def.width = 3 * Field::def_width_wider() / 2;
|
||||
def.label = L("Printer Agent");
|
||||
def.tooltip = L("Select the network agent implementation for printer communication. "
|
||||
option = optgroup->get_option("printer_agent");
|
||||
option.opt.gui_type = ConfigOptionDef::GUIType::printer_agent_select;
|
||||
option.opt.width = 3 * Field::def_width_wider() / 2;
|
||||
option.opt.tooltip = L("Select the network agent implementation for printer communication. "
|
||||
"Available agents are registered at startup.");
|
||||
def.mode = comAdvanced;
|
||||
|
||||
// Create the field without get_option() so it is not registered in m_opt_map.
|
||||
// ConfigOptionsGroup handles printer_agent before the generic mapped write path.
|
||||
Line agent_line = optgroup->create_single_option_line(Option(def, "printer_agent"));
|
||||
optgroup->append_line(agent_line);
|
||||
if (Field* agent_field = get_field("printer_agent"))
|
||||
{
|
||||
if (auto* choice = dynamic_cast<PrinterAgentChoice*>(agent_field); choice && choice->getWindow())
|
||||
choice->set_value(m_config->opt_string("printer_agent"), false);
|
||||
}
|
||||
|
||||
// Register by hand so the UnsavedChanges dialog can render a row for it.
|
||||
wxGetApp().sidebar().get_searcher().add_key("printer_agent", m_type, optgroup->title,
|
||||
optgroup->config_category());
|
||||
optgroup->append_single_option_line(option);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5912,15 +5896,6 @@ void TabPrinter::reload_config()
|
||||
if (m_active_page && m_active_page->title() == "Multimaterial")
|
||||
m_active_page->set_value("extruders_count", int(m_extruders_count));
|
||||
|
||||
// m_opt_map-driven reload does not cover printer_agent, so sync this custom field explicitly.
|
||||
if (Field* agent_field = get_field("printer_agent"))
|
||||
{
|
||||
if (auto* choice = dynamic_cast<PrinterAgentChoice*>(agent_field); choice && choice->getWindow())
|
||||
{
|
||||
const std::string selected_agent = m_config->opt_string("printer_agent");
|
||||
choice->set_value(selected_agent, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TabPrinter::activate_selected_page(std::function<void()> throw_if_canceled)
|
||||
@@ -5932,15 +5907,6 @@ void TabPrinter::activate_selected_page(std::function<void()> throw_if_canceled)
|
||||
if (m_active_page && m_active_page->title() == "Multimaterial")
|
||||
m_active_page->set_value("extruders_count", int(m_extruders_count));
|
||||
|
||||
// m_opt_map-driven reload does not cover printer_agent, so sync this custom field explicitly.
|
||||
if (Field* agent_field = get_field("printer_agent"))
|
||||
{
|
||||
if (auto* choice = dynamic_cast<PrinterAgentChoice*>(agent_field); choice && choice->getWindow())
|
||||
{
|
||||
const std::string selected_agent = m_config->opt_string("printer_agent");
|
||||
choice->set_value(selected_agent, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TabPrinter::clear_pages()
|
||||
|
||||
Reference in New Issue
Block a user