mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-21 18:02:09 +00:00
Compare commits
2 Commits
fix/plugin
...
fix/crash_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5be8075e9 | ||
|
|
8d528b2a8f |
@@ -591,6 +591,7 @@ namespace Slic3r
|
|||||||
}
|
}
|
||||||
|
|
||||||
selected_machine = dev_id;
|
selected_machine = dev_id;
|
||||||
|
record_user_last_machine(selected_machine);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,21 +854,39 @@ namespace Slic3r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceManager::record_user_last_machine(const std::string& dev_id)
|
||||||
|
{
|
||||||
|
if (Slic3r::GUI::wxGetApp().app_config) {
|
||||||
|
Slic3r::GUI::wxGetApp().app_config->set("user_last_selected_machine", dev_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DeviceManager::get_user_last_machine() const
|
||||||
|
{
|
||||||
|
if (Slic3r::GUI::wxGetApp().app_config) {
|
||||||
|
const auto& user_last_machine = Slic3r::GUI::wxGetApp().app_config->get("user_last_selected_machine");
|
||||||
|
if (!user_last_machine.empty()) {
|
||||||
|
return user_last_machine;
|
||||||
|
} else if (m_agent) {
|
||||||
|
return m_agent->get_user_selected_machine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceManager::load_last_machine()
|
void DeviceManager::load_last_machine()
|
||||||
{
|
{
|
||||||
// Get all available machines, include cloud machines and lan machines that have access right
|
if (userMachineList.empty()) return;
|
||||||
auto all_machines = get_my_machine_list();
|
else if (userMachineList.size() == 1) {
|
||||||
if (all_machines.empty())
|
this->set_selected_machine(userMachineList.begin()->second->get_dev_id());
|
||||||
return;
|
|
||||||
|
|
||||||
// Then connect to the machine we last selected if available
|
|
||||||
const std::string last_monitor_machine = m_agent ? m_agent->get_user_selected_machine() : "";
|
|
||||||
const auto last_machine = all_machines.find(last_monitor_machine);
|
|
||||||
if (last_machine != all_machines.end()) {
|
|
||||||
this->set_selected_machine(last_machine->second->get_dev_id());
|
|
||||||
} else {
|
} else {
|
||||||
// If not, then select the first available one
|
const auto& last_monitor_machine = get_user_last_machine();
|
||||||
this->set_selected_machine(all_machines.begin()->second->get_dev_id());
|
if (userMachineList.find(last_monitor_machine) != userMachineList.end()) {
|
||||||
|
set_selected_machine(last_monitor_machine);
|
||||||
|
} else {
|
||||||
|
this->set_selected_machine(userMachineList.begin()->second->get_dev_id());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ public:
|
|||||||
MachineObject* get_selected_machine();
|
MachineObject* get_selected_machine();
|
||||||
bool set_selected_machine(std::string dev_id);
|
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;
|
||||||
|
|
||||||
// local machine
|
// local machine
|
||||||
void set_local_selected_machine(std::string dev_id) { local_selected_machine = dev_id; };
|
void set_local_selected_machine(std::string dev_id) { local_selected_machine = dev_id; };
|
||||||
MachineObject* get_local_selected_machine() const { return get_local_machine(local_selected_machine); }
|
MachineObject* get_local_selected_machine() const { return get_local_machine(local_selected_machine); }
|
||||||
|
|||||||
@@ -2637,7 +2637,6 @@ void GUI_App::on_start_subscribe_again(std::string dev_id)
|
|||||||
|
|
||||||
if ( (dev_id == obj->get_dev_id()) && obj->is_connecting() && obj->subscribe_counter > 0) {
|
if ( (dev_id == obj->get_dev_id()) && obj->is_connecting() && obj->subscribe_counter > 0) {
|
||||||
obj->subscribe_counter--;
|
obj->subscribe_counter--;
|
||||||
if(wxGetApp().getAgent()) wxGetApp().getAgent()->set_user_selected_machine(dev_id);
|
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": dev_id=" << obj->get_dev_id();
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": dev_id=" << obj->get_dev_id();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user