From bfd7e6b75e40f809d6e92aaa5c0dc2c70f9f1e39 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 26 Oct 2023 10:41:30 +0200 Subject: [PATCH 1/3] TetxInput: Added process of wxEVT_TEXT event. + Fixed SPE-1993 : bug in physical printer dialog (Connect) --- src/slic3r/GUI/PhysicalPrinterDialog.cpp | 22 +++++++++------------- src/slic3r/GUI/Widgets/TextInput.cpp | 5 +++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.cpp b/src/slic3r/GUI/PhysicalPrinterDialog.cpp index 5ef37e013f..1da6f85859 100644 --- a/src/slic3r/GUI/PhysicalPrinterDialog.cpp +++ b/src/slic3r/GUI/PhysicalPrinterDialog.cpp @@ -439,7 +439,7 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr Field* printhost_field = m_optgroup->get_field("print_host"); if (printhost_field) { - wxTextCtrl* temp = dynamic_cast(printhost_field->getWindow()); + text_ctrl* temp = dynamic_cast(printhost_field->getWindow()); if (temp) temp->Bind(wxEVT_TEXT, ([printhost_field, temp](wxEvent& e) { @@ -489,11 +489,11 @@ void PhysicalPrinterDialog::update(bool printer_change) m_optgroup->show_field("host_type"); // hide PrusaConnect address - if (Field* printhost_field = m_optgroup->get_field("print_host"); printhost_field) { - if (wxTextCtrl* temp = dynamic_cast(printhost_field->getWindow()); temp && temp->GetValue() == L"https://connect.prusa3d.com") { - temp->SetValue(wxString()); - } - } + Field* printhost_field = m_optgroup->get_field("print_host"); + text_ctrl* printhost_win = printhost_field ? dynamic_cast(printhost_field->getWindow()) : nullptr; + if (printhost_win && !printhost_win->GetValue().IsEmpty()) + printhost_win->SetValue(wxString()); + if (opt->value == htPrusaLink) { // PrusaConnect does NOT allow http digest m_optgroup->show_field("printhost_authorization_type"); AuthorizationType auth_type = m_config->option>("printhost_authorization_type")->value; @@ -506,15 +506,11 @@ void PhysicalPrinterDialog::update(bool printer_change) for (const std::string& opt_key : std::vector{ "printhost_user", "printhost_password" }) m_optgroup->hide_field(opt_key); supports_multiple_printers = opt && opt->value == htRepetier; - if (opt->value == htPrusaConnect) { // automatically show default prusaconnect address - if (Field* printhost_field = m_optgroup->get_field("print_host"); printhost_field) { - if (text_ctrl* temp = dynamic_cast(printhost_field->getWindow()); temp && temp->GetValue().IsEmpty()) { - temp->SetValue(L"https://connect.prusa3d.com"); - } - } + if (opt->value == htPrusaConnect && printhost_win && printhost_win->GetValue().IsEmpty()) { + // automatically show default prusaconnect address + printhost_win->SetValue(L"https://connect.prusa3d.com"); } } - } else { m_optgroup->set_value("host_type", int(PrintHostType::htOctoPrint), false); diff --git a/src/slic3r/GUI/Widgets/TextInput.cpp b/src/slic3r/GUI/Widgets/TextInput.cpp index 5fea2df008..3e515bd77c 100644 --- a/src/slic3r/GUI/Widgets/TextInput.cpp +++ b/src/slic3r/GUI/Widgets/TextInput.cpp @@ -78,6 +78,11 @@ void TextInput::Create(wxWindow * parent, e.SetId(GetId()); ProcessEventLocally(e); }); + text_ctrl->Bind(wxEVT_TEXT, [this](auto &e) { + OnEdit(); + e.SetId(GetId()); + ProcessEventLocally(e); + }); text_ctrl->Bind(wxEVT_RIGHT_DOWN, [](auto &e) {}); // disable context menu if (!icon.IsEmpty()) { From da6a384e48905c2d98ddf411520bc15285fcf824 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Thu, 26 Oct 2023 11:31:50 +0200 Subject: [PATCH 2/3] Erasing of Connect address in PhysicalPrinterDialog --- src/slic3r/GUI/PhysicalPrinterDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.cpp b/src/slic3r/GUI/PhysicalPrinterDialog.cpp index 1da6f85859..e6992cbf7a 100644 --- a/src/slic3r/GUI/PhysicalPrinterDialog.cpp +++ b/src/slic3r/GUI/PhysicalPrinterDialog.cpp @@ -491,7 +491,7 @@ void PhysicalPrinterDialog::update(bool printer_change) // hide PrusaConnect address Field* printhost_field = m_optgroup->get_field("print_host"); text_ctrl* printhost_win = printhost_field ? dynamic_cast(printhost_field->getWindow()) : nullptr; - if (printhost_win && !printhost_win->GetValue().IsEmpty()) + if (printhost_win && printhost_win->GetValue() == L"https://connect.prusa3d.com") printhost_win->SetValue(wxString()); if (opt->value == htPrusaLink) { // PrusaConnect does NOT allow http digest From c3931c80f2df5ec7eea80581bb1fbf79313fe266 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Fri, 3 Nov 2023 16:07:23 +0100 Subject: [PATCH 3/3] Physical Printer Dialog changes PrusaConnect hostname no browse button PrusaConnect address check on OK Store hostname when showing PrusaConnect URL --- src/slic3r/GUI/PhysicalPrinterDialog.cpp | 50 +++++++++++++++++++----- src/slic3r/GUI/PhysicalPrinterDialog.hpp | 5 ++- src/slic3r/GUI/Widgets/TextInput.cpp | 1 - 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.cpp b/src/slic3r/GUI/PhysicalPrinterDialog.cpp index e6992cbf7a..bfa86cd948 100644 --- a/src/slic3r/GUI/PhysicalPrinterDialog.cpp +++ b/src/slic3r/GUI/PhysicalPrinterDialog.cpp @@ -436,11 +436,15 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr m_optgroup->activate(); + const auto opt = m_config->option>("host_type"); + m_last_host_type = opt->value; + m_opened_as_connect = (m_last_host_type == htPrusaConnect); + Field* printhost_field = m_optgroup->get_field("print_host"); if (printhost_field) { text_ctrl* temp = dynamic_cast(printhost_field->getWindow()); - if (temp) + if (temp) { temp->Bind(wxEVT_TEXT, ([printhost_field, temp](wxEvent& e) { #ifndef __WXGTK__ @@ -457,6 +461,7 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr if (field) field->propagate_value(); }), temp->GetId()); + } } // Always fill in the "printhost_port" combo box from the config and select it. @@ -488,12 +493,6 @@ void PhysicalPrinterDialog::update(bool printer_change) const auto opt = m_config->option>("host_type"); m_optgroup->show_field("host_type"); - // hide PrusaConnect address - Field* printhost_field = m_optgroup->get_field("print_host"); - text_ctrl* printhost_win = printhost_field ? dynamic_cast(printhost_field->getWindow()) : nullptr; - if (printhost_win && printhost_win->GetValue() == L"https://connect.prusa3d.com") - printhost_win->SetValue(wxString()); - if (opt->value == htPrusaLink) { // PrusaConnect does NOT allow http digest m_optgroup->show_field("printhost_authorization_type"); AuthorizationType auth_type = m_config->option>("printhost_authorization_type")->value; @@ -506,11 +505,30 @@ void PhysicalPrinterDialog::update(bool printer_change) for (const std::string& opt_key : std::vector{ "printhost_user", "printhost_password" }) m_optgroup->hide_field(opt_key); supports_multiple_printers = opt && opt->value == htRepetier; - if (opt->value == htPrusaConnect && printhost_win && printhost_win->GetValue().IsEmpty()) { - // automatically show default prusaconnect address + } + // Hide Browse and Test buttons for Connect + if (opt->value == htPrusaConnect) { + m_printhost_browse_btn->Hide(); + // hide show hostname and PrusaConnect address + Field* printhost_field = m_optgroup->get_field("print_host"); + text_ctrl* printhost_win = printhost_field ? dynamic_cast(printhost_field->getWindow()) : nullptr; + if (!m_opened_as_connect && printhost_win && m_last_host_type != htPrusaConnect){ + m_stored_host = printhost_win->GetValue(); printhost_win->SetValue(L"https://connect.prusa3d.com"); } + } else { + m_printhost_browse_btn->Show(); + // hide PrusaConnect address and show hostname + Field* printhost_field = m_optgroup->get_field("print_host"); + text_ctrl* printhost_win = printhost_field ? dynamic_cast(printhost_field->getWindow()) : nullptr; + if (!m_opened_as_connect && printhost_win && m_last_host_type == htPrusaConnect) { + wxString temp_host = printhost_win->GetValue(); + printhost_win->SetValue(m_stored_host); + m_stored_host = temp_host; + } } + + m_last_host_type = opt->value; } else { m_optgroup->set_value("host_type", int(PrintHostType::htOctoPrint), false); @@ -727,6 +745,20 @@ void PhysicalPrinterDialog::OnOK(wxEvent& event) return; } + Field* printhost_field = m_optgroup->get_field("print_host"); + text_ctrl* printhost_win = printhost_field ? dynamic_cast(printhost_field->getWindow()) : nullptr; + const auto opt = m_config->option>("host_type"); + if (opt->value == htPrusaConnect) { + if (printhost_win && printhost_win->GetValue() != L"https://connect.prusa3d.com"){ + InfoDialog msg(this, _L("Warning"), _L("URL of PrusaConnect is different than https://connect.prusa3d.com. Do you wish to continue?"), true, wxYES_NO); + if(msg.ShowModal() != wxID_YES){ + printhost_win->SetValue(L"https://connect.prusa3d.com"); + return; + } + } + } + + PhysicalPrinterCollection& printers = wxGetApp().preset_bundle->physical_printers; const PhysicalPrinter* existing = printers.find_printer(into_u8(printer_name), false); if (existing && into_u8(printer_name) != printers.get_selected_printer_name()) diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.hpp b/src/slic3r/GUI/PhysicalPrinterDialog.hpp index 8668fd1719..0de8df235f 100644 --- a/src/slic3r/GUI/PhysicalPrinterDialog.hpp +++ b/src/slic3r/GUI/PhysicalPrinterDialog.hpp @@ -66,7 +66,6 @@ class PhysicalPrinterDialog : public DPIDialog PhysicalPrinter m_printer; wxString m_default_name; DynamicPrintConfig* m_config { nullptr }; - ::TextInput* m_printer_name { nullptr }; std::vector m_presets; @@ -80,6 +79,10 @@ class PhysicalPrinterDialog : public DPIDialog wxBoxSizer* m_presets_sizer {nullptr}; + wxString m_stored_host; + PrintHostType m_last_host_type; + bool m_opened_as_connect {false}; + void build_printhost_settings(ConfigOptionsGroup* optgroup); void OnOK(wxEvent& event); void AddPreset(wxEvent& event); diff --git a/src/slic3r/GUI/Widgets/TextInput.cpp b/src/slic3r/GUI/Widgets/TextInput.cpp index 3e515bd77c..b4f1b1a707 100644 --- a/src/slic3r/GUI/Widgets/TextInput.cpp +++ b/src/slic3r/GUI/Widgets/TextInput.cpp @@ -79,7 +79,6 @@ void TextInput::Create(wxWindow * parent, ProcessEventLocally(e); }); text_ctrl->Bind(wxEVT_TEXT, [this](auto &e) { - OnEdit(); e.SetId(GetId()); ProcessEventLocally(e); });