micro refactor vender type

This commit is contained in:
SoftFever 2023-08-27 11:01:52 +08:00
parent 1f03e4d241
commit aa4c042855
17 changed files with 79 additions and 81 deletions

View file

@ -556,8 +556,7 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
m_print_enable = get_enable_print_status();
m_print_btn->Enable(m_print_enable);
if (m_print_enable) {
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
if (preset_bundle.printers.get_edited_preset().has_lidar(&preset_bundle))
if (wxGetApp().preset_bundle->is_bbl_vendor())
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_PRINT_PLATE));
else
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SEND_GCODE));
@ -950,28 +949,24 @@ void MainFrame::init_tabpanel() {
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGING, [this](wxBookCtrlEvent &e) {
int old_sel = e.GetOldSelection();
int new_sel = e.GetSelection();
if (wxGetApp().preset_bundle &&
wxGetApp().preset_bundle->printers.get_edited_preset().has_lidar(wxGetApp().preset_bundle) &&
new_sel == tpMonitor) {
if (!wxGetApp().getAgent()) {
e.Veto();
BOOST_LOG_TRIVIAL(info) << boost::format("skipped tab switch from %1% to %2%, lack of network plugins") %
old_sel % new_sel;
if (m_plater) {
wxCommandEvent *evt = new wxCommandEvent(EVT_INSTALL_PLUGIN_HINT);
wxQueueEvent(m_plater, evt);
if (wxGetApp().preset_bundle && wxGetApp().preset_bundle->is_bbl_vendor() && new_sel == tpMonitor) {
if (!wxGetApp().getAgent()) {
e.Veto();
BOOST_LOG_TRIVIAL(info) << boost::format("skipped tab switch from %1% to %2%, lack of network plugins") % old_sel % new_sel;
if (m_plater) {
wxCommandEvent *evt = new wxCommandEvent(EVT_INSTALL_PLUGIN_HINT);
wxQueueEvent(m_plater, evt);
}
}
}
} else {
if (new_sel == tpMonitor && wxGetApp().preset_bundle != nullptr) {
auto cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config;
wxString url = cfg.opt_string("print_host_webui").empty() ? cfg.opt_string("print_host")
: cfg.opt_string("print_host_webui");
if (url.empty()) {
wxString url = wxString::Format("file://%s/web/orca/missing_connection.html", from_u8(resources_dir()));
m_printer_view->load_url(url);
if (new_sel == tpMonitor && wxGetApp().preset_bundle != nullptr) {
auto cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config;
wxString url = cfg.opt_string("print_host_webui").empty() ? cfg.opt_string("print_host") : cfg.opt_string("print_host_webui");
if (url.empty()) {
wxString url = wxString::Format("file://%s/web/orca/missing_connection.html", from_u8(resources_dir()));
m_printer_view->load_url(url);
}
}
}
}
});
@ -1575,7 +1570,7 @@ wxBoxSizer* MainFrame::create_side_tools()
SidePopup* p = new SidePopup(this);
if (wxGetApp().preset_bundle
&& !wxGetApp().preset_bundle->printers.get_edited_preset().has_lidar(wxGetApp().preset_bundle)) {
&& !wxGetApp().preset_bundle->is_bbl_vendor()) {
// ThirdParty Buttons
SideButton* export_gcode_btn = new SideButton(p, _L("Export G-code file"), "");
export_gcode_btn->SetCornerRadius(0);
@ -3497,7 +3492,7 @@ void MainFrame::load_printer_url(wxString url)
void MainFrame::load_printer_url()
{
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
if (preset_bundle.printers.get_edited_preset().has_lidar(&preset_bundle))
if (preset_bundle.is_bbl_vendor())
return;
auto cfg = preset_bundle.printers.get_edited_preset().config;