Reset device selection on agent swap or unload (#124)

set_live_printer_agent centralizes
the swap: deselect the machine,
clear stale sidebar state and the
previous agent's Other Devices, then
install the new agent (or null when
its provider vanished). Plugin
load/unload callbacks refresh the
dropdown and re-run agent selection.
load_last_machine no longer falls
back to the first available machine.
This commit is contained in:
Andrew
2026-07-16 16:27:53 +08:00
committed by Ian Chua
parent 12075459d2
commit a2a4ca20e4
6 changed files with 147 additions and 46 deletions

View File

@@ -48,8 +48,9 @@ public:
MachineObject* get_selected_machine();
bool set_selected_machine(std::string dev_id);
void record_user_last_machine(const std::string& dev_id);
std::string get_user_last_machine() const;
// why: clears stale sidebar sync-status / AMS visuals. Public so the printer-agent
// swap path can reuse it instead of duplicating the two sidebar calls.
void OnSelectedMachineLost();
// local machine
void set_local_selected_machine(std::string dev_id) { local_selected_machine = dev_id; };
@@ -70,6 +71,8 @@ public:
void erase_user_machine(std::string dev_id) { userMachineList.erase(dev_id); }
void clean_user_info(bool keep_local_selection = false);
void clear_other_devices();
void load_last_machine();
void update_user_machine_list_info(const std::string& provider);
void parse_user_print_info(std::string body);
@@ -110,7 +113,6 @@ private:
void check_pushing();
void OnMachineBindStateChanged(MachineObject* obj, const std::string& new_state);
void OnSelectedMachineLost();
void OnSelectedMachineChanged(const std::string& pre_dev_id, const std::string& new_dev_id);