update slic3r

This commit is contained in:
QIDI TECH
2024-11-28 15:19:12 +08:00
parent a26696f35e
commit 7eb6543991
196 changed files with 18701 additions and 3803 deletions

View File

@@ -33,11 +33,13 @@ wxDEFINE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent);
wxDEFINE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent);
wxDEFINE_EVENT(EVT_CLOSE_IPADDRESS_DLG, wxCommandEvent);
wxDEFINE_EVENT(EVT_CHECK_IP_ADDRESS_FAILED, wxCommandEvent);
wxDEFINE_EVENT(EVT_CHECK_IP_ADDRESS_LAYOUT, wxCommandEvent);
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_RETRY, wxCommandEvent);
wxDEFINE_EVENT(EVT_PRINT_ERROR_STOP, wxCommandEvent);
wxDEFINE_EVENT(EVT_UPDATE_NOZZLE, wxCommandEvent);
wxDEFINE_EVENT(EVT_JUMP_TO_HMS, wxCommandEvent);
wxDEFINE_EVENT(EVT_JUMP_TO_LIVEVIEW, wxCommandEvent);
wxDEFINE_EVENT(EVT_UPDATE_TEXT_MSG, wxCommandEvent);
ReleaseNoteDialog::ReleaseNoteDialog(Plater *plater /*= nullptr*/)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Release Note"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
@@ -880,7 +882,7 @@ PrintErrorDialog::PrintErrorDialog(wxWindow* parent, wxWindowID id, const wxStri
bottom_sizer->Add(m_sizer_button, 0, wxEXPAND | wxRIGHT | wxLEFT, 0);
m_sizer_right->Add(bottom_sizer, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(15));
m_sizer_right->Add(bottom_sizer, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(20));
m_sizer_right->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_sizer_right, 0, wxBOTTOM | wxEXPAND, FromDIP(5));
@@ -936,20 +938,34 @@ void PrintErrorDialog::on_webrequest_state(wxWebRequestEvent& evt)
}
}
void PrintErrorDialog::update_text_image(wxString text, wxString image_url)
void PrintErrorDialog::update_text_image(const wxString& text, const wxString& error_code, const wxString& image_url)
{
//if (!m_sizer_text_release_note) {
// m_sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
//}
wxBoxSizer* sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
wxString error_code_msg = error_code;
if (!error_code.IsEmpty()) {
wxDateTime now = wxDateTime::Now();
wxString show_time = now.Format("%H%M%d");
error_code_msg = wxString::Format("[%S %S]", error_code, show_time);
}
if (!m_staticText_release_note) {
m_staticText_release_note = new Label(m_vebview_release_note, text, LB_AUTO_WRAP);
sizer_text_release_note->Add(m_error_prompt_pic_static, 0, wxALIGN_CENTER, FromDIP(5));
sizer_text_release_note->AddSpacer(10);
sizer_text_release_note->Add(m_staticText_release_note, 0, wxALIGN_CENTER , FromDIP(5));
m_vebview_release_note->SetSizer(sizer_text_release_note);
}
if (!m_staticText_error_code) {
m_staticText_error_code = new Label(m_vebview_release_note, error_code_msg, LB_AUTO_WRAP);
sizer_text_release_note->AddSpacer(5);
sizer_text_release_note->Add(m_staticText_error_code, 0, wxALIGN_CENTER, FromDIP(5));
}
m_vebview_release_note->SetSizer(sizer_text_release_note);
if (!image_url.empty()) {
web_request = wxWebSession::GetDefault().CreateRequest(this, image_url);
BOOST_LOG_TRIVIAL(trace) << "monitor: create new webrequest, state = " << web_request.GetState() << ", url = " << image_url;
@@ -966,6 +982,9 @@ void PrintErrorDialog::update_text_image(wxString text, wxString image_url)
m_staticText_release_note->SetMaxSize(wxSize(FromDIP(300), -1));
m_staticText_release_note->SetMinSize(wxSize(FromDIP(300), -1));
m_staticText_release_note->SetLabelText(text);
m_staticText_error_code->SetMaxSize(wxSize(FromDIP(300), -1));
m_staticText_error_code->SetMinSize(wxSize(FromDIP(300), -1));
m_staticText_error_code->SetLabelText(error_code_msg);
m_vebview_release_note->Layout();
auto text_size = m_staticText_release_note->GetBestSize();
@@ -974,7 +993,7 @@ void PrintErrorDialog::update_text_image(wxString text, wxString image_url)
m_vebview_release_note->SetMinSize(wxSize(FromDIP(320), text_size.y + FromDIP(220)));
}
else {
m_vebview_release_note->SetMinSize(wxSize(FromDIP(320), text_size.y + FromDIP(25)));
m_vebview_release_note->SetMinSize(wxSize(FromDIP(320), text_size.y + FromDIP(50)));
}
else {
m_vebview_release_note->SetMinSize(wxSize(FromDIP(320), FromDIP(340)));
@@ -1032,7 +1051,8 @@ void PrintErrorDialog::update_title_style(wxString title, std::vector<int> butto
}
void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text) {
void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text)
{
Button* print_error_button = new Button(this, buton_text);
print_error_button->SetBackgroundColor(btn_bg_white);
print_error_button->SetBorderColor(wxColour(38, 46, 48));
@@ -1046,8 +1066,8 @@ void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text) {
}
void PrintErrorDialog::init_button_list() {
void PrintErrorDialog::init_button_list()
{
init_button(RESUME_PRINTING, _L("Resume Printing"));
m_button_list[RESUME_PRINTING]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
post_event(wxCommandEvent(EVT_SECONDARY_CHECK_RESUME));
@@ -1421,24 +1441,30 @@ void ConfirmBeforeSendDialog::rescale()
m_button_cancel->Rescale();
}
InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
:DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, _L("LAN Connection Failed (Sending print file)"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe),
wxID_ANY,
_L("Connect the printer using IP and access code"),
wxDefaultPosition,
wxDefaultSize,
wxCAPTION | wxCLOSE_BOX)
{
std::string icon_path = (boost::format("%1%/images/QIDIStudioTitle.ico") % resources_dir()).str();
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
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_msg = new wxBoxSizer(wxHORIZONTAL);
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
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_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 QIDI 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_before_enter_text = _L("Step 1. Please confirm QIDI 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.");
m_tip1 = new Label(this, ::Label::Body_13, comfirm_before_enter_text, LB_AUTO_WRAP);
@@ -1446,30 +1472,42 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_tip1->SetMaxSize(wxSize(FromDIP(352), -1));
m_tip1->Wrap(FromDIP(352));
auto m_line_tips = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_line_tips->SetBackgroundColour(wxColour(0xEEEEEE));
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));
auto m_input_tip_area = new wxBoxSizer(wxHORIZONTAL);
auto m_input_area = new wxBoxSizer(wxHORIZONTAL);
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_tips_ip = new Label(this, "IP");
ip_input_top_panel = new wxPanel(this);
ip_input_bot_panel = new wxPanel(this);
ip_input_top_panel->SetBackgroundColour(*wxWHITE);
ip_input_bot_panel->SetBackgroundColour(*wxWHITE);
auto m_input_top_sizer = new wxBoxSizer(wxVERTICAL);
auto m_input_bot_sizer = new wxBoxSizer(wxVERTICAL);
/*top input*/
auto m_input_tip_area = new wxBoxSizer(wxHORIZONTAL);
auto m_input_area = new wxBoxSizer(wxHORIZONTAL);
m_tips_ip = new Label(ip_input_top_panel, "IP");
m_tips_ip->SetMinSize(wxSize(FromDIP(168), -1));
m_tips_ip->SetMaxSize(wxSize(FromDIP(168), -1));
m_input_ip = new TextInput(this, wxEmptyString, wxEmptyString);
m_input_ip = new TextInput(ip_input_top_panel, wxEmptyString, wxEmptyString);
m_input_ip->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_ip->SetMinSize(wxSize(FromDIP(168), FromDIP(28)));
m_input_ip->SetMaxSize(wxSize(FromDIP(168), FromDIP(28)));
m_tips_access_code = new Label(this, _L("Access Code"));
m_tips_access_code->SetMinSize(wxSize(FromDIP(168),-1));
m_tips_access_code->SetMaxSize(wxSize(FromDIP(168),-1));
m_tips_access_code = new Label(ip_input_top_panel, _L("Access Code"));
m_tips_access_code->SetMinSize(wxSize(FromDIP(168), -1));
m_tips_access_code->SetMaxSize(wxSize(FromDIP(168), -1));
m_input_access_code = new TextInput(this, wxEmptyString, wxEmptyString);
m_input_access_code = new TextInput(ip_input_top_panel, wxEmptyString, wxEmptyString);
m_input_access_code->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_access_code->SetMinSize(wxSize(FromDIP(168), FromDIP(28)));
m_input_access_code->SetMaxSize(wxSize(FromDIP(168), FromDIP(28)));
@@ -1477,11 +1515,65 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
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(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(m_input_access_code, 0, wxALIGN_CENTER, 0);
m_input_top_sizer->Add(m_input_tip_area, 0, wxRIGHT | wxEXPAND, FromDIP(18));
m_input_top_sizer->Add(0, 0, 0, wxTOP, FromDIP(4));
m_input_top_sizer->Add(m_input_area, 0, wxRIGHT | wxEXPAND, FromDIP(18));
ip_input_top_panel->SetSizer(m_input_top_sizer);
ip_input_top_panel->Layout();
ip_input_top_panel->Fit();
/*bom input*/
auto m_input_sn_area = new wxBoxSizer(wxHORIZONTAL);
auto m_input_modelID_area = new wxBoxSizer(wxHORIZONTAL);
m_tips_sn = new Label(ip_input_bot_panel, "SN");
m_tips_sn->SetMinSize(wxSize(FromDIP(168), -1));
m_tips_sn->SetMaxSize(wxSize(FromDIP(168), -1));
m_input_sn = new TextInput(ip_input_bot_panel, wxEmptyString, wxEmptyString);
m_input_sn->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_sn->SetMinSize(wxSize(FromDIP(168), FromDIP(28)));
m_input_sn->SetMaxSize(wxSize(FromDIP(168), FromDIP(28)));
m_tips_modelID = new Label(ip_input_bot_panel, _L("Printer model"));
m_tips_modelID->SetMinSize(wxSize(FromDIP(168), -1));
m_tips_modelID->SetMaxSize(wxSize(FromDIP(168), -1));
m_input_modelID = new ComboBox(ip_input_bot_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(168), FromDIP(28)), 0, nullptr, wxCB_READONLY);
// m_input_modelID->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_modelID->SetMinSize(wxSize(FromDIP(168), FromDIP(28)));
m_input_modelID->SetMaxSize(wxSize(FromDIP(168), FromDIP(28)));
m_models_map = DeviceManager::get_all_model_id_with_name();
for (auto it = m_models_map.begin(); it != m_models_map.end(); ++it) {
m_input_modelID->Append(it->right);
m_input_modelID->SetSelection(0);
}
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(0, 0, 0, wxTOP, FromDIP(4));
m_input_bot_sizer->Add(m_input_modelID_area, 0, wxRIGHT | wxEXPAND, FromDIP(18));
ip_input_bot_panel->SetSizer(m_input_bot_sizer);
ip_input_bot_panel->Layout();
ip_input_bot_panel->Fit();
/*other*/
m_test_right_msg = new Label(this, Label::Body_13, wxEmptyString, LB_AUTO_WRAP);
m_test_right_msg->SetForegroundColour(wxColour(129, 150, 255));
m_test_right_msg->Hide();
@@ -1491,11 +1583,7 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_test_wrong_msg->SetForegroundColour(wxColour(208, 27, 27));
m_test_wrong_msg->Hide();
m_tip3 = new Label(this, Label::Body_12, _L("Where to find your printer's IP and Access Code?"), LB_AUTO_WRAP);
m_tip3->SetMinSize(wxSize(FromDIP(352), -1));
m_tip3->SetMaxSize(wxSize(FromDIP(352), -1));
m_tip4 = new Label(this, ::Label::Body_13, _L("Step 3: Ping the IP address to check for packet loss and latency."), LB_AUTO_WRAP);
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));
@@ -1520,11 +1608,12 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetCornerRadius(FromDIP(12));
m_button_ok->Bind(wxEVT_LEFT_DOWN, &InputIpAddressDialog::on_ok, this);
m_button_ok->Enable(false);
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"));
/*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);
@@ -1534,39 +1623,34 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
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));
m_sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
// m_sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
m_sizer_button->Layout();
m_status_bar = std::make_shared<QDTStatusBarSend>(this);
m_status_bar = std::make_shared<QDTStatusBarSend>(this);
m_status_bar->get_panel()->Hide();
auto m_step_icon_panel1 = new wxWindow(this, wxID_ANY);
auto m_step_icon_panel2 = new wxWindow(this, wxID_ANY);
m_step_icon_panel3 = new wxWindow(this, wxID_ANY);
m_step_icon_panel1->SetBackgroundColour(*wxWHITE);
m_step_icon_panel2->SetBackgroundColour(*wxWHITE);
m_step_icon_panel3->SetBackgroundColour(*wxWHITE);
auto m_sizer_step_icon_panel1 = new wxBoxSizer(wxVERTICAL);
auto m_sizer_step_icon_panel2 = new wxBoxSizer(wxVERTICAL);
auto m_sizer_step_icon_panel3 = new wxBoxSizer(wxVERTICAL);
m_img_step1 = new wxStaticBitmap(m_step_icon_panel1, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0);
auto m_line_tips_left = new wxPanel(m_step_icon_panel1, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_line_tips_left->SetBackgroundColour(wxColour(0xEEEEEE));
m_img_step2 = new wxStaticBitmap(m_step_icon_panel2, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0);
m_img_step3 = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0);
m_sizer_step_icon_panel1->Add(m_img_step1, 0, wxALIGN_CENTER|wxALL, FromDIP(5));
m_img_step3 = new wxStaticBitmap(m_step_icon_panel3, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0);
m_step_icon_panel1->SetSizer(m_sizer_step_icon_panel1);
m_step_icon_panel1->Layout();
@@ -1576,52 +1660,52 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_step_icon_panel2->Layout();
m_step_icon_panel2->Fit();
m_step_icon_panel3->SetSizer(m_sizer_step_icon_panel3);
m_step_icon_panel3->Layout();
m_step_icon_panel3->Fit();
m_sizer_step_icon_panel2->Add(m_img_step2, 0, wxALIGN_CENTER|wxALL, FromDIP(5));
//m_sizer_step_icon_panel3->Add(m_img_step3, 0, wxALIGN_CENTER|wxALL, FromDIP(5));
m_sizer_step_icon_panel1->Add(m_img_step1, 0, wxALIGN_CENTER | wxALL, FromDIP(5));
m_sizer_step_icon_panel2->Add(m_img_step2, 0, wxALIGN_CENTER | wxALL, FromDIP(5));
m_sizer_step_icon_panel3->Add(m_img_step3, 0, wxALIGN_CENTER | wxALL, FromDIP(5));
m_step_icon_panel1->SetMinSize(wxSize(-1, m_tip1->GetBestSize().y));
m_step_icon_panel1->SetMaxSize(wxSize(-1, m_tip1->GetBestSize().y));
m_sizer_msg->Add(0, 0, 0, wxALIGN_CENTER, FromDIP(20));
m_sizer_msg->Add(m_img_step3, 0, wxALL, FromDIP(5));
m_sizer_msg->Add(0, 0, 0, wxALIGN_CENTER, FromDIP(8));
m_sizer_msg->Add(m_tip4, 0, wxALIGN_CENTER | wxEXPAND | wxLEFT, FromDIP(5));
m_img_step3->Hide();
m_tip4->Hide();
m_step_icon_panel2->SetMinSize(wxSize(-1, m_tip2->GetBestSize().y));
m_step_icon_panel2->SetMaxSize(wxSize(-1, m_tip2->GetBestSize().y));
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_line_tips_left, 1, 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(m_tip1, 0, wxRIGHT | wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(20));
m_sizer_main_right->Add(m_line_tips, 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(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_tip3, 0, wxRIGHT | wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4));
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(m_input_tip_area, 0, wxRIGHT|wxEXPAND, FromDIP(18));
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_input_area, 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(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_right->Add(0, 0, 0, wxTOP, FromDIP(16));
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();
@@ -1630,17 +1714,19 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_sizer_main->Layout();
m_sizer_body->Add(m_line_top, 0, wxEXPAND, 0);
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(20));
m_sizer_body->Add(m_sizer_main, 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(0, 0, 0, wxTOP, FromDIP(4));
m_sizer_body->Add(m_sizer_msg, 0, wxLEFT|wxEXPAND, FromDIP(18));
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(0, 0, 0, wxTOP, FromDIP(8));
m_sizer_body->Add(m_sizer_button, 0, wxRIGHT | wxEXPAND, FromDIP(25));
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_body->Layout();
switch_input_panel(0);
SetSizer(m_sizer_body);
Layout();
Fit();
@@ -1649,29 +1735,60 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
Move(wxPoint(GetScreenPosition().x, GetScreenPosition().y - FromDIP(50)));
wxGetApp().UpdateDlgDarkUI(this);
Bind(EVT_CHECK_IP_ADDRESS_FAILED, &InputIpAddressDialog::on_check_ip_address_failed, this);
closeTimer = new wxTimer();
closeTimer->SetOwner(this);
Bind(wxEVT_TIMER, &InputIpAddressDialog::OnTimer, 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();
EndModal(wxID_YES);
});
Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {on_cancel();});
Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {
on_cancel();
closeTimer->Stop();
});
Bind(EVT_UPDATE_TEXT_MSG, &InputIpAddressDialog::update_test_msg_event, this);
Bind(EVT_CHECK_IP_ADDRESS_LAYOUT, [this](auto& e) {
int mode = e.GetInt();
switch_input_panel(mode);
Layout();
Fit();
});
}
void InputIpAddressDialog::switch_input_panel(int index)
{
if (index == 0) {
ip_input_top_panel->Show();
ip_input_bot_panel->Hide();
m_step_icon_panel3->Hide();
m_tip3->Hide();
} else {
ip_input_top_panel->Hide();
ip_input_bot_panel->Show();
m_step_icon_panel3->Show();
m_tip3->Show();
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
current_input_index = index;
}
void InputIpAddressDialog::on_cancel()
{
if (m_send_job) {
if (m_send_job->is_running()) {
m_send_job->cancel();
m_send_job->join();
}
}
if (m_result == 0){
this->EndModal(wxID_YES);
}else {
this->EndModal(wxID_CANCEL);
if (m_thread) {
m_thread->interrupt();
m_thread->detach();
delete m_thread;
m_thread = nullptr;
}
EndModal(wxID_CANCEL);
}
@@ -1757,87 +1874,126 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt)
{
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();
std::string str_ip = m_input_ip->GetTextCtrl()->GetValue().ToStdString();
std::string str_access_code = m_input_access_code->GetTextCtrl()->GetValue().ToStdString();
std::string str_sn = m_input_sn->GetTextCtrl()->GetValue().ToStdString();
std::string str_model_id = "";
//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;
auto it = m_models_map.right.find(m_input_modelID->GetStringSelection().ToStdString());
if (it != m_models_map.right.end()) {
str_model_id = it->get_left();
}
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();
}
Refresh();
Layout();
Fit();
m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code, str_sn, str_model_id));
}
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();
}
});
void InputIpAddressDialog::update_test_msg_event(wxCommandEvent& evt)
{
wxString text = evt.GetString();
bool beconnect = evt.GetInt();
update_test_msg(text, beconnect);
Layout();
Fit();
}
void InputIpAddressDialog::post_update_test_msg(wxString text, bool beconnect)
{
wxCommandEvent event(EVT_UPDATE_TEXT_MSG);
event.SetEventObject(this);
event.SetString(text);
event.SetInt(beconnect);
wxPostEvent(this, event);
}
m_send_job = std::make_shared<SendJob>(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();
void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id)
{
post_update_test_msg(_L("connecting..."), true);
detectResult detectData;
auto result = -1;
if (current_input_index == 0) {
#if !QDT_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;
#ifdef __APPLE__
result = -3;
#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;
result = wxGetApp().getAgent()->bind_detect(str_ip, "secure", detectData);
#endif
m_send_job->connection_type = m_obj->connection_type();
m_send_job->cloud_print_only = true;
m_send_job->has_sdcard = m_obj->has_sdcard();
m_send_job->set_check_mode();
m_send_job->set_project_name("verify_job");
} else {
result = 0;
detectData.dev_name = sn;
detectData.dev_id = sn;
detectData.connect_type = "lan";
detectData.connect_type = "free";
}
m_send_job->on_check_ip_address_fail([this](int result) {
this->check_ip_address_failed(result);
});
if (result < 0) {
post_update_test_msg(wxEmptyString, true);
if (result == -1) {
post_update_test_msg(_L("Failed to connect to printer."), false);
}
else if (result == -2) {
post_update_test_msg(_L("Failed to publish login request."), false);
}
else if (result == -3) {
wxCommandEvent event(EVT_CHECK_IP_ADDRESS_LAYOUT);
event.SetEventObject(this);
event.SetInt(1);
wxPostEvent(this, event);
}
return;
}
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);
});
if (detectData.bind_state == "occupied") {
post_update_test_msg(wxEmptyString, true);
post_update_test_msg(_L("The printer has already been bound."), false);
return;
}
m_send_job->start();
if (detectData.connect_type == "cloud") {
post_update_test_msg(wxEmptyString, true);
post_update_test_msg(_L("The printer mode is incorrect, please switch to LAN Only."), false);
return;
}
DeviceManager* dev = wxGetApp().getDeviceManager();
m_obj = dev->insert_local_device(detectData.dev_name, detectData.dev_id, str_ip, detectData.connect_type, detectData.bind_state, detectData.version, str_access_code);
if (m_obj) {
m_obj->set_user_access_code(str_access_code);
wxGetApp().getDeviceManager()->set_selected_machine(m_obj->dev_id);
}
closeCount = 1;
post_update_test_msg(wxEmptyString, true);
post_update_test_msg(wxString::Format(_L("Connecting to printer... The dialog will close later"), closeCount), true);
#ifdef __APPLE__
wxCommandEvent event(EVT_CLOSE_IPADDRESS_DLG);
wxPostEvent(this, event);
#else
closeTimer->Start(1000);
#endif
}
void InputIpAddressDialog::OnTimer(wxTimerEvent& event) {
if (closeCount > 0) {
closeCount--;
}
else {
closeTimer->Stop();
EndModal(wxID_CLOSE);
}
}
void InputIpAddressDialog::check_ip_address_failed(int result)
@@ -1855,9 +2011,6 @@ void InputIpAddressDialog::on_check_ip_address_failed(wxCommandEvent& evt)
}
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);
m_img_step3->Show();
m_tip4->Show();
//m_trouble_shoot->Show();
Layout();
Fit();
}
@@ -1869,12 +2022,21 @@ void InputIpAddressDialog::on_check_ip_address_failed(wxCommandEvent& evt)
m_button_ok->SetBackgroundColor(btn_bg_green);
}
void InputIpAddressDialog::on_text(wxCommandEvent& evt)
void InputIpAddressDialog::on_text(wxCommandEvent &evt)
{
auto str_ip = m_input_ip->GetTextCtrl()->GetValue();
auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
auto str_ip = m_input_ip->GetTextCtrl()->GetValue();
auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
auto str_sn = m_input_sn->GetTextCtrl()->GetValue();
bool invalid_access_code = true;
if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8) {
for (char c : str_access_code) {
if (!('0' <= c && c <= '9' || 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z')) {
invalid_access_code = false;
return;
}
}
if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8 && invalid_access_code) {
m_button_ok->Enable(true);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(129, 150, 255), StateColor::Pressed), std::pair<wxColour, int>(wxColour(129, 150, 255), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
@@ -1886,6 +2048,20 @@ void InputIpAddressDialog::on_text(wxCommandEvent& evt)
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
if (current_input_index == 1){
if (str_sn.length() == 15) {
m_button_ok->Enable(true);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_ok->SetBackgroundColor(btn_bg_green);
} else {
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
}
}
InputIpAddressDialog::~InputIpAddressDialog()