mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-18 16:32:06 +00:00
clean up
This commit is contained in:
@@ -172,24 +172,16 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
|
||||
def.enum_labels.push_back(agent.display_name);
|
||||
}
|
||||
|
||||
// Set initial selection based on current config value or default
|
||||
const std::string current_agent = m_config->opt_string("printer_agent");
|
||||
std::string selected_agent = current_agent;
|
||||
|
||||
if (selected_agent.empty()) {
|
||||
selected_agent = ORCA_PRINTER_AGENT_ID;
|
||||
}
|
||||
|
||||
// Verify selected agent is valid
|
||||
// Resolve selected agent: use config value if valid, otherwise fall back to default
|
||||
std::string selected_agent = m_config->opt_string("printer_agent");
|
||||
auto it = std::find_if(agents.begin(), agents.end(), [&selected_agent](const auto& a) { return a.id == selected_agent; });
|
||||
if (it == agents.end()) {
|
||||
selected_agent = ORCA_PRINTER_AGENT_ID;
|
||||
it = std::find_if(agents.begin(), agents.end(), [&selected_agent](const auto& a) { return a.id == selected_agent; });
|
||||
}
|
||||
|
||||
// Set default value for the enum (using the index)
|
||||
auto def_it = std::find_if(agents.begin(), agents.end(), [&selected_agent](const auto& a) { return a.id == selected_agent; });
|
||||
if (def_it != agents.end()) {
|
||||
size_t default_idx = std::distance(agents.begin(), def_it);
|
||||
if (it != agents.end()) {
|
||||
size_t default_idx = std::distance(agents.begin(), it);
|
||||
def.set_default_value(new ConfigOptionInt(static_cast<int>(default_idx)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user