mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-18 16:32:06 +00:00
Merge branch 'upstream/main' into harktech/k2-discovery
Consolidates #13744 (CFS filament sync) into this PR per maintainer request and resyncs with main. Conflicts resolved: * src/slic3r/GUI/Plater.cpp -- parallel else-if added by both sides (htCrealityPrint + flashforge_local_api branches); kept both. * src/slic3r/GUI/PhysicalPrinterDialog.cpp -- both sides added a host-specific Browse dialog (Creality DNS-SD + Flashforge); kept both as early-return branches, fall through to BonjourDialog. * src/slic3r/GUI/PrintHostDialogs.hpp -- parallel class declarations (CrealityPrintHostSendDialog + FlashforgePrintHostSendDialog); kept both.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/choicdlg.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <wx/wupdlock.h>
|
||||
|
||||
@@ -31,6 +32,7 @@
|
||||
#include "PrintHostDialogs.hpp"
|
||||
#include "../Utils/ASCIIFolding.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
#include "../Utils/Flashforge.hpp"
|
||||
#include "../Utils/UndoRedo.hpp"
|
||||
#include "RemovableDriveManager.hpp"
|
||||
#include "BitmapCache.hpp"
|
||||
@@ -205,12 +207,12 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
|
||||
{
|
||||
auto sizer = create_sizer_with_btn(parent, &m_printhost_browse_btn, "printer_host_browser", _L("Browse") + " " + dots);
|
||||
m_printhost_browse_btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent& e) {
|
||||
const auto host_type = m_config->opt_enum<PrintHostType>("host_type");
|
||||
|
||||
// Creality K-series printers announce themselves via DNS-SD under a
|
||||
// per-device-unique service type _Creality-<MAC-hex>._udp, so the
|
||||
// standard fixed-service-name Bonjour browser does not find them.
|
||||
// Dispatch to the Creality-specific scanner instead.
|
||||
const auto* host_type_opt = m_config->option<ConfigOptionEnum<PrintHostType>>("host_type");
|
||||
const auto host_type = host_type_opt ? host_type_opt->value : htOctoPrint;
|
||||
if (host_type == htCrealityPrint) {
|
||||
CrealityDiscoveryDialog dialog(this);
|
||||
if (dialog.ShowModal() == wxID_OK && !dialog.selected_ip().empty()) {
|
||||
@@ -223,11 +225,39 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
|
||||
return;
|
||||
}
|
||||
|
||||
if (host_type == htFlashforge) {
|
||||
wxBusyCursor wait;
|
||||
std::vector<FlashforgeDiscoveredPrinter> printers;
|
||||
wxString error_msg;
|
||||
if (!Flashforge::discover_printers(printers, error_msg)) {
|
||||
show_error(this, error_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
wxArrayString choices;
|
||||
for (const auto& printer : printers)
|
||||
choices.Add(from_u8((boost::format("%1% (%2%) [%3%]") % printer.name % printer.ip_address % printer.serial_number).str()));
|
||||
|
||||
wxSingleChoiceDialog dialog(this, _L("Select a Flashforge printer"), _L("Discovered Printers"), choices);
|
||||
if (dialog.ShowModal() == wxID_OK) {
|
||||
const int idx = dialog.GetSelection();
|
||||
if (idx >= 0 && idx < static_cast<int>(printers.size())) {
|
||||
m_optgroup->set_value("print_host", from_u8(printers[idx].ip_address), true);
|
||||
m_optgroup->set_value("flashforge_serial_number", from_u8(printers[idx].serial_number), true);
|
||||
m_config->opt_string("print_host") = printers[idx].ip_address;
|
||||
m_config->opt_string("flashforge_serial_number") = printers[idx].serial_number;
|
||||
update_printhost_buttons();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
BonjourDialog dialog(this, Preset::printer_technology(*m_config));
|
||||
if (dialog.show_and_lookup()) {
|
||||
m_optgroup->set_value("print_host", dialog.get_selected(), true);
|
||||
m_optgroup->get_field("print_host")->field_changed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return sizer;
|
||||
@@ -348,6 +378,10 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
|
||||
option.opt.width = Field::def_width_wider();
|
||||
m_optgroup->append_single_option_line(option);
|
||||
|
||||
option = m_optgroup->get_option("flashforge_serial_number");
|
||||
option.opt.width = Field::def_width_wider();
|
||||
m_optgroup->append_single_option_line(option);
|
||||
|
||||
option = m_optgroup->get_option("printhost_port");
|
||||
option.opt.width = Field::def_width_wider();
|
||||
Line port_line = m_optgroup->create_single_option_line(option);
|
||||
@@ -704,13 +738,17 @@ void PhysicalPrinterDialog::update(bool printer_change)
|
||||
}
|
||||
|
||||
if (opt->value == htFlashforge) {
|
||||
m_optgroup->hide_field("printhost_apikey");
|
||||
m_optgroup->hide_field("printhost_authorization_type");
|
||||
}
|
||||
m_optgroup->show_field("printhost_apikey");
|
||||
m_optgroup->show_field("flashforge_serial_number");
|
||||
m_optgroup->hide_field("printhost_authorization_type");
|
||||
} else {
|
||||
m_optgroup->hide_field("flashforge_serial_number");
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_optgroup->set_value("host_type", int(PrintHostType::htOctoPrint), false);
|
||||
m_optgroup->hide_field("host_type");
|
||||
m_optgroup->hide_field("flashforge_serial_number");
|
||||
|
||||
m_optgroup->show_field("printhost_authorization_type");
|
||||
|
||||
@@ -828,7 +866,7 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
|
||||
void PhysicalPrinterDialog::check_host_key_valid()
|
||||
{
|
||||
std::vector<std::string> keys = {"print_host", "print_host_webui", "printhost_apikey", "printhost_cafile", "printhost_user", "printhost_password", "printhost_port"};
|
||||
std::vector<std::string> keys = {"print_host", "print_host_webui", "printhost_apikey", "flashforge_serial_number", "printhost_cafile", "printhost_user", "printhost_password", "printhost_port"};
|
||||
for (auto &key : keys) {
|
||||
auto it = m_config->option<ConfigOptionString>(key);
|
||||
if (!it) m_config->set_key_value(key, new ConfigOptionString(""));
|
||||
|
||||
Reference in New Issue
Block a user