badge support
This commit is contained in:
@ -612,6 +612,9 @@ void DevFilaSystemParser::ParseV1_0(const json& jj, MachineObject* obj, DevFilaS
|
||||
{
|
||||
curr_tray->remain = -1;
|
||||
}
|
||||
if (tray_it->contains("tray_slot_placeholder")) {
|
||||
curr_tray->is_slot_placeholder = true;
|
||||
}
|
||||
int ams_id_int = 0;
|
||||
int tray_id_int = 0;
|
||||
try
|
||||
|
||||
@ -53,6 +53,7 @@ public:
|
||||
wxColour wx_color;
|
||||
bool is_bbl;
|
||||
bool is_exists = false;
|
||||
bool is_slot_placeholder = false; // Orca: True for empty tray slots from pull-mode agents
|
||||
int hold_count = 0;
|
||||
int remain = 0; // filament remain: 0 ~ 100
|
||||
|
||||
|
||||
@ -3469,16 +3469,25 @@ unsigned GUI_App::get_colour_approx_luma(const wxColour &colour)
|
||||
));
|
||||
}
|
||||
|
||||
void GUI_App::switch_printer_agent(const std::string& agent_id)
|
||||
void GUI_App::switch_printer_agent()
|
||||
{
|
||||
if (!m_agent) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": no agent exists";
|
||||
return;
|
||||
}
|
||||
|
||||
std::string agent_id;
|
||||
|
||||
const DynamicPrintConfig& config = preset_bundle->printers.get_edited_preset().config;
|
||||
if (config.has("printer_agent")) {
|
||||
std::string value = config.option<ConfigOptionString>("printer_agent")->value;
|
||||
if (!value.empty()) {
|
||||
agent_id = value;
|
||||
}
|
||||
}
|
||||
// Use registry to validate and create agent
|
||||
// If empty, use default
|
||||
std::string effective_agent_id = agent_id.empty() ? NetworkAgentFactory::get_default_printer_agent_id() : agent_id;
|
||||
std::string effective_agent_id = agent_id.empty() ? ORCA_PRINTER_AGENT_ID : agent_id;
|
||||
|
||||
// Check if agent is registered
|
||||
if (!NetworkAgentFactory::is_printer_agent_registered(effective_agent_id)) {
|
||||
|
||||
@ -342,7 +342,7 @@ public:
|
||||
NetworkAgent* getAgent() { return m_agent; }
|
||||
|
||||
// Dynamic printer agent switching
|
||||
void switch_printer_agent(const std::string& agent_id);
|
||||
void switch_printer_agent();
|
||||
|
||||
FilamentColorCodeQuery* get_filament_color_code_query();
|
||||
bool is_editor() const { return m_app_mode == EAppMode::Editor; }
|
||||
|
||||
@ -177,13 +177,13 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
|
||||
std::string selected_agent = current_agent;
|
||||
|
||||
if (selected_agent.empty()) {
|
||||
selected_agent = NetworkAgentFactory::get_default_printer_agent_id();
|
||||
selected_agent = ORCA_PRINTER_AGENT_ID;
|
||||
}
|
||||
|
||||
// Verify selected agent is valid
|
||||
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 = NetworkAgentFactory::get_default_printer_agent_id();
|
||||
selected_agent = ORCA_PRINTER_AGENT_ID;
|
||||
}
|
||||
|
||||
// Set default value for the enum (using the index)
|
||||
|
||||
@ -3230,6 +3230,7 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
||||
tray_config.set_key_value("filament_multi_colour", new ConfigOptionStrings{});
|
||||
tray_config.set_key_value("filament_colour_type", new ConfigOptionStrings{std::to_string(tray.ctype)});
|
||||
tray_config.set_key_value("filament_exist", new ConfigOptionBools{tray.is_exists});
|
||||
tray_config.set_key_value("filament_slot_placeholder", new ConfigOptionBools{tray.is_slot_placeholder});
|
||||
std::optional<FilamentBaseInfo> info;
|
||||
if (wxGetApp().preset_bundle) {
|
||||
info = wxGetApp().preset_bundle->get_filament_by_filament_id(tray.setting_id);
|
||||
@ -3520,8 +3521,15 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
|
||||
{ // badge ams filament
|
||||
clear_combos_filament_badge();
|
||||
if (sync_result.direct_sync) {
|
||||
for (auto &c : p->combos_filament) {
|
||||
badge_combox_filament(c);
|
||||
auto& ams_list = wxGetApp().preset_bundle->filament_ams_list;
|
||||
size_t tray_idx = 0;
|
||||
for (auto& entry : ams_list) {
|
||||
if (tray_idx >= p->combos_filament.size()) break;
|
||||
auto filament_id = entry.second.opt_string("filament_id", 0u);
|
||||
if (!filament_id.empty()) {
|
||||
badge_combox_filament(p->combos_filament[tray_idx]);
|
||||
}
|
||||
tray_idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2136,22 +2136,7 @@ void Tab::on_presets_changed()
|
||||
|
||||
void Tab::update_printer_agent_if_needed()
|
||||
{
|
||||
std::string agent_id = "orca";
|
||||
if (m_preset_bundle) {
|
||||
if (wxGetApp().preset_bundle->is_bbl_vendor()) {
|
||||
agent_id = "bbl";
|
||||
} else if (wxGetApp().preset_bundle->is_qidi_vendor()) {
|
||||
agent_id = "qidi";
|
||||
}
|
||||
}
|
||||
|
||||
const DynamicPrintConfig& config = m_preset_bundle->printers.get_edited_preset().config;
|
||||
if (config.has("printer_agent")) {
|
||||
std::string value = config.option<ConfigOptionString>("printer_agent")->value;
|
||||
if (!value.empty()) {
|
||||
agent_id = value;
|
||||
}
|
||||
}
|
||||
// Switch agent in GUI_App
|
||||
wxGetApp().switch_printer_agent(agent_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user