mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-16 18:12:10 +00:00
ENH: clean codes about device
JIRA: [STUDIO-13609] Change-Id: I591de7033360b9570600006cfbce2148a8d031d5 (cherry picked from commit e9c774be8f4c89b8dafa14ef56913612fb68bd0c)
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include "BitmapCache.hpp"
|
||||
#include "BindDialog.hpp"
|
||||
|
||||
#include "DeviceCore/DevManager.h"
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_UPDATE_WINDOWS_POSITION, wxCommandEvent);
|
||||
@@ -169,7 +171,7 @@ void MachineObjectPanel::doRender(wxDC &dc)
|
||||
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
|
||||
wxString dev_name = "";
|
||||
if (m_info) {
|
||||
dev_name = from_u8(m_info->dev_name);
|
||||
dev_name = from_u8(m_info->get_dev_name());
|
||||
|
||||
if (m_state == PrinterState::IN_LAN) {
|
||||
dev_name += _L("(LAN)");
|
||||
@@ -270,7 +272,7 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
} else {
|
||||
if (m_info) {
|
||||
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
|
||||
wxGetApp().mainframe->jump_to_monitor(m_info->get_dev_id());
|
||||
}
|
||||
//wxGetApp().mainframe->SetFocus();
|
||||
wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST);
|
||||
@@ -281,14 +283,14 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
|
||||
}
|
||||
if (m_info && m_info->is_lan_mode_printer()) {
|
||||
if (m_info->has_access_right() && m_info->is_avaliable()) {
|
||||
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
|
||||
wxGetApp().mainframe->jump_to_monitor(m_info->get_dev_id());
|
||||
} else {
|
||||
wxCommandEvent event(EVT_CONNECT_LAN_PRINT);
|
||||
event.SetEventObject(this);
|
||||
wxPostEvent(this, event);
|
||||
}
|
||||
} else {
|
||||
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id);
|
||||
wxGetApp().mainframe->jump_to_monitor(m_info->get_dev_id());
|
||||
}
|
||||
} else {
|
||||
if (m_info && m_info->is_lan_mode_printer()) {
|
||||
@@ -491,7 +493,7 @@ void SelectMachinePopup::update_other_devices()
|
||||
{
|
||||
DeviceManager* dev = wxGetApp().getDeviceManager();
|
||||
if (!dev) return;
|
||||
m_free_machine_list = dev->get_local_machine_list();
|
||||
m_free_machine_list = dev->get_local_machinelist();
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_other_devices start";
|
||||
this->Freeze();
|
||||
@@ -507,7 +509,7 @@ void SelectMachinePopup::update_other_devices()
|
||||
continue;
|
||||
|
||||
/* do not show printer in my list */
|
||||
auto it = m_bind_machine_list.find(mobj->dev_id);
|
||||
auto it = m_bind_machine_list.find(mobj->get_dev_id());
|
||||
if (it != m_bind_machine_list.end())
|
||||
continue;
|
||||
|
||||
@@ -559,7 +561,7 @@ void SelectMachinePopup::update_other_devices()
|
||||
ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
|
||||
dlg.set_machine_object(mobj);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
wxGetApp().mainframe->jump_to_monitor(mobj->dev_id);
|
||||
wxGetApp().mainframe->jump_to_monitor(mobj->get_dev_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -570,7 +572,7 @@ void SelectMachinePopup::update_other_devices()
|
||||
dlg.update_machine_info(mobj);
|
||||
int dlg_result = wxID_CANCEL;
|
||||
dlg_result = dlg.ShowModal();
|
||||
if (dlg_result == wxID_OK) { wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); }
|
||||
if (dlg_result == wxID_OK) { wxGetApp().mainframe->jump_to_monitor(mobj->get_dev_id()); }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -634,7 +636,7 @@ void SelectMachinePopup::update_user_devices()
|
||||
|
||||
std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto& a, auto&b) {
|
||||
if (a.second && b.second) {
|
||||
return a.second->dev_name.compare(b.second->dev_name) < 0;
|
||||
return a.second->get_dev_name().compare(b.second->get_dev_name()) < 0;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
@@ -690,7 +692,7 @@ void SelectMachinePopup::update_user_devices()
|
||||
if (mobj) {
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (config) {
|
||||
config->erase_local_machine(mobj->dev_id);
|
||||
config->erase_local_machine(mobj->get_dev_id());
|
||||
}
|
||||
|
||||
mobj->set_access_code("");
|
||||
@@ -739,7 +741,7 @@ void SelectMachinePopup::update_user_devices()
|
||||
ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
|
||||
dlg.set_machine_object(mobj);
|
||||
if (dlg.ShowModal() == wxID_OK) {
|
||||
wxGetApp().mainframe->jump_to_monitor(mobj->dev_id);
|
||||
wxGetApp().mainframe->jump_to_monitor(mobj->get_dev_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -776,14 +778,14 @@ bool SelectMachinePopup::search_for_printer(MachineObject* obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto& name = wxString::FromUTF8(obj->dev_name).ToStdString();
|
||||
const auto& name = wxString::FromUTF8(obj->get_dev_name()).ToStdString();
|
||||
const auto& name_it = name.find(search_text);
|
||||
if (name_it != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
const auto& ip_it = obj->dev_ip.find(search_text);
|
||||
const auto& ip_it = obj->get_dev_ip().find(search_text);
|
||||
if (ip_it != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
@@ -908,7 +910,7 @@ void EditDevNameDialog::set_machine_obj(MachineObject *obj)
|
||||
{
|
||||
m_info = obj;
|
||||
if (m_info)
|
||||
m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->dev_name));
|
||||
m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->get_dev_name()));
|
||||
}
|
||||
|
||||
void EditDevNameDialog::on_dpi_changed(const wxRect &suggested_rect)
|
||||
@@ -974,7 +976,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
|
||||
auto utf8_str = new_dev_name.ToUTF8();
|
||||
auto name = std::string(utf8_str.data(), utf8_str.length());
|
||||
if (m_info)
|
||||
dev->modify_device_name(m_info->dev_id, name);
|
||||
dev->modify_device_name(m_info->get_dev_id(), name);
|
||||
}
|
||||
DPIDialog::EndModal(wxID_CLOSE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user