diff --git a/src/slic3r/GUI/BBLStatusBarSend.cpp b/src/slic3r/GUI/BBLStatusBarSend.cpp index 637c240ac..fcf008296 100644 --- a/src/slic3r/GUI/BBLStatusBarSend.cpp +++ b/src/slic3r/GUI/BBLStatusBarSend.cpp @@ -59,9 +59,7 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id) m_cancelbutton->SetCornerRadius(m_self->FromDIP(12)); m_cancelbutton->Bind(wxEVT_BUTTON, [this](wxCommandEvent &evt) { - m_was_cancelled = true; - if (m_cancel_cb_fina) - m_cancel_cb_fina(); + cancel(); }); m_stext_percent = new wxStaticText(m_self, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0); @@ -387,4 +385,10 @@ void BBLStatusBarSend::enable_cancel_button() m_cancelbutton->Enable(); } +void BBLStatusBarSend::cancel() +{ + m_was_cancelled = true; + if (m_cancel_cb_fina) m_cancel_cb_fina(); +} + } diff --git a/src/slic3r/GUI/BBLStatusBarSend.hpp b/src/slic3r/GUI/BBLStatusBarSend.hpp index dfab9257d..df4e5998f 100644 --- a/src/slic3r/GUI/BBLStatusBarSend.hpp +++ b/src/slic3r/GUI/BBLStatusBarSend.hpp @@ -86,6 +86,9 @@ public: void disable_cancel_button(); void enable_cancel_button(); + + void cancel(); + private: bool m_show_error_info_state = false; bool m_busy = false; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index d8eb50d1f..21dac7cc8 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -5995,10 +5995,11 @@ void GUI_App::show_ip_address_enter_dialog(wxString title) { auto evt = new wxCommandEvent(EVT_SHOW_IP_DIALOG); evt->SetString(title); + evt->SetInt(-1); wxQueueEvent(this, evt); } -bool GUI_App::show_modal_ip_address_enter_dialog(wxString title) +bool GUI_App::show_modal_ip_address_enter_dialog(bool input_sn, wxString title) { DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); if (!dev) return false; @@ -6006,6 +6007,7 @@ bool GUI_App::show_modal_ip_address_enter_dialog(wxString title) auto obj = dev->get_selected_machine(); InputIpAddressDialog dlg(nullptr); + dlg.m_need_input_sn = input_sn; dlg.set_machine_obj(obj); if (!title.empty()) dlg.update_title(title); @@ -6036,7 +6038,8 @@ bool GUI_App::show_modal_ip_address_enter_dialog(wxString title) void GUI_App::show_ip_address_enter_dialog_handler(wxCommandEvent& evt) { wxString title = evt.GetString(); - show_modal_ip_address_enter_dialog(title); + int mode = evt.GetInt(); + show_modal_ip_address_enter_dialog(mode == -1?false:true, title); } //void GUI_App::add_config_menu(wxMenuBar *menu) diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 5c842ddde..7c3b2edac 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -509,7 +509,7 @@ public: void update_internal_development(); void show_ip_address_enter_dialog(wxString title = wxEmptyString); void show_ip_address_enter_dialog_handler(wxCommandEvent &evt); - bool show_modal_ip_address_enter_dialog(wxString title = wxEmptyString); + bool show_modal_ip_address_enter_dialog(bool input_sn, wxString title = wxEmptyString); // BBS //void add_config_menu(wxMenuBar *menu); diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index fefb2a445..f1d6f88fe 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -497,7 +497,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr wfs) m_image_grid->SetStatus(m_bmp_failed, _L("Please enter the IP of printer to connect.")); fs->SetUrl("0"); fs.reset(); - if (wxGetApp().show_modal_ip_address_enter_dialog(_L("LAN Connection Failed (Failed to view sdcard)"))) { + if (wxGetApp().show_modal_ip_address_enter_dialog(false, _L("LAN Connection Failed (Failed to view sdcard)"))) { if (auto fs = wfs.lock()) fs->Retry(); } diff --git a/src/slic3r/GUI/MediaPlayCtrl.cpp b/src/slic3r/GUI/MediaPlayCtrl.cpp index adb7528b9..61e3c43db 100644 --- a/src/slic3r/GUI/MediaPlayCtrl.cpp +++ b/src/slic3r/GUI/MediaPlayCtrl.cpp @@ -487,7 +487,7 @@ void MediaPlayCtrl::Stop(wxString const &msg, wxString const &msg2) tunnel == "rtsps"; if (m_failed_code < 0 && last_state != wxMEDIASTATE_PLAYING && local && (m_failed_retry > 1 || m_user_triggered)) { m_next_retry = wxDateTime(); // stop retry - if (wxGetApp().show_modal_ip_address_enter_dialog(_L("LAN Connection Failed (Failed to start liveview)"))) { + if (wxGetApp().show_modal_ip_address_enter_dialog(false, _L("LAN Connection Failed (Failed to start liveview)"))) { m_failed_retry = 0; m_user_triggered = true; if (m_last_user_play + wxTimeSpan::Minutes(5) < wxDateTime::Now()) { diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 65a999940..a14ab8167 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -1479,29 +1479,33 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) SetBackgroundColour(*wxWHITE); m_result = -1; wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL); - wxBoxSizer *m_sizer_main = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer *m_sizer_main_left = new wxBoxSizer(wxVERTICAL); - wxBoxSizer *m_sizer_main_right = new wxBoxSizer(wxVERTICAL); + wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL); wxBoxSizer *m_sizer_msg = new wxBoxSizer(wxHORIZONTAL); auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1)); m_line_top->SetBackgroundColour(wxColour(166, 169, 170)); - comfirm_before_enter_text = _L("Step 1. Please confirm Bambu Studio and your printer are in the same LAN."); - comfirm_after_enter_text = _L("Step 2. If the IP and Access Code below are different from the actual values on your printer, please correct them."); - comfirm_last_enter_text = _L("Step 3. Please obtain the device SN from the printer side; it is usually found in the device information on the printer screen."); + comfirm_before_check_text = _L("Try the following methods to update the connection parameters and reconnect to the printer."); + comfirm_before_enter_text = _L("1. Please confirm Bambu Studio and your printer are in the same LAN."); + comfirm_after_enter_text = _L("2. If the IP and Access Code below are different from the actual values on your printer, please correct them."); + comfirm_last_enter_text = _L("3. Please obtain the device SN from the printer side; it is usually found in the device information on the printer screen."); + + m_tip0 = new Label(this, ::Label::Body_13, comfirm_before_check_text, LB_AUTO_WRAP); + m_tip0->SetMinSize(wxSize(FromDIP(355), -1)); + m_tip0->SetMaxSize(wxSize(FromDIP(355), -1)); + m_tip0->Wrap(FromDIP(355)); m_tip1 = new Label(this, ::Label::Body_13, comfirm_before_enter_text, LB_AUTO_WRAP); - m_tip1->SetMinSize(wxSize(FromDIP(352), -1)); - m_tip1->SetMaxSize(wxSize(FromDIP(352), -1)); - m_tip1->Wrap(FromDIP(352)); + m_tip1->SetMinSize(wxSize(FromDIP(355), -1)); + m_tip1->SetMaxSize(wxSize(FromDIP(355), -1)); + m_tip1->Wrap(FromDIP(355)); m_tip2 = new Label(this, ::Label::Body_13, comfirm_after_enter_text, LB_AUTO_WRAP); - m_tip2->SetMinSize(wxSize(FromDIP(352), -1)); - m_tip2->SetMaxSize(wxSize(FromDIP(352), -1)); + m_tip2->SetMinSize(wxSize(FromDIP(355), -1)); + m_tip2->SetMaxSize(wxSize(FromDIP(355), -1)); m_tip3 = new Label(this, ::Label::Body_13, comfirm_last_enter_text, LB_AUTO_WRAP); - m_tip3->SetMinSize(wxSize(FromDIP(352), -1)); - m_tip3->SetMaxSize(wxSize(FromDIP(352), -1)); + m_tip3->SetMinSize(wxSize(FromDIP(355), -1)); + m_tip3->SetMaxSize(wxSize(FromDIP(355), -1)); ip_input_top_panel = new wxPanel(this); ip_input_bot_panel = new wxPanel(this); @@ -1535,11 +1539,11 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) m_input_access_code->SetMaxSize(wxSize(FromDIP(168), FromDIP(28))); m_input_tip_area->Add(m_tips_ip, 0, wxALIGN_CENTER, 0); - m_input_tip_area->Add(0, 0, 0, wxLEFT, FromDIP(16)); + m_input_tip_area->Add(0, 0, 0, wxLEFT, FromDIP(20)); m_input_tip_area->Add(m_tips_access_code, 0, wxALIGN_CENTER, 0); m_input_area->Add(m_input_ip, 0, wxALIGN_CENTER, 0); - m_input_area->Add(0, 0, 0, wxLEFT, FromDIP(16)); + m_input_area->Add(0, 0, 0, wxLEFT, FromDIP(20)); m_input_area->Add(m_input_access_code, 0, wxALIGN_CENTER, 0); m_input_top_sizer->Add(m_input_tip_area, 0, wxRIGHT | wxEXPAND, FromDIP(18)); @@ -1579,16 +1583,14 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) } m_input_sn_area->Add(m_tips_sn, 0, wxALIGN_CENTER, 0); - m_input_sn_area->Add(0, 0, 0, wxLEFT, FromDIP(16)); m_input_sn_area->Add(m_tips_modelID, 0, wxALIGN_CENTER, 0); m_input_modelID_area->Add(m_input_sn, 0, wxALIGN_CENTER, 0); - m_input_modelID_area->Add(0, 0, 0, wxLEFT, FromDIP(16)); m_input_modelID_area->Add(m_input_modelID, 0, wxALIGN_CENTER, 0); - m_input_bot_sizer->Add(m_input_sn_area, 0, wxRIGHT | wxEXPAND, FromDIP(18)); + m_input_bot_sizer->Add(m_input_sn_area, 0, wxEXPAND, 0); m_input_bot_sizer->Add(0, 0, 0, wxTOP, FromDIP(4)); - m_input_bot_sizer->Add(m_input_modelID_area, 0, wxRIGHT | wxEXPAND, FromDIP(18)); + m_input_bot_sizer->Add(m_input_modelID_area, 0, wxEXPAND, 0); ip_input_bot_panel->SetSizer(m_input_bot_sizer); ip_input_bot_panel->Layout(); @@ -1604,12 +1606,12 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) m_test_wrong_msg->Hide(); m_tip4 = new Label(this, Label::Body_12, _L("Where to find your printer's IP and Access Code?"), LB_AUTO_WRAP); - m_tip4->SetMinSize(wxSize(FromDIP(352), -1)); - m_tip4->SetMaxSize(wxSize(FromDIP(352), -1)); + m_tip4->SetMinSize(wxSize(FromDIP(355), -1)); + m_tip4->SetMaxSize(wxSize(FromDIP(355), -1)); m_trouble_shoot = new wxHyperlinkCtrl(this, wxID_ANY, "How to trouble shooting", ""); - m_img_help = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("input_access_code_x1_en", this, 198), wxDefaultPosition, wxSize(FromDIP(352), -1), 0); + m_img_help = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("input_access_code_x1_en", this, 198), wxDefaultPosition, wxSize(FromDIP(355), -1), 0); auto m_sizer_button = new wxBoxSizer(wxHORIZONTAL); @@ -1632,18 +1634,6 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90)); - /*auto m_button_cancel = new Button(this, _L("Close")); - m_button_cancel->SetBackgroundColor(btn_bg_white); - m_button_cancel->SetBorderColor(wxColour(38, 46, 48)); - m_button_cancel->SetFont(Label::Body_12); - m_button_cancel->SetSize(wxSize(FromDIP(58), FromDIP(24))); - m_button_cancel->SetMinSize(wxSize(FromDIP(58), FromDIP(24))); - m_button_cancel->SetCornerRadius(FromDIP(12)); - - m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) { - on_cancel(); - });*/ - m_sizer_button->AddStretchSpacer(); m_sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5)); // m_sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5)); @@ -1693,51 +1683,41 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) m_sizer_msg->Layout(); - m_sizer_main_left->Add(m_step_icon_panel1, 0, wxEXPAND, 0); - m_sizer_main_left->Add(0, 0, 0, wxTOP, FromDIP(20)); - m_sizer_main_left->Add(m_step_icon_panel2, 0, wxEXPAND, 0); - m_sizer_main_left->Add(0, 0, 0, wxTOP, FromDIP(20)); - m_sizer_main_left->Add(m_step_icon_panel3, 0, wxEXPAND, 0); - - m_sizer_main_left->Layout(); m_trouble_shoot->Hide(); - m_sizer_main_right->Add(m_tip1, 0, wxRIGHT | wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(20)); - m_sizer_main_right->Add(m_tip2, 0, wxRIGHT | wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(2)); - m_sizer_main_right->Add(m_tip3, 0, wxTOP|wxRIGHT|wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(12)); - m_sizer_main_right->Add(m_tip4, 0, wxRIGHT | wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(3)); - m_sizer_main_right->Add(m_img_help, 0, 0, 0); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(12)); - m_sizer_main_right->Add(ip_input_top_panel, 0, wxRIGHT|wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(ip_input_bot_panel, 0, wxRIGHT|wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); - //m_sizer_main_right->Add(m_button_ok, 0, wxRIGHT, FromDIP(18)); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); - m_sizer_main_right->Add(m_test_right_msg, 0, wxRIGHT|wxEXPAND, FromDIP(18)); - m_sizer_main_right->Add(m_test_wrong_msg, 0, wxRIGHT|wxEXPAND, FromDIP(18)); + m_sizer_main->Add(m_tip0, 0, wxEXPAND, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(6)); + m_sizer_main->Add(m_tip1, 0, wxEXPAND, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(20)); + m_sizer_main->Add(m_tip2, 0, wxEXPAND, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(2)); + m_sizer_main->Add(m_tip3, 0, wxTOP|wxEXPAND, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(12)); + m_sizer_main->Add(m_tip4, 0, wxEXPAND, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(3)); + m_sizer_main->Add(m_img_help, 0, 0, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(12)); + m_sizer_main->Add(ip_input_top_panel, 0,wxEXPAND, 0); + m_sizer_main->Add(ip_input_bot_panel, 0,wxEXPAND, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(4)); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(4)); + m_sizer_main->Add(m_test_right_msg, 0, wxEXPAND, 0); + m_sizer_main->Add(m_test_wrong_msg, 0, wxEXPAND, 0); - m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4)); - m_sizer_main_right->Add(m_status_bar->get_panel(), 0,wxRIGHT|wxEXPAND, FromDIP(18)); - m_sizer_main_right->Layout(); - - m_sizer_main->Add(m_sizer_main_left, 0, wxLEFT, FromDIP(18)); - m_sizer_main->Add(m_sizer_main_right, 0, wxLEFT|wxEXPAND, FromDIP(4)); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(4)); + m_sizer_main->Add(m_status_bar->get_panel(), 0, wxEXPAND, 0); m_sizer_main->Layout(); m_sizer_body->Add(m_line_top, 0, wxEXPAND, 0); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(10)); - m_sizer_body->Add(m_sizer_main, 0, wxRIGHT, FromDIP(10)); + m_sizer_body->Add(m_sizer_main, 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(20)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4)); - m_sizer_body->Add(m_sizer_msg, 0, wxLEFT|wxEXPAND, FromDIP(18)); + m_sizer_body->Add(m_sizer_msg, 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(20)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4)); - m_sizer_body->Add(m_trouble_shoot, 0, wxLEFT | wxRIGHT | wxEXPAND, FromDIP(40)); + m_sizer_body->Add(m_trouble_shoot, 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(20)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(8)); - m_sizer_body->Add(m_sizer_button, 0, wxRIGHT | wxEXPAND, FromDIP(25)); + m_sizer_body->Add(m_sizer_button, 0, wxLEFT|wxRIGHT|wxEXPAND, FromDIP(20)); m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(10)); m_sizer_body->Layout(); @@ -1755,7 +1735,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent) closeTimer->SetOwner(this); Bind(wxEVT_TIMER, &InputIpAddressDialog::OnTimer, this); - //Bind(EVT_CHECK_IP_ADDRESS_FAILED, &InputIpAddressDialog::on_check_ip_address_failed, this); + Bind(EVT_CHECK_IP_ADDRESS_FAILED, &InputIpAddressDialog::on_check_ip_address_failed, this); Bind(EVT_CLOSE_IPADDRESS_DLG, [this](auto& e) { m_status_bar->reset(); @@ -1853,14 +1833,14 @@ void InputIpAddressDialog::update_test_msg(wxString msg,bool connected) if(connected){ m_test_right_msg->Show(); m_test_right_msg->SetLabelText(msg); - m_test_right_msg->SetMinSize(wxSize(FromDIP(352), -1)); - m_test_right_msg->SetMaxSize(wxSize(FromDIP(352), -1)); + m_test_right_msg->SetMinSize(wxSize(FromDIP(355), -1)); + m_test_right_msg->SetMaxSize(wxSize(FromDIP(355), -1)); } else{ m_test_wrong_msg->Show(); m_test_wrong_msg->SetLabelText(msg); - m_test_wrong_msg->SetMinSize(wxSize(FromDIP(352), -1)); - m_test_wrong_msg->SetMaxSize(wxSize(FromDIP(352), -1)); + m_test_wrong_msg->SetMinSize(wxSize(FromDIP(355), -1)); + m_test_wrong_msg->SetMaxSize(wxSize(FromDIP(355), -1)); } } @@ -1886,6 +1866,11 @@ bool InputIpAddressDialog::isIp(std::string ipstr) void InputIpAddressDialog::on_ok(wxMouseEvent& evt) { + if (!m_need_input_sn) { + on_send_retry(); + return; + } + m_test_right_msg->Hide(); m_test_wrong_msg->Hide(); m_trouble_shoot->Hide(); @@ -1909,6 +1894,88 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt) m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code, str_sn, str_model_id)); } +void InputIpAddressDialog::on_send_retry() +{ + m_test_right_msg->Hide(); + m_test_wrong_msg->Hide(); + m_img_step3->Hide(); + m_tip4->Hide(); + m_trouble_shoot->Hide(); + Layout(); + Fit(); + wxString ip = m_input_ip->GetTextCtrl()->GetValue(); + wxString str_access_code = m_input_access_code->GetTextCtrl()->GetValue(); + + // check support function + if (!m_obj) return; + if (!m_obj->is_support_send_to_sdcard) { + wxString input_str = wxString::Format("%s|%s", ip, str_access_code); + auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS); + event.SetString(input_str); + event.SetEventObject(this); + wxPostEvent(this, event); + + auto event_close = wxCommandEvent(EVT_CLOSE_IPADDRESS_DLG); + event_close.SetEventObject(this); + wxPostEvent(this, event_close); + return; + } + + m_button_ok->Enable(false); + m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90)); + m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90)); + + if (m_send_job) { m_send_job->join(); } + + m_status_bar->reset(); + m_status_bar->set_prog_block(); + m_status_bar->set_cancel_callback_fina([this]() { + BOOST_LOG_TRIVIAL(info) << "print_job: enter canceled"; + if (m_send_job) { + if (m_send_job->is_running()) { + BOOST_LOG_TRIVIAL(info) << "send_job: canceled"; + m_send_job->cancel(); + } + m_send_job->join(); + } + }); + + m_send_job = std::make_shared(m_status_bar, wxGetApp().plater(), m_obj->dev_id); + m_send_job->m_dev_ip = ip.ToStdString(); + m_send_job->m_access_code = str_access_code.ToStdString(); + +#if !BBL_RELEASE_TO_PUBLIC + m_send_job->m_local_use_ssl_for_mqtt = wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false; + m_send_job->m_local_use_ssl_for_ftp = wxGetApp().app_config->get("enable_ssl_for_ftp") == "true" ? true : false; +#else + m_send_job->m_local_use_ssl_for_mqtt = m_obj->local_use_ssl_for_mqtt; + m_send_job->m_local_use_ssl_for_ftp = m_obj->local_use_ssl_for_ftp; +#endif + + m_send_job->connection_type = m_obj->connection_type(); + m_send_job->cloud_print_only = true; + m_send_job->has_sdcard = m_obj->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL; + m_send_job->set_check_mode(); + m_send_job->set_project_name("verify_job"); + + m_send_job->on_check_ip_address_fail([this](int result) { + this->check_ip_address_failed(result); + }); + + m_send_job->on_check_ip_address_success([this, ip, str_access_code]() { + wxString input_str = wxString::Format("%s|%s", ip, str_access_code); + auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS); + event.SetString(input_str); + event.SetEventObject(this); + wxPostEvent(this, event); + m_result = 0; + + update_test_msg(_L("IP and Access Code Verified! You may close the window"), true); + }); + + m_send_job->start(); +} + void InputIpAddressDialog::update_test_msg_event(wxCommandEvent& evt) { wxString text = evt.GetString(); @@ -2025,7 +2092,13 @@ void InputIpAddressDialog::on_check_ip_address_failed(wxCommandEvent& evt) update_test_msg(_L("Connection failed, please double check IP and Access Code"), false); } else { - update_test_msg(_L("Connection failed! If your IP and Access Code is correct, \nplease move to step 3 for troubleshooting network issues"), false); + if (m_need_input_sn) { + update_test_msg(_L("Connection failed! If your IP and Access Code is correct, \nplease move to step 3 for troubleshooting network issues"), false); + } + else { + update_test_msg(_L("Connection failed! Please refer to the wiki page."), false); + } + Layout(); Fit(); } @@ -2089,4 +2162,84 @@ void InputIpAddressDialog::on_dpi_changed(const wxRect& suggested_rect) } + SendFailedConfirm::SendFailedConfirm(wxWindow *parent /*= nullptr*/): + DPIDialog(static_cast(wxGetApp().mainframe), + wxID_ANY, + _L("sending failed"), + wxDefaultPosition, + wxDefaultSize, + wxCAPTION | wxCLOSE_BOX) + { + SetMinSize(wxSize(FromDIP(560), -1)); + SetMaxSize(wxSize(FromDIP(560), -1)); + + std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str(); + SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO)); + + SetBackgroundColour(*wxWHITE); + auto m_sizer_main = new wxBoxSizer(wxVERTICAL); + auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(400), 1)); + m_line_top->SetBackgroundColour(wxColour(166, 169, 170)); + + + auto tip = new Label(this, _L("Failed to send. Click Retry to attempt sending again. If retrying does not work, please check the reason.")); + tip->Wrap(FromDIP(480)); + tip->SetMinSize(wxSize(FromDIP(480), -1)); + tip->SetMaxSize(wxSize(FromDIP(480), -1)); + + wxBoxSizer *button_sizer = new wxBoxSizer(wxHORIZONTAL); + + StateColor btn_bg_green(std::pair(wxColour(27, 136, 68), StateColor::Pressed), std::pair(wxColour(61, 203, 115), StateColor::Hovered), + std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); + + StateColor btn_bg_white(std::pair(wxColour(206, 206, 206), StateColor::Pressed), std::pair(wxColour(238, 238, 238), StateColor::Hovered), + std::pair(*wxWHITE, StateColor::Normal)); + + + auto m_button_retry = new Button(this, _L("Retry")); + m_button_retry->SetBackgroundColor(btn_bg_green); + m_button_retry->SetBorderColor(*wxWHITE); + m_button_retry->SetTextColor(wxColour("#FFFFFE")); + m_button_retry->SetFont(Label::Body_12); + m_button_retry->SetSize(wxSize(-1, FromDIP(24))); + m_button_retry->SetMinSize(wxSize(FromDIP(58), FromDIP(24))); + m_button_retry->SetCornerRadius(FromDIP(12)); + + m_button_retry->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { + EndModal(wxYES); + }); + + auto m_button_input = new Button(this, _L("reconnect")); + m_button_input->SetBackgroundColor(btn_bg_white); + m_button_input->SetBorderColor(wxColour(38, 46, 48)); + m_button_input->SetFont(Label::Body_12); + m_button_input->SetSize(wxSize(-1, FromDIP(24))); + m_button_input->SetMinSize(wxSize(FromDIP(58), FromDIP(24))); + m_button_input->SetCornerRadius(FromDIP(12)); + + m_button_input->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { + EndModal(wxAPPLY); + }); + + button_sizer->Add(0, 0, 1, wxEXPAND, 5); + button_sizer->Add(m_button_retry, 0, wxALL, 5); + button_sizer->Add(m_button_input, 0, wxALL, 5); + + m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(20)); + m_sizer_main->Add(tip, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(25)); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(25)); + m_sizer_main->Add(button_sizer, 0, wxEXPAND|wxRIGHT, FromDIP(25)); + m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(20)); + + SetSizer(m_sizer_main); + Layout(); + Fit(); + + CentreOnParent(); + wxGetApp().UpdateDlgDarkUI(this); + } + +void SendFailedConfirm::on_dpi_changed(const wxRect &suggested_rect) {} + }} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index 81f51ab38..7320e6f4a 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -275,6 +275,7 @@ protected: class InputIpAddressDialog : public DPIDialog { public: + wxString comfirm_before_check_text; wxString comfirm_before_enter_text; wxString comfirm_after_enter_text; wxString comfirm_last_enter_text; @@ -283,6 +284,7 @@ public: std::string m_ip; wxWindow* m_step_icon_panel3{ nullptr }; + Label* m_tip0{ nullptr }; Label* m_tip1{ nullptr }; Label* m_tip2{ nullptr }; Label* m_tip3{ nullptr }; @@ -312,6 +314,7 @@ public: wxTimer* closeTimer{ nullptr }; int closeCount{3}; bool m_show_access_code{ false }; + bool m_need_input_sn{true}; int m_result; int current_input_index {0}; std::shared_ptr m_send_job{nullptr}; @@ -327,6 +330,7 @@ public: void check_ip_address_failed(int result); void on_check_ip_address_failed(wxCommandEvent& evt); void on_ok(wxMouseEvent& evt); + void on_send_retry(); void update_test_msg_event(wxCommandEvent &evt); void post_update_test_msg(wxString text, bool beconnect); void workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id); @@ -335,6 +339,15 @@ public: void on_dpi_changed(const wxRect& suggested_rect) override; }; +class SendFailedConfirm : public DPIDialog +{ +public: + SendFailedConfirm(wxWindow *parent = nullptr); + ~SendFailedConfirm(){}; + + //void on_ok(wxMouseEvent &evt); + void on_dpi_changed(const wxRect &suggested_rect) override; +}; wxDECLARE_EVENT(EVT_CLOSE_IPADDRESS_DLG, wxCommandEvent); wxDECLARE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent); diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index 70ed38529..1c21c971b 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -9,6 +9,7 @@ #include "MainFrame.hpp" #include "format.hpp" #include "Widgets/ProgressDialog.hpp" +#include "ReleaseNote.hpp" #include "Widgets/RoundedRectangle.hpp" #include "Widgets/StaticBox.hpp" #include "ConnectPrinter.hpp" @@ -918,10 +919,23 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event) enable_prepare_mode = false; - m_send_job->on_check_ip_address_fail([this](int result) { - wxCommandEvent *evt = new wxCommandEvent(EVT_CLEAR_IPADDRESS); - wxQueueEvent(this, evt); - wxGetApp().show_ip_address_enter_dialog(); + m_send_job->on_check_ip_address_fail([this, token = std::weak_ptr(m_token)](int result) { + CallAfter([token, this] { + if (token.expired()) { return; } + if (this) { + SendFailedConfirm sfcDlg; + auto res = sfcDlg.ShowModal(); + m_status_bar->cancel(); + + if (res == wxYES) { + wxQueueEvent(m_button_ensure, new wxCommandEvent(wxEVT_BUTTON)); + } else if (res == wxAPPLY) { + wxCommandEvent *evt = new wxCommandEvent(EVT_CLEAR_IPADDRESS); + wxQueueEvent(this, evt); + wxGetApp().show_ip_address_enter_dialog(); + } + } + }); }); if (obj_->is_lan_mode_printer()) {