diff --git a/resources/web/qidi/link_connection.png b/resources/web/qidi/link_connection.png
new file mode 100644
index 0000000..31ea4fb
Binary files /dev/null and b/resources/web/qidi/link_connection.png differ
diff --git a/resources/web/qidi/link_missing_connection.html b/resources/web/qidi/link_missing_connection.html
new file mode 100644
index 0000000..20933be
--- /dev/null
+++ b/resources/web/qidi/link_missing_connection.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+Printer Connection Required
+
+
+
+
+
+
+
+
+
+
+
+
+ Please set up your printer connection to view the device.
+
+
+
+
+
+
+
diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp
index 3019d8b..38b44d8 100644
--- a/src/libslic3r/PresetBundle.cpp
+++ b/src/libslic3r/PresetBundle.cpp
@@ -2047,4 +2047,17 @@ void copy_bed_model_and_texture_if_needed(DynamicPrintConfig& config)
do_copy(config.option("bed_custom_model"), "model");
}
+// y3
+std::set PresetBundle::get_vendors()
+{
+ std::set qidiVendors;
+ for (auto vendor_profile : vendors) {
+ for (auto vendor_model : vendor_profile.second.models) {
+ std::string vendor_name = vendor_model.name;
+ qidiVendors.emplace(vendor_name);
+ }
+ }
+ return qidiVendors;
+}
+
} // namespace Slic3r
diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp
index 1410277..a15befc 100644
--- a/src/libslic3r/PresetBundle.hpp
+++ b/src/libslic3r/PresetBundle.hpp
@@ -190,6 +190,9 @@ public:
return { Preset::TYPE_PRINTER, Preset::TYPE_SLA_PRINT, Preset::TYPE_SLA_MATERIAL };
}
+ //y3
+ std::set get_vendors();
+
private:
std::pair load_system_presets(ForwardCompatibilitySubstitutionRule compatibility_rule);
// Merge one vendor's presets with the other vendor's presets, report duplicates.
diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp
index fa25a47..2c0cebb 100644
--- a/src/slic3r/GUI/GUI_App.hpp
+++ b/src/slic3r/GUI/GUI_App.hpp
@@ -409,6 +409,11 @@ public:
void open_wifi_config_dialog(bool forced, const wxString& drive_path = {});
bool get_wifi_config_dialog_shown() const { return m_wifi_config_dialog_shown; }
+
+ //y3
+ void setExitHost(std::set exit_host) { m_exit_host = exit_host; };
+ std::set getExitHost() { return m_exit_host; };
+
private:
bool on_init_inner();
void init_app_config();
@@ -433,6 +438,8 @@ private:
bool m_datadir_redefined { false };
bool m_wifi_config_dialog_shown { false };
+ //y3
+ std::set m_exit_host;
};
DECLARE_APP(GUI_App)
diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp
index ff848ae..ba1e636 100644
--- a/src/slic3r/GUI/MainFrame.cpp
+++ b/src/slic3r/GUI/MainFrame.cpp
@@ -2102,37 +2102,38 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
//B64
m_printer_view->SetPauseThread(false);
-
- if (const DynamicPrintConfig *cfg = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config(); cfg) {
- const PhysicalPrinter &pp = preset_bundle.physical_printers.get_selected_printer();
- wxString host = pp.config.opt_string("print_host");
- //B55
- //B45
- if (host.empty()) {
- tem_host = "";
- host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
- } else {
- //B55
- const auto opt = cfg->option>("host_type");
- const auto host_type = opt != nullptr ? opt->value : htOctoPrint;
- if (!host.Lower().starts_with("http"))
- host = wxString::Format("http://%s", host);
- if (host_type == htMoonraker) {
- if (!host.Lower().ends_with("10088"))
- host = wxString::Format("%s:10088", host);
- }
- }
- //B55
- if (tem_host != host) {
- //B45
- m_printer_view->load_url(host);
- tem_host = host;
- }
- } else {
- tem_host = "";
- wxString url = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
- m_printer_view->load_url(url);
- }
+ //y3
+ //if (const DynamicPrintConfig *cfg = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config(); cfg) {
+ // const PhysicalPrinter &pp = preset_bundle.physical_printers.get_selected_printer();
+ // wxString host = pp.config.opt_string("print_host");
+ // //B55
+ // //B45
+ // if (host.empty()) {
+ // tem_host = "";
+ // host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
+ // } else {
+ // //B55
+ // const auto opt = cfg->option>("host_type");
+ // const auto host_type = opt != nullptr ? opt->value : htOctoPrint;
+ // if (!host.Lower().starts_with("http"))
+ // host = wxString::Format("http://%s", host);
+ // if (host_type == htMoonraker) {
+ // if (!host.Lower().ends_with("10088"))
+ // host = wxString::Format("%s:10088", host);
+ // }
+ // }
+ // //B55
+ // if (tem_host != host) {
+ // //B45
+ // m_printer_view->load_url(host);
+ // tem_host = host;
+ // }
+ //} else {
+ // tem_host = "";
+ // wxString url = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
+ // m_printer_view->load_url(url);
+ //}
+ m_printer_view->Layout();
}
// B30
if (m_tabpanel->GetSelection() != (int) new_selection && m_tabpanel->GetSelection() < 4)
diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.cpp b/src/slic3r/GUI/PhysicalPrinterDialog.cpp
index 9dc239f..ce78c71 100644
--- a/src/slic3r/GUI/PhysicalPrinterDialog.cpp
+++ b/src/slic3r/GUI/PhysicalPrinterDialog.cpp
@@ -46,11 +46,11 @@ PresetForPrinter::PresetForPrinter(PhysicalPrinterDialog* parent, const std::str
m_parent(parent)
{
m_sizer = new wxBoxSizer(wxVERTICAL);
-
- m_delete_preset_btn = new ScalableButton(parent, wxID_ANY, "cross");
- m_delete_preset_btn->SetFont(wxGetApp().normal_font());
- m_delete_preset_btn->SetToolTip(_L("Delete this preset from this printer device"));
- m_delete_preset_btn->Bind(wxEVT_BUTTON, &PresetForPrinter::DeletePreset, this);
+ //y4
+ //m_delete_preset_btn = new ScalableButton(parent, wxID_ANY, "cross");
+ //m_delete_preset_btn->SetFont(wxGetApp().normal_font());
+ //m_delete_preset_btn->SetToolTip(_L("Delete this preset from this printer device"));
+ //m_delete_preset_btn->Bind(wxEVT_BUTTON, &PresetForPrinter::DeletePreset, this);
m_presets_list = new PresetComboBox(parent, Preset::TYPE_PRINTER);
m_presets_list->set_printer_technology(parent->get_printer_technology());
@@ -88,7 +88,7 @@ PresetForPrinter::PresetForPrinter(PhysicalPrinterDialog* parent, const std::str
wxBoxSizer* preset_sizer = new wxBoxSizer(wxHORIZONTAL);
preset_sizer->Add(m_presets_list , 1, wxEXPAND);
- preset_sizer->Add(m_delete_preset_btn , 0, wxEXPAND | wxLEFT, BORDER_W);
+ // preset_sizer->Add(m_delete_preset_btn , 0, wxEXPAND | wxLEFT, BORDER_W);
wxBoxSizer* name_sizer = new wxBoxSizer(wxHORIZONTAL);
name_sizer->Add(m_info_line, 0, wxEXPAND);
@@ -101,7 +101,7 @@ PresetForPrinter::PresetForPrinter(PhysicalPrinterDialog* parent, const std::str
PresetForPrinter::~PresetForPrinter()
{
m_presets_list->Destroy();
- m_delete_preset_btn->Destroy();
+ // m_delete_preset_btn->Destroy();
m_info_line->Destroy();
m_full_printer_name->Destroy();
}
@@ -126,7 +126,7 @@ std::string PresetForPrinter::get_preset_name()
void PresetForPrinter::SuppressDelete()
{
- m_delete_preset_btn->Enable(false);
+ //m_delete_preset_btn->Enable(false);
// this case means that now we have only one related preset for the printer
// So, allow any selection
@@ -136,8 +136,8 @@ void PresetForPrinter::SuppressDelete()
void PresetForPrinter::AllowDelete()
{
- if (!m_delete_preset_btn->IsEnabled())
- m_delete_preset_btn->Enable();
+ //if (!m_delete_preset_btn->IsEnabled())
+ // m_delete_preset_btn->Enable();
m_presets_list->set_printer_technology(m_parent->get_printer_technology());
m_presets_list->update();
@@ -146,7 +146,7 @@ void PresetForPrinter::AllowDelete()
void PresetForPrinter::on_sys_color_changed()
{
m_presets_list->sys_color_changed();
- m_delete_preset_btn->sys_color_changed();
+ // m_delete_preset_btn->sys_color_changed();
}
@@ -154,7 +154,8 @@ void PresetForPrinter::on_sys_color_changed()
// PhysicalPrinterDialog
//------------------------------------------
-PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent, wxString printer_name) :
+//y3
+PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow *parent, wxString printer_name, std::set exit_host) :
DPIDialog(parent, wxID_ANY, _L("Physical Printer"), wxDefaultPosition, wxSize(45 * wxGetApp().em_unit(), -1), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
m_printer("", wxGetApp().preset_bundle->physical_printers.default_config())
{
@@ -170,15 +171,18 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent, wxString printer_
else {
std::string full_name = into_u8(printer_name);
printer_name = from_u8(PhysicalPrinter::get_short_name(full_name));
+ old_name = into_u8(printer_name);
new_printer = false;
}
+ m_exit_host = exit_host;
+
wxStaticText* label_top = new wxStaticText(this, wxID_ANY, _L("Descriptive name for the printer") + ":");
- m_add_preset_btn = new ScalableButton(this, wxID_ANY, "add_copies");
+ /* m_add_preset_btn = new ScalableButton(this, wxID_ANY, "add_copies");
m_add_preset_btn->SetFont(wxGetApp().normal_font());
m_add_preset_btn->SetToolTip(_L("Add preset for this printer device"));
- m_add_preset_btn->Bind(wxEVT_BUTTON, &PhysicalPrinterDialog::AddPreset, this);
+ m_add_preset_btn->Bind(wxEVT_BUTTON, &PhysicalPrinterDialog::AddPreset, this);*/
m_printer_name = new ::TextInput(this,printer_name);
wxGetApp().UpdateDarkUI(m_printer_name);
@@ -219,7 +223,7 @@ PhysicalPrinterDialog::PhysicalPrinterDialog(wxWindow* parent, wxString printer_
wxBoxSizer* nameSizer = new wxBoxSizer(wxHORIZONTAL);
nameSizer->Add(m_printer_name, 1, wxEXPAND);
- nameSizer->Add(m_add_preset_btn, 0, wxEXPAND | wxLEFT, BORDER_W);
+ // nameSizer->Add(m_add_preset_btn, 0, wxEXPAND | wxLEFT, BORDER_W);
m_presets_sizer = new wxBoxSizer(wxVERTICAL);
for (PresetForPrinter* preset : m_presets)
@@ -722,7 +726,7 @@ void PhysicalPrinterDialog::on_dpi_changed(const wxRect& suggested_rect)
void PhysicalPrinterDialog::on_sys_color_changed()
{
- m_add_preset_btn->sys_color_changed();
+ //m_add_preset_btn->sys_color_changed();
m_printhost_browse_btn->sys_color_changed();
m_printhost_test_btn->sys_color_changed();
if (m_printhost_cafile_browse_btn)
@@ -734,6 +738,21 @@ void PhysicalPrinterDialog::on_sys_color_changed()
void PhysicalPrinterDialog::OnOK(wxEvent& event)
{
+
+ //y3
+ std::string now_host = boost::any_cast(m_optgroup->get_field("print_host")->get_value());
+ if (now_host.empty()) {
+ MessageDialog msg_wingow(nullptr, _L("The host or IP or URL cannot be empty."), "", wxICON_WARNING | wxOK);
+ msg_wingow.ShowModal();
+ return;
+ }
+ if (m_exit_host.find(now_host) != m_exit_host.end()) {
+ MessageDialog msg_wingow(nullptr, _L("A device with the same host (IP or URL) already exists, please re-enter."), "",
+ wxICON_WARNING | wxOK);
+ msg_wingow.ShowModal();
+ return;
+ }
+
wxString printer_name = m_printer_name->GetValue();
if (printer_name.IsEmpty() || printer_name == m_default_name) {
warning_catcher(this, _L("You have to enter a printer name."));
@@ -759,17 +778,21 @@ void PhysicalPrinterDialog::OnOK(wxEvent& event)
}
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())
+ if (existing && into_u8(printer_name) != printers.get_selected_printer_name() && into_u8(printer_name) != old_name)
{
+
+ //y3
wxString msg_text = from_u8((boost::format(_u8L("Printer with name \"%1%\" already exists.")) % existing->name/*printer_name*/).str());
- msg_text += "\n" + _L("Replace?");
- //wxMessageDialog dialog(nullptr, msg_text, _L("Warning"), wxICON_WARNING | wxYES | wxNO);
- MessageDialog dialog(nullptr, msg_text, _L("Warning"), wxICON_WARNING | wxYES | wxNO);
+ //msg_text += "\n" + _L("Replace?");
+ ////wxMessageDialog dialog(nullptr, msg_text, _L("Warning"), wxICON_WARNING | wxYES | wxNO);
+ //MessageDialog dialog(nullptr, msg_text, _L("Warning"), wxICON_WARNING | wxYES | wxNO);
+ MessageDialog dialog(nullptr, msg_text, _L("Warning"), wxICON_WARNING | wxOK);
+ dialog.ShowModal();
+ return;
+ //if (dialog.ShowModal() == wxID_NO)
+ // return;
- if (dialog.ShowModal() == wxID_NO)
- return;
-
- m_printer.name = existing->name;
+ //m_printer.name = existing->name;
}
std::set repeat_presets;
@@ -821,7 +844,9 @@ void PhysicalPrinterDialog::OnOK(wxEvent& event)
wxGetApp().get_tab(Preset::TYPE_PRINTER)->update_preset_choice();
//B64
- wxGetApp().SetPresentChange(true);
+ // wxGetApp().SetPresentChange(true);
+ m_machine_name = into_u8(printer_name);
+ m_machine_host = now_host;
event.Skip();
}
@@ -867,4 +892,8 @@ void PhysicalPrinterDialog::DeletePreset(PresetForPrinter* preset_for_printer)
update_host_type(true);
}
+//y3
+std::string PhysicalPrinterDialog::get_name() { return m_machine_name; }
+std::string PhysicalPrinterDialog::get_host() { return m_machine_host; }
+
}} // namespace Slic3r::GUI
diff --git a/src/slic3r/GUI/PhysicalPrinterDialog.hpp b/src/slic3r/GUI/PhysicalPrinterDialog.hpp
index 8e34087..63fd904 100644
--- a/src/slic3r/GUI/PhysicalPrinterDialog.hpp
+++ b/src/slic3r/GUI/PhysicalPrinterDialog.hpp
@@ -79,12 +79,17 @@ class PhysicalPrinterDialog : public DPIDialog
wxString m_stored_host;
PrintHostType m_last_host_type;
bool m_opened_as_connect {false};
+ //y3
+ std::string m_machine_name;
+ std::string m_machine_host;
+
void build_printhost_settings(ConfigOptionsGroup* optgroup);
void OnOK(wxEvent& event);
void AddPreset(wxEvent& event);
public:
- PhysicalPrinterDialog(wxWindow* parent, wxString printer_name);
+ //y3
+ PhysicalPrinterDialog(wxWindow *parent, wxString printer_name, std::set exit_host);
~PhysicalPrinterDialog();
void update(bool printer_change = false);
@@ -98,10 +103,20 @@ public:
PrinterTechnology get_printer_technology();
void DeletePreset(PresetForPrinter* preset_for_printer);
+ //y3
+ std::string get_name();
+ std::string get_host();
+
+
protected:
void on_dpi_changed(const wxRect& suggested_rect) override;
void on_sys_color_changed() override;
+private:
+ //y3
+ std::set m_exit_host;
+ std::string old_name;
+
};
diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp
index a91a4cd..982a06c 100644
--- a/src/slic3r/GUI/PresetComboBoxes.cpp
+++ b/src/slic3r/GUI/PresetComboBoxes.cpp
@@ -364,19 +364,31 @@ void PresetComboBox::update(std::string select_preset_name)
}
void PresetComboBox::edit_physical_printer()
-{
+{
+ //y3
+ std::set m_exit_host = wxGetApp().getExitHost();
if (!m_preset_bundle->physical_printers.has_selection())
return;
-
- PhysicalPrinterDialog dlg(this->GetParent(),this->GetString(this->GetSelection()));
- if (dlg.ShowModal() == wxID_OK)
+ PhysicalPrinter &ph_printer = m_preset_bundle->physical_printers.get_selected_printer();
+ std::string ph_host = ph_printer.config.opt_string("print_host");
+ m_exit_host.erase(ph_host);
+ PhysicalPrinterDialog dlg(this->GetParent(), this->GetString(this->GetSelection()), m_exit_host);
+ if (dlg.ShowModal() == wxID_OK)
+ {
update();
+ wxGetApp().SetPresentChange(true);
+ }
+
}
void PresetComboBox::add_physical_printer()
-{
- if (PhysicalPrinterDialog(this->GetParent(), wxEmptyString).ShowModal() == wxID_OK)
+{
+ //y3
+ std::set m_exit_host = wxGetApp().getExitHost();
+ if (PhysicalPrinterDialog(this->GetParent(), wxEmptyString, m_exit_host).ShowModal() == wxID_OK) {
update();
+ wxGetApp().SetPresentChange(true);
+ }
}
void PresetComboBox::open_physical_printer_url()
@@ -409,6 +421,8 @@ bool PresetComboBox::del_physical_printer(const wxString& note_string/* = wxEmpt
return false;
m_preset_bundle->physical_printers.delete_selected_printer();
+ //y3
+ wxGetApp().SetPresentChange(true);
this->update();
@@ -775,7 +789,9 @@ void PlaterPresetComboBox::show_add_menu()
append_menu_item(menu, wxID_ANY, _L("Add physical printer"), "",
[this](wxCommandEvent&) {
- PhysicalPrinterDialog dlg(this->GetParent(), wxEmptyString);
+ //y3
+ std::set m_exit_host = wxGetApp().getExitHost();
+ PhysicalPrinterDialog dlg(this->GetParent(), wxEmptyString, m_exit_host);
if (dlg.ShowModal() == wxID_OK)
update();
}, "edit_uni", menu, []() { return true; }, wxGetApp().plater());
diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp
index 90f1e99..c839c6b 100644
--- a/src/slic3r/GUI/PrintHostDialogs.cpp
+++ b/src/slic3r/GUI/PrintHostDialogs.cpp
@@ -164,8 +164,8 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path & path,
wxHSCROLL | wxVSCROLL);
scroll_macine_list->SetBackgroundColour(*wxWHITE);
scroll_macine_list->SetScrollRate(5, 5);
- scroll_macine_list->SetMinSize(wxSize(FromDIP(320), 10 * FromDIP(30)));
- scroll_macine_list->SetMaxSize(wxSize(FromDIP(320), 10 * FromDIP(30)));
+ scroll_macine_list->SetMinSize(wxSize(FromDIP(320), 10 * FromDIP(27)));
+ scroll_macine_list->SetMaxSize(wxSize(FromDIP(320), 10 * FromDIP(27)));
wxBoxSizer *sizer_machine_list = new wxBoxSizer(wxVERTICAL);
scroll_macine_list->SetSizer(sizer_machine_list);
scroll_macine_list->Layout();
@@ -195,10 +195,20 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path & path,
}
}
}
+ //y4
+ PhysicalPrinter selected_printer = ph_printers.get_selected_printer();
+ std::set selected_printer_presets = selected_printer.get_preset_names();
+ std::string printer_preset = *selected_printer_presets.begin();
m_presetData = preset_data;
for (const PhysicalPrinterPresetData &data : preset_data) {
- wxCheckBox *checkbox = new wxCheckBox(scroll_macine_list, wxID_ANY, " " + data.fullname + "\n IP: " + data.host);
- checkbox->SetValue(data.selected);
+ //y4
+ SendCheckBox *checkbox = new SendCheckBox(scroll_macine_list, wxID_ANY, " " + data.fullname + "\n IP: " + data.host);
+ unSelectedBoxes.push_back(checkbox);
+ checkbox->Bind(wxEVT_CHECKBOX, &PrintHostSendDialog::OnCheckBoxClicked, this);
+ checkbox->SetState(data.selected);
+ if (printer_preset.find(data.preset_name) == std::string::npos) {
+ checkbox->Disable();
+ }
sizer_machine_list->Add(checkbox, 0, wxEXPAND | wxALL, 5);
}
@@ -211,18 +221,25 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path & path,
panel->SetSizer(box_sizer);
wxCheckBox *selectcheckbox = new wxCheckBox(panel, wxID_ANY, "");
-
- selectcheckbox->Bind(wxEVT_CHECKBOX, [sizer_machine_list](wxCommandEvent &event) {
+ //y4
+ selectcheckbox->Bind(wxEVT_CHECKBOX, [sizer_machine_list, this](wxCommandEvent &event) {
bool isChecked = event.IsChecked();
for (int i = 0; i < sizer_machine_list->GetItemCount(); i++) {
- wxCheckBox *checkbox = dynamic_cast(sizer_machine_list->GetItem(i)->GetWindow());
- if (checkbox) {
- checkbox->SetValue(isChecked);
+ SendCheckBox *checkbox = dynamic_cast(sizer_machine_list->GetItem(i)->GetWindow());
+ if ((isChecked && checkbox->IsChecked()) || (!isChecked && !checkbox->IsChecked())) {
+ continue;
}
+ else if (checkbox && checkbox->IsEnabled()) {
+ checkbox->SetState(isChecked);
+ }
+ checkbox->Refresh();
+ if (SelectedBoxes.size() == 6)
+ break;
}
+
});
- wxStaticText *text = new wxStaticText(panel, wxID_ANY, _L("QIDI Slicer's Physical Printer"));
+ wxStaticText *text = new wxStaticText(panel, wxID_ANY, _L("QIDI Local's Physical Printer"));
text->SetWindowStyle(wxALIGN_CENTER_HORIZONTAL);
box_sizer->Add(selectcheckbox, 0, wxEXPAND | wxALL, 5);
@@ -235,25 +252,37 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path & path,
scrool_box_sizer->Add(line, 0, wxEXPAND | wxTOP | wxBOTTOM, 5);
scrool_box_sizer->Add(scroll_macine_list);
-
wxScrolledWindow *scroll_macine_list2 = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(800), FromDIP(300)),
wxHSCROLL | wxVSCROLL);
scroll_macine_list2->SetBackgroundColour(*wxWHITE);
scroll_macine_list2->SetScrollRate(5, 5);
- scroll_macine_list2->SetMinSize(wxSize(FromDIP(320), 10 * FromDIP(30)));
- scroll_macine_list2->SetMaxSize(wxSize(FromDIP(320), 10 * FromDIP(30)));
- wxBoxSizer *sizer_machine_list2 = new wxBoxSizer(wxVERTICAL);
+ scroll_macine_list2->SetMinSize(wxSize(FromDIP(320), 10 * FromDIP(27)));
+ scroll_macine_list2->SetMaxSize(wxSize(FromDIP(320), 10 * FromDIP(27)));
+ wxBoxSizer* sizer_machine_list2 = new wxBoxSizer(wxVERTICAL);
scroll_macine_list2->SetSizer(sizer_machine_list2);
scroll_macine_list2->Layout();
#if QDT_RELEASE_TO_PUBLIC
auto m_devices = wxGetApp().get_devices();
- for (const auto &device : m_devices) {
- wxCheckBox *checkbox = new wxCheckBox(scroll_macine_list2, wxID_ANY, " " + from_u8(device.device_name) + "\n IP: " + device.local_ip);
- checkbox->SetValue(false);
+ for (const auto &device : m_devices)
+ {
+ //y4
+ SendCheckBox *checkbox = new SendCheckBox(scroll_macine_list2, wxID_ANY,
+ " " + from_u8(device.device_name) + "\n IP: " + device.local_ip);
+ unSelectedBoxes.push_back(checkbox);
+ checkbox->Bind(wxEVT_CHECKBOX, &PrintHostSendDialog::OnCheckBoxClicked, this);
+ checkbox->SetState(false);
+ std::string machine_type = device.machine_type;
+ if (machine_type.empty())
+ {
+ std::size_t found = device.device_name.find('@');
+ if (found != std::string::npos)
+ machine_type = device.device_name.substr(found + 1);
+ }
+ if (NormalizeVendor(printer_preset).find(NormalizeVendor(machine_type)) == std::string::npos || machine_type.empty())
+ checkbox->Disable();
sizer_machine_list2->Add(checkbox, 0, wxEXPAND | wxALL, 5);
-
- }
+ }
#endif
@@ -266,15 +295,21 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path & path,
panel2->SetSizer(box_sizer2);
wxCheckBox *selectcheckbox2 = new wxCheckBox(panel2, wxID_ANY, "");
-
- selectcheckbox2->Bind(wxEVT_CHECKBOX, [sizer_machine_list2](wxCommandEvent &event) {
+ //y4
+ selectcheckbox2->Bind(wxEVT_CHECKBOX, [sizer_machine_list2, this](wxCommandEvent &event) {
bool isChecked = event.IsChecked();
for (int i = 0; i < sizer_machine_list2->GetItemCount(); i++) {
- wxCheckBox *checkbox = dynamic_cast(sizer_machine_list2->GetItem(i)->GetWindow());
- if (checkbox) {
- checkbox->SetValue(isChecked);
+ SendCheckBox *checkbox = dynamic_cast(sizer_machine_list2->GetItem(i)->GetWindow());
+ if ((isChecked && checkbox->IsChecked()) || (!isChecked && !checkbox->IsChecked())) {
+ continue;
+ } else if (checkbox && checkbox->IsEnabled()) {
+ checkbox->SetState(isChecked);
}
+ checkbox->Refresh();
+ if (SelectedBoxes.size() == 6)
+ break;
}
+ sizer_machine_list2->Layout();
});
wxStaticText *text2 = new wxStaticText(panel2, wxID_ANY, _L("QIDI Link's Physical Printer"));
@@ -294,10 +329,13 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path & path,
wxStaticBoxSizer *sizer1 = new wxStaticBoxSizer(wxVERTICAL, this, _L(""));
- sizer1->Add(scrool_box_sizer, 1, wxEXPAND | wxALL, 10);
+ sizer1->Add(scrool_box_sizer);
+
wxStaticBoxSizer *sizer2 = new wxStaticBoxSizer(wxVERTICAL, this, _L(""));
- sizer2->Add(scrool_box_sizer2, 1, wxEXPAND | wxALL, 10);
+ sizer2->Add(scrool_box_sizer2);
+
+
//hbox2->Add(scrool_box_sizer);
@@ -305,13 +343,13 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path & path,
//hbox2->Add(scrool_box_sizer2);
- hbox2->Add(sizer1, 1, wxEXPAND);
+ hbox2->Add(sizer1);
hbox2->Add(0, 0, 0, wxEXPAND | wxLEFT, 23);
- hbox2->Add(sizer2, 1, wxEXPAND);
+ hbox2->Add(sizer2);
content_sizer->Add(hbox2 , 1, wxEXPAND);
content_sizer->Add(0, 0, 0, wxEXPAND | wxBOTTOM, 23);
-
+
if (combo_groups != nullptr) {
// Repetier specific: Show a selection of file groups.
auto *label_group = new wxStaticText(this, wxID_ANY, _L("Group"));
@@ -605,6 +643,39 @@ void PrintHostSendDialog::EndModal(int ret)
MsgDialog::EndModal(ret);
}
+//y4
+std::string PrintHostSendDialog::NormalizeVendor(const std::string &str)
+{
+ std::string normalized;
+ for (char c : str) {
+ if (std::isalnum(c)) {
+ normalized += std::tolower(c);
+ }
+ }
+ return normalized;
+}
+//y4
+void PrintHostSendDialog::OnCheckBoxClicked(wxCommandEvent &event)
+{
+ SendCheckBox *checkbox = dynamic_cast(event.GetEventObject());
+ if (checkbox->IsChecked()) {
+ if (SelectedBoxes.size() < 6) {
+ SelectedBoxes.push_back(checkbox);
+ unSelectedBoxes.erase(std::remove(unSelectedBoxes.begin(), unSelectedBoxes.end(), checkbox), unSelectedBoxes.end());
+ } else {
+ checkbox->SetValue(false);
+ wxString msg_text = _L("The max selected printer number is 6.");
+ MessageDialog dialog(nullptr, msg_text, _L("Information"), wxICON_INFORMATION | wxOK);
+ dialog.ShowModal();
+ return;
+ }
+ } else {
+ SelectedBoxes.erase(std::remove(SelectedBoxes.begin(), SelectedBoxes.end(), checkbox), SelectedBoxes.end());
+ unSelectedBoxes.push_back(checkbox);
+ }
+}
+
+
//B64
wxDEFINE_EVENT(EVT_PRINTHOST_WAIT, PrintHostQueueDialog::Event);
diff --git a/src/slic3r/GUI/PrintHostDialogs.hpp b/src/slic3r/GUI/PrintHostDialogs.hpp
index 3e26b9d..60abf0c 100644
--- a/src/slic3r/GUI/PrintHostDialogs.hpp
+++ b/src/slic3r/GUI/PrintHostDialogs.hpp
@@ -25,6 +25,25 @@ class wxDataViewListCtrl;
namespace Slic3r {
namespace GUI {
+//y4
+class SendCheckBox : public wxCheckBox
+{
+public:
+ SendCheckBox(wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos = wxDefaultPosition)
+ : wxCheckBox(parent, id, label, pos)
+ {}
+
+ void SetState(bool value)
+ {
+ wxCheckBox::SetValue(value);
+ wxCommandEvent event(wxEVT_CHECKBOX, GetId());
+ event.SetEventObject(this);
+ event.SetInt(value);
+ GetEventHandler()->ProcessEvent(event);
+ }
+};
+
+
//B53 //B62
struct PhysicalPrinterPresetData
@@ -62,6 +81,10 @@ public:
//B64
wxBoxSizer *create_item_input(
wxString str_before, wxString str_after, wxWindow *parent, wxString tooltip, std::string param);
+ //y4
+ std::string NormalizeVendor(const std::string &str);
+ void OnCheckBoxClicked(wxCommandEvent &event);
+
private:
wxTextCtrl *txt_filename;
wxComboBox *combo_groups;
@@ -77,6 +100,9 @@ private:
std::vector m_checkbox_net_states;
//B61
Plater *m_plater{nullptr};
+ //y4
+ std::vector unSelectedBoxes;
+ std::vector SelectedBoxes;
};
diff --git a/src/slic3r/GUI/PrinterWebView.cpp b/src/slic3r/GUI/PrinterWebView.cpp
index 0382a8a..23fb431 100644
--- a/src/slic3r/GUI/PrinterWebView.cpp
+++ b/src/slic3r/GUI/PrinterWebView.cpp
@@ -56,7 +56,7 @@ PrinterWebView::PrinterWebView(wxWindow *parent) : wxPanel(parent, wxID_ANY, wxD
init_scroll_window(this);
wxPanel *titlePanel = new wxPanel(this, wxID_ANY);
- titlePanel->SetBackgroundColour(wxColour(30, 30, 32));
+ titlePanel->SetBackgroundColour(wxColour(38, 38, 41));
wxPanel *menuPanel = new wxPanel(titlePanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxTAB_TRAVERSAL);
menuPanel->SetSizer(menuPanelSizer);
@@ -75,9 +75,10 @@ PrinterWebView::PrinterWebView(wxWindow *parent) : wxPanel(parent, wxID_ANY, wxD
titlePanel->SetSizer(buttonSizer);
toggleBar = new SwitchButton(menuPanel);
- toggleBar->SetSize(300);
+ toggleBar->SetSize(327);
toggleBar->SetMaxSize({em_unit(this) * 40, -1});
- toggleBar->SetLabels(_L("Slicer"), _L("Link"));
+ //y3
+ toggleBar->SetLabels(_L("Local"), _L("Link"));
toggleBar->SetValue(m_isNetMode);
toggleBar->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent &evt) {
bool is_checked = evt.GetInt();
@@ -87,10 +88,22 @@ PrinterWebView::PrinterWebView(wxWindow *parent) : wxPanel(parent, wxID_ANY, wxD
if (!m_isNetMode) {
wxGetApp().app_config->set("machine_list_net", "0");
ShowLocalPrinterButton();
+ //y3
+ if (into_u8(m_web).find("missing_connection") != std::string::npos) {
+ wxString url = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
+ load_disconnect_url(url);
+ }
} else {
wxGetApp().app_config->set("machine_list_net", "1");
ShowNetPrinterButton();
+ if (into_u8(m_web).find("missing_connection") != std::string::npos) {
+ wxString url = wxString::Format("file://%s/web/qidi/link_missing_connection.html", from_u8(resources_dir()));
+ load_disconnect_url(url);
+ }
}
+ leftScrolledWindow->Scroll(0, 0);
+ UpdateLayout();
+ UpdateState();
});
menuPanelSizer->Add(toggleBar);
@@ -114,7 +127,11 @@ PrinterWebView::PrinterWebView(wxWindow *parent) : wxPanel(parent, wxID_ANY, wxD
leftallsizer->Add(titlePanel, wxSizerFlags(0).Expand());
leftallsizer->Add(leftScrolledWindow, wxSizerFlags(1).Expand());
+ wxPanel* line_area = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(1,10));
+ line_area->SetBackgroundColour(wxColor(66, 66, 69));
+
allsizer->Add(leftallsizer, wxSizerFlags(0).Expand());
+ allsizer->Add(line_area, 0, wxEXPAND);
allsizer->Add(m_browser, wxSizerFlags(1).Expand().Border(wxALL, 0));
// Zoom
@@ -129,7 +146,7 @@ PrinterWebView::PrinterWebView(wxWindow *parent) : wxPanel(parent, wxID_ANY, wxD
if (m_isSimpleMode) {
arrow_button->SetBitmap(*get_bmp_bundle("arrow-right-s-line", 20));
devicesizer->SetMinSize(wxSize(190, -1));
- toggleBar->SetSize(190);
+ toggleBar->SetSize(237);
leftScrolledWindow->SetMinSize(wxSize(190, -1));
devicesizer->Layout();
leftScrolledWindow->Layout();
@@ -155,12 +172,12 @@ wxBoxSizer *PrinterWebView::init_login_bar(wxPanel *Panel)
std::pair(wxColour(68, 121, 251), StateColor::Hovered),
std::pair(wxColour(198, 198, 200), StateColor::Normal));
- StateColor btn_bg(std::pair(wxColour(30, 30, 32), StateColor::Disabled),
- std::pair(wxColour(30, 30, 32), StateColor::Pressed),
- std::pair(wxColour(30, 30, 32), StateColor::Hovered),
- std::pair(wxColour(30, 30, 32), StateColor::Normal));
+ StateColor btn_bg(std::pair(wxColour(38, 38, 41), StateColor::Disabled),
+ std::pair(wxColour(38, 38, 41), StateColor::Pressed),
+ std::pair(wxColour(38, 38, 41), StateColor::Hovered),
+ std::pair(wxColour(38, 38, 41), StateColor::Normal));
- login_button = new DeviceButton(Panel, "Login/Register", "", wxBU_LEFT);
+ login_button = new DeviceButton(Panel, _L("Login/Register"), "", wxBU_LEFT);
login_button->SetTextColor(text_color);
login_button->SetBackgroundColor(btn_bg);
login_button->SetBorderColor(btn_bg);
@@ -178,33 +195,37 @@ wxBoxSizer *PrinterWebView::init_menu_bar(wxPanel *Panel)
wxBoxSizer *buttonsizer = new wxBoxSizer(wxHORIZONTAL);
StateColor add_btn_bg(std::pair(wxColour(57, 57, 61), StateColor::Disabled),
- std::pair(wxColour(26, 26, 28), StateColor::Pressed),
- std::pair(wxColour(26, 26, 28), StateColor::Hovered),
- std::pair(wxColour(76, 76, 79), StateColor::Normal));
+ std::pair(wxColour(138, 138, 141), StateColor::Pressed),
+ std::pair(wxColour(85, 85, 90), StateColor::Hovered),
+ std::pair(wxColour(74, 74, 79), StateColor::Normal));
// B63
- add_button = new DeviceButton(Panel, "", "add_machine_list_able", wxBU_LEFT);
+ add_button = new DeviceButton(Panel, "add_machine_list_able", wxBU_LEFT);
add_button->SetBackgroundColor(add_btn_bg);
+ add_button->SetBorderColor(wxColour(57, 51, 55));
add_button->SetCanFocus(false);
buttonsizer->Add(add_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
add_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnAddButtonClick, this);
- // B63
- delete_button = new DeviceButton(Panel, "", "delete_machine_list_able", wxBU_LEFT);
+ // B63 //y3
+ delete_button = new DeviceButton(Panel, "delete_machine_list_able", wxBU_LEFT);
delete_button->SetBackgroundColor(add_btn_bg);
+ delete_button->SetBorderColor(wxColour(57, 51, 55));
delete_button->SetCanFocus(false);
buttonsizer->Add(delete_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
delete_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnDeleteButtonClick, this);
// B63
- edit_button = new DeviceButton(Panel, "", "edit_machine_list_able", wxBU_LEFT);
+ edit_button = new DeviceButton(Panel, "edit_machine_list_able", wxBU_LEFT);
edit_button->SetBackgroundColor(add_btn_bg);
+ edit_button->SetBorderColor(wxColour(57, 51, 55));
edit_button->SetCanFocus(false);
buttonsizer->Add(edit_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
edit_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnEditButtonClick, this);
- refresh_button = new DeviceButton(Panel, "", "refresh_machine_list_able", wxBU_LEFT);
+ refresh_button = new DeviceButton(Panel, "refresh_machine_list_able", wxBU_LEFT);
refresh_button->SetBackgroundColor(add_btn_bg);
+ refresh_button->SetBorderColor(wxColour(57, 51, 55));
refresh_button->SetCanFocus(false);
buttonsizer->Add(refresh_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
refresh_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnRefreshButtonClick, this);
@@ -217,15 +238,15 @@ wxBoxSizer *PrinterWebView::init_menu_bar(wxPanel *Panel)
if (m_isSimpleMode)
text_static->Hide();
-
- arrow_button = new wxButton(Panel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
+ //y3
+ arrow_button = new RoundButton(Panel, wxID_ANY, "", wxDefaultPosition, wxSize(35, 35));
arrow_button->SetBackgroundColour(Panel->GetBackgroundColour());
arrow_button->SetForegroundColour(Panel->GetBackgroundColour());
- arrow_button->SetMinSize(wxSize(40, -1));
if (m_isSimpleMode)
arrow_button->SetBitmap(*get_bmp_bundle("arrow-right-s-line", 20));
else
arrow_button->SetBitmap(*get_bmp_bundle("arrow-left-s-line", 20));
+ buttonsizer->AddStretchSpacer(1);
buttonsizer->Add(arrow_button, wxSizerFlags().Align(wxALIGN_RIGHT).CenterVertical().Border(wxALL, 2));
arrow_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnZoomButtonClick, this);
@@ -235,7 +256,7 @@ wxBoxSizer *PrinterWebView::init_menu_bar(wxPanel *Panel)
}
void PrinterWebView::init_scroll_window(wxPanel* Panel) {
leftScrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL | wxVSCROLL);
- leftScrolledWindow->SetBackgroundColour(wxColour(30, 30, 32));
+ leftScrolledWindow->SetBackgroundColour(wxColour(38, 38, 41));
leftScrolledWindow->SetSizer(devicesizer);
leftScrolledWindow->SetScrollRate(10, 10);
leftScrolledWindow->SetMinSize(wxSize(300, -1));
@@ -323,7 +344,7 @@ void PrinterWebView::SetPresetChanged(bool status) {
m_stopThread = false;
DeleteButton();
DeleteNetButton();
-
+ m_exit_host.clear();
//ShowLocalPrinterButton();
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
@@ -348,16 +369,25 @@ void PrinterWebView::SetPresetChanged(bool status) {
const auto opt = cfg_t->option>("host_type");
auto host_type = opt != nullptr ? opt->value : htOctoPrint;
-
+ //y3
+ bool is_selected = false;
+ if (!select_machine_name.empty())
+ if (select_machine_name == it->get_short_name(full_name)) {
+ is_selected = true;
+ select_machine_name = "";
+ }
//BOOST_LOG_TRIVIAL(error) << preset_name;
//BOOST_LOG_TRIVIAL(error) << full_name;
//BOOST_LOG_TRIVIAL(error) << (it->get_short_name(full_name));
//BOOST_LOG_TRIVIAL(error) << (it->get_preset_name(full_name));
//BOOST_LOG_TRIVIAL(error) << model_id;
- AddButton((it->get_short_name(full_name)), host, model_id, full_name, ph_printers.is_selected(it, preset_name),
+ AddButton((it->get_short_name(full_name)), host, model_id, full_name, is_selected,
(host_type == htMoonraker));
+ m_exit_host.insert(host);
}
}
+ wxGetApp().setExitHost(m_exit_host);
+
#if QDT_RELEASE_TO_PUBLIC
auto m_devices = wxGetApp().get_devices();
@@ -365,14 +395,55 @@ void PrinterWebView::SetPresetChanged(bool status) {
AddNetButton(device);
}
#endif
-
- if (GetNetMode()) {
- ShowNetPrinterButton();
- } else {
- ShowLocalPrinterButton();
- }
+ //y3
+ if (webisNetMode == isNetWeb) {
+ ShowNetPrinterButton();
+ for (DeviceButton* button : m_net_buttons) {
+ if (m_ip == (button->getIPLabel())) {
+ button->SetIsSelected(true);
+ wxCommandEvent event(wxEVT_BUTTON, button->GetId());
+ wxPostEvent(button, event);
+ break;
+ }
+ }
+ toggleBar->SetValue(true);
+ m_isNetMode = true;
+ } else if (webisNetMode == isLocalWeb) {
+ ShowLocalPrinterButton();
+ if (m_exit_host.find(into_u8(m_ip)) != m_exit_host.end())
+ {
+ for (DeviceButton* button : m_buttons) {
+ if (m_ip == (button->getIPLabel())) {
+ button->SetIsSelected(true);
+ break;
+ }
+ }
+ toggleBar->SetValue(false);
+ m_isNetMode = false;
+ } else {
+ wxString m_host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
+ load_disconnect_url(m_host);
+ }
+ }
+ else
+ {
+ if (m_isNetMode)
+ {
+ ShowNetPrinterButton();
+ wxString m_host = wxString::Format("file://%s/web/qidi/link_missing_connection.html", from_u8(resources_dir()));
+ load_disconnect_url(m_host);
+ }
+ else
+ {
+ ShowLocalPrinterButton();
+ wxString m_host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
+ load_disconnect_url(m_host);
+ }
+ }
CreatThread();
+ UpdateState();
+ UpdateLayout();
}
}
void PrinterWebView::SetLoginStatus(bool status) {
@@ -393,17 +464,15 @@ void PrinterWebView::SetLoginStatus(bool status) {
m_isloginin = true;
UpdateState();
} else {
- login_button->SetLabel("Login/Register");
+ login_button->SetLabel(_L("Login/Register"));
#if QDT_RELEASE_TO_PUBLIC
std::vector devices;
wxGetApp().set_devices(devices);
#endif
-
+ //y3
+ if (webisNetMode == isNetWeb)
+ webisNetMode = isDisconnect;
SetPresetChanged(true);
- m_isNetMode = false;
- toggleBar->SetValue(m_isNetMode);
- ShowLocalPrinterButton();
- wxGetApp().app_config->set("machine_list_net", "0");
UpdateState();
}
}
@@ -426,12 +495,13 @@ void PrinterWebView::AddButton(const wxString & device_name,
{
wxString Machine_Name = Machine_Name.Format("%s%s", machine_type, "_thumbnail");
- StateColor mac_btn_bg(std::pair(wxColour(26, 26, 28), StateColor::Pressed),
- std::pair(wxColour(26, 26, 28), StateColor::Hovered),
- std::pair(wxColour(38, 38, 41), StateColor::Normal));
+ StateColor mac_btn_bg(std::pair(wxColour(147, 147, 150), StateColor::Pressed),
+ std::pair(wxColour(76, 76, 80), StateColor::Hovered),
+ std::pair(wxColour(67, 67, 71), StateColor::Normal));
DeviceButton *machine_button = new DeviceButton(leftScrolledWindow, fullname, Machine_Name, wxBU_LEFT, wxSize(80, 80), device_name, ip);
machine_button->SetBackgroundColor(mac_btn_bg);
+ machine_button->SetBorderColor(wxColour(67, 67, 71));
machine_button->SetCanFocus(false);
machine_button->SetIsSimpleMode(m_isSimpleMode);
wxString formattedHost = ip;
@@ -449,37 +519,69 @@ void PrinterWebView::AddButton(const wxString & device_name,
devicesizer->Add(machine_button, wxSizerFlags().Border(wxALL, 1).Expand());
devicesizer->Layout();
m_buttons.push_back(machine_button);
+
+ if(isSelected)
+ load_url(formattedHost);
}
+
+//y3
+std::string PrinterWebView::NormalizeVendor(const std::string& str)
+{
+ std::string normalized;
+ for (char c : str) {
+ if (std::isalnum(c)) {
+ normalized += std::tolower(c);
+ }
+ }
+ return normalized;
+}
+
#if QDT_RELEASE_TO_PUBLIC
void PrinterWebView::AddNetButton(const Device device)
{
- // y2
- const Preset preset = wxGetApp().preset_bundle->prints.get_edited_preset();
- bool isQIDI = false;
- auto models = preset.vendor->models;
- for (auto model : models) {
- std::string model_id = model.id;
- if (device.device_name.find(model_id) != std::string::npos) {
- isQIDI = true;
- break;
- }
- }
+ //y3
+ std::set qidi_printers = wxGetApp().preset_bundle->get_vendors();
- std::size_t found = device.device_name.find('@');
- wxString Machine_Name;
- wxString device_name;
- // y2
- if (found != std::string::npos && isQIDI) {
- std::string extracted = device.device_name.substr(found + 1);
- Machine_Name = Machine_Name.Format("%s%s", extracted, "_thumbnail");
- device_name = device_name.Format("%s", device.device_name.substr(0, found));
- } else {
- Machine_Name = Machine_Name.Format("%s%s", "my_printer", "_thumbnail");
- device_name = device_name.Format("%s", device.device_name);
- }
- StateColor mac_btn_bg(std::pair(wxColour(26, 26, 28), StateColor::Pressed),
- std::pair(wxColour(26, 26, 28), StateColor::Hovered),
- std::pair(wxColour(38, 38, 41), StateColor::Normal));
+ wxString Machine_Name;
+ wxString device_name;
+ if (!device.machine_type.empty())
+ {
+ device_name = device.device_name;
+ std::string extracted = device.machine_type;
+ for (std::string machine_vendor : qidi_printers)
+ {
+ if (NormalizeVendor(machine_vendor) == NormalizeVendor(extracted))
+ {
+ Machine_Name = Machine_Name.Format("%s%s", machine_vendor, "_thumbnail");
+ break;
+ }
+ }
+ }
+ else
+ {
+ device_name = device.device_name;
+ std::size_t found = device.device_name.find('@');
+ if (found != std::string::npos)
+ {
+ std::string extracted = device.device_name.substr(found + 1);
+ for (std::string machine_vendor : qidi_printers)
+ {
+ if (NormalizeVendor(machine_vendor) == NormalizeVendor(extracted))
+ {
+ Machine_Name = Machine_Name.Format("%s%s", machine_vendor, "_thumbnail");
+ break;
+ }
+ }
+ }
+ }
+
+ if (Machine_Name.empty())
+ {
+ Machine_Name = Machine_Name.Format("%s%s", "my_printer", "_thumbnail");
+ }
+ StateColor mac_btn_bg(std::pair(wxColour(147, 147, 150), StateColor::Pressed),
+ std::pair(wxColour(76, 76, 80), StateColor::Hovered),
+ std::pair(wxColour(67, 67, 71), StateColor::Normal));
QIDINetwork m_qidinetwork;
@@ -488,6 +590,7 @@ void PrinterWebView::AddNetButton(const Device device)
device_name, device.local_ip);
machine_button->SetBackgroundColor(mac_btn_bg);
+ machine_button->SetBorderColor(wxColour(67, 67, 71));
machine_button->SetCanFocus(false);
machine_button->SetIsSimpleMode(m_isSimpleMode);
@@ -598,7 +701,7 @@ void PrinterWebView::OnZoomButtonClick(wxCommandEvent &event)
staticBitmap->SetBitmap(ScalableBitmap(this, "user_dark", wxSize(60, 60)).get_bitmap());
login_button->SetIsSimpleMode(m_isSimpleMode);
wxGetApp().app_config->set("machine_list_minification", "0");
- toggleBar->SetSize(300);
+ toggleBar->SetSize(327);
devicesizer->SetMinSize(wxSize(300, -1));
leftScrolledWindow->SetMinSize(wxSize(300, -1));
arrow_button->SetBitmap(*get_bmp_bundle("arrow-left-s-line", 20));
@@ -614,7 +717,7 @@ void PrinterWebView::OnZoomButtonClick(wxCommandEvent &event)
login_button->SetIsSimpleMode(m_isSimpleMode);
wxGetApp().app_config->set("machine_list_minification", "1");
- toggleBar->SetSize(190);
+ toggleBar->SetSize(237);
arrow_button->SetBitmap(*get_bmp_bundle("arrow-right-s-line", 20));
devicesizer->SetMinSize(wxSize(190, -1));
leftScrolledWindow->SetMinSize(wxSize(190, -1));
@@ -676,6 +779,12 @@ void PrinterWebView::OnLoginButtonClick(wxCommandEvent &event)
{
// B64
wxGetApp().ShowUserLogin(true);
+ devicesizer->Layout();
+
+ leftScrolledWindow->Layout();
+
+ allsizer->Layout();
+ UpdateLayout();
// if (m_isloginin) {
// wxGetApp().app_config->set("user_token", "");
@@ -702,12 +811,13 @@ void PrinterWebView::OnLoginButtonClick(wxCommandEvent &event)
}
void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
{
- PhysicalPrinterDialog dlg(this->GetParent(), wxEmptyString);
+ PhysicalPrinterDialog dlg(this->GetParent(), wxEmptyString, m_exit_host);
if (dlg.ShowModal() == wxID_OK) {
if (m_handlerl) {
m_handlerl(event);
}
- // SetPresetChanged(true);
+ select_machine_name = dlg.get_name();
+ SetPresetChanged(true);
UpdateLayout();
Refresh();
}
@@ -733,11 +843,9 @@ void PrinterWebView::OnDeleteButtonClick(wxCommandEvent &event)
preset_bundle.physical_printers.delete_selected_printer();
+ webisNetMode = isDisconnect;
SetPresetChanged(true);
- wxString host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
- load_url(host);
-
UpdateLayout();
Refresh();
break;
@@ -771,10 +879,8 @@ void PrinterWebView::OnDeleteButtonClick(wxCommandEvent &event)
}
}
#endif
-
+ webisNetMode = isDisconnect;
SetPresetChanged(true);
- wxString host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
- load_url(host);
UpdateLayout();
Refresh();
@@ -790,13 +896,24 @@ void PrinterWebView::OnEditButtonClick(wxCommandEvent &event)
{
for (DeviceButton *button : m_buttons) {
if ((button->GetIsSelected())) {
- // y1
- PhysicalPrinterDialog dlg(this->GetParent(), button->GetLabel());
+ // y1 //y3
+ m_exit_host.erase(into_u8(button->getIPLabel()));
+ PhysicalPrinterDialog dlg(this->GetParent(), button->GetLabel(), m_exit_host);
if (dlg.ShowModal() == wxID_OK) {
if (m_handlerl) {
m_handlerl(event);
}
- // SetPresetChanged(true);
+ m_ip = dlg.get_host();
+ wxString url;
+ if (!m_ip.Lower().starts_with("http"))
+ url = wxString::Format("http://%s", m_ip);
+
+ if (!url.Lower().ends_with("10088"))
+ url = wxString::Format("%s:10088", url);
+
+ load_url(url);
+
+ SetPresetChanged(true);
}
break;
}
@@ -875,19 +992,30 @@ void PrinterWebView::OnScroll(wxScrollWinEvent &event)
UpdateLayout();
event.Skip();
}
+
+//y3
+void PrinterWebView::load_disconnect_url(wxString& url)
+{
+ webisNetMode = isDisconnect;
+ m_web = url;
+ m_ip = "";
+ m_browser->LoadURL(url);
+ UpdateState();
+}
+
void PrinterWebView::load_url(wxString &url)
{
if (m_browser == nullptr || m_web == url)
return;
- // m_web = url;
+ m_web = url;
m_browser->LoadURL(url);
-
+ webisNetMode = isLocalWeb;
// B55
if (url.Lower().starts_with("http"))
url.Remove(0, 7);
if (url.Lower().ends_with("10088"))
url.Remove(url.length() - 6);
-
+ m_ip = url;
for (DeviceButton *button : m_net_buttons) {
button->SetIsSelected(false);
}
@@ -904,7 +1032,9 @@ void PrinterWebView::load_net_url(std::string url, std::string ip)
{
if (m_browser == nullptr || m_web == url)
return;
- // m_web = url;
+ m_web = url;
+ m_ip = ip;
+ webisNetMode = isNetWeb;
m_browser->LoadURL(url);
for (DeviceButton *button : m_buttons) {
@@ -921,57 +1051,58 @@ void PrinterWebView::load_net_url(std::string url, std::string ip)
}
void PrinterWebView::UpdateState()
{
- m_select_type = "null";
- add_button->SetIcon("add_machine_list_able");
- add_button->Enable(true);
- add_button->Refresh();
- delete_button->SetIcon("delete_machine_list_disable");
- delete_button->Enable(false);
- delete_button->Refresh();
- edit_button->SetIcon("edit_machine_list_disable");
- edit_button->Enable(false);
- edit_button->Refresh();
- refresh_button->SetIcon("refresh_machine_list_disable");
- refresh_button->Enable(false);
- refresh_button->Refresh();
- login_button->Refresh();
-
- for (DeviceButton *button : m_buttons) {
- if (button->GetIsSelected()) {
- m_select_type = "local";
- add_button->SetIcon("add_machine_list_able");
- add_button->Enable(true);
- add_button->Refresh();
- delete_button->SetIcon("delete_machine_list_able");
- delete_button->Enable(true);
- delete_button->Refresh();
- edit_button->SetIcon("edit_machine_list_able");
- edit_button->Enable(true);
- edit_button->Refresh();
- refresh_button->SetIcon("refresh_machine_list_able");
- refresh_button->Enable(true);
- refresh_button->Refresh();
- login_button->Refresh();
- }
- }
- for (DeviceButton *button : m_net_buttons) {
- if (button->GetIsSelected()) {
- m_select_type = "net";
- add_button->SetIcon("add_machine_list_disable");
- add_button->Enable(false);
- add_button->Refresh();
- delete_button->SetIcon("delete_machine_list_able");
- delete_button->Enable(true);
- delete_button->Refresh();
- edit_button->SetIcon("edit_machine_list_disable");
- edit_button->Enable(false);
- edit_button->Refresh();
- refresh_button->SetIcon("refresh_machine_list_able");
- refresh_button->Enable(true);
- refresh_button->Refresh();
- login_button->Refresh();
- }
- }
+ //y3
+ StateColor add_btn_bg(std::pair(wxColour(57, 57, 61), StateColor::Disabled),
+ std::pair(wxColour(138, 138, 141), StateColor::Pressed),
+ std::pair(wxColour(85, 85, 90), StateColor::Hovered),
+ std::pair(wxColour(74, 74, 79), StateColor::Normal));
+ if (!m_isNetMode){
+ m_select_type = "local";
+ add_button->SetIcon("add_machine_list_able");
+ add_button->Enable(true);
+ add_button->Refresh();
+ delete_button->SetIcon("delete_machine_list_disable");
+ delete_button->Enable(false);
+ delete_button->Refresh();
+ edit_button->SetIcon("edit_machine_list_disable");
+ edit_button->Enable(false);
+ edit_button->Refresh();
+ refresh_button->SetIcon("refresh_machine_list_able");
+ refresh_button->Enable(true);
+ refresh_button->Refresh();
+ login_button->Refresh();
+ for (DeviceButton* button : m_buttons) {
+ if (button->GetIsSelected()) {
+ delete_button->SetIcon("delete_machine_list_able");
+ delete_button->Enable(true);
+ delete_button->Refresh();
+ edit_button->SetIcon("edit_machine_list_able");
+ edit_button->Enable(true);
+ edit_button->Refresh();
+ }
+ }
+ }else{
+ m_select_type = "net";
+ add_button->SetIcon("add_machine_list_disable");
+ add_button->Enable(false);
+ add_button->Refresh();
+ delete_button->SetIcon("delete_machine_list_disable");
+ delete_button->Enable(false);
+ delete_button->Refresh();
+ edit_button->SetIcon("edit_machine_list_disable");
+ edit_button->Enable(false);
+ edit_button->Refresh();
+ refresh_button->SetIcon("refresh_machine_list_able");
+ refresh_button->Enable(true);
+ refresh_button->Refresh();
+ login_button->Refresh();
+ for (DeviceButton* button : m_net_buttons) {
+ if (button->GetIsSelected()) {
+ delete_button->SetIcon("delete_machine_list_able");
+ delete_button->Enable(true);
+ }
+ }
+ }
}
void PrinterWebView::OnClose(wxCloseEvent &evt) { this->Hide(); }
void PrinterWebView::RunScript(const wxString &javascript)
diff --git a/src/slic3r/GUI/PrinterWebView.hpp b/src/slic3r/GUI/PrinterWebView.hpp
index 073bb60..6d82a6c 100644
--- a/src/slic3r/GUI/PrinterWebView.hpp
+++ b/src/slic3r/GUI/PrinterWebView.hpp
@@ -48,9 +48,13 @@
namespace Slic3r {
namespace GUI {
-
-
-
+//y3
+enum WebState
+{
+ isDisconnect,
+ isLocalWeb,
+ isNetWeb
+};
class PrinterWebView : public wxPanel {
public:
@@ -113,6 +117,10 @@ public:
std::vector GetButton() { return m_buttons; };
bool GetNetMode() { return m_isNetMode; };
std::vector GetNetButton() { return m_net_buttons; };
+ //y3
+ std::string NormalizeVendor(const std::string& str);
+ void load_disconnect_url(wxString& url);
+ std::set GetExitHost() { return m_exit_host; };
private:
wxBoxSizer *leftallsizer;
@@ -151,9 +159,71 @@ private:
bool m_isloginin;
SwitchButton * toggleBar;
wxStaticBitmap * staticBitmap;
+ //y3
+ wxString m_ip;
+ std::string select_machine_name;
+ WebState webisNetMode = isDisconnect;
+ std::set m_exit_host;
};
+//y3
+class RoundButton : public wxButton
+{
+public:
+ RoundButton(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize)
+ : wxButton(parent, id, label, pos, size, wxBORDER_NONE)
+ {
+ m_hovered = false;
+ Bind(wxEVT_ENTER_WINDOW, &RoundButton::OnMouseEnter, this);
+ Bind(wxEVT_LEAVE_WINDOW, &RoundButton::OnMouseLeave, this);
+ Bind(wxEVT_PAINT, &RoundButton::OnPaint, this);
+ }
+protected:
+ void OnMouseEnter(wxMouseEvent& event)
+ {
+ m_hovered = true;
+ Refresh();
+ }
+
+ void OnMouseLeave(wxMouseEvent& event)
+ {
+ m_hovered = false;
+ Refresh();
+ }
+
+ void OnPaint(wxPaintEvent& event)
+ {
+ wxPaintDC dc(this);
+
+
+ wxSize size = GetClientSize();
+ int x = size.x;
+ int y = size.y;
+
+ if (m_hovered)
+ {
+ dc.SetBrush(wxBrush(wxColour(60, 60, 63), wxBRUSHSTYLE_SOLID));
+ }
+ else
+ {
+ dc.SetBrush(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
+ }
+
+ dc.SetPen(wxPen(GetBackgroundColour(), 1, wxPENSTYLE_TRANSPARENT));
+
+
+ wxBitmap img = GetBitmap();
+ wxSize img_size = img.GetSize();
+
+ int radius = std::max(img_size.x, img_size.y) / 2;
+ dc.DrawCircle(size.x / 2, size.y / 2, radius + 5);
+ dc.DrawBitmap(img, (size.x - img_size.x) / 2, (size.y - img_size.y) / 2);
+ }
+
+private:
+ bool m_hovered;
+};
} // GUI
} // Slic3r
diff --git a/src/slic3r/GUI/Widgets/DeviceButton.cpp b/src/slic3r/GUI/Widgets/DeviceButton.cpp
index b56cc09..e91ce84 100644
--- a/src/slic3r/GUI/Widgets/DeviceButton.cpp
+++ b/src/slic3r/GUI/Widgets/DeviceButton.cpp
@@ -26,7 +26,7 @@ END_EVENT_TABLE()
DeviceButton::DeviceButton(wxString name_text, wxString ip_text) : paddingSize(10, 8), m_name_text(name_text), m_ip_text(ip_text)
{
background_color = StateColor(
- std::make_pair(0xF0F0F0, (int) StateColor::Disabled),
+ std::make_pair(0x262629, (int) StateColor::Disabled),
std::make_pair(0x37EE7C, (int) StateColor::Hovered | StateColor::Checked),
std::make_pair(0x00AE42, (int) StateColor::Checked),
std::make_pair(*wxLIGHT_GREY, (int) StateColor::Hovered),
@@ -49,6 +49,14 @@ DeviceButton::DeviceButton(wxWindow *parent,
Create(parent, text, icon, style, iconSize);
}
+//y3
+DeviceButton::DeviceButton(wxWindow *parent, wxString icon, long style)
+{
+ paddingSize = wxSize(12, 6);
+ wxSize iconSize = wxSize(20, 20);
+ Create(parent, "", icon, style, iconSize);
+}
+
bool DeviceButton::Create(wxWindow *parent, wxString text, wxString icon, long style, wxSize iconSize /* = wxSize(16, 16)*/)
{
StaticBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
@@ -164,14 +172,14 @@ void DeviceButton::SetIsSelected(bool isSelected)
{
m_isSelected = isSelected;
if (m_isSelected) {
- StateColor calc_btn_bg(std::pair(wxColour(26, 26, 28), StateColor::Pressed),
- std::pair(wxColour(26, 26, 28), StateColor::Hovered),
- std::pair(wxColour(26, 26, 28), StateColor::Normal));
+ StateColor calc_btn_bg(std::pair(wxColour(147, 147, 150), StateColor::Pressed),
+ std::pair(wxColour(100, 100, 105), StateColor::Hovered),
+ std::pair(wxColour(100, 100, 105), StateColor::Normal));
SetBackgroundColor(calc_btn_bg);
} else {
- StateColor calc_btn_bg(std::pair(wxColour(26, 26, 28), StateColor::Pressed),
- std::pair(wxColour(26, 26, 28), StateColor::Hovered),
- std::pair(wxColour(38, 38, 41), StateColor::Normal));
+ StateColor calc_btn_bg(std::pair(wxColour(118, 118, 121), StateColor::Pressed),
+ std::pair(wxColour(76, 76, 80), StateColor::Hovered),
+ std::pair(wxColour(67, 67, 71), StateColor::Normal));
SetBackgroundColor(calc_btn_bg);
}
Refresh();
@@ -250,7 +258,7 @@ void DeviceButton::render(wxDC &dc)
wxString m_name_text = wxString::FromUTF8(tempName_string);
if (GetLabel() == "") {
- dc.DrawBitmap(icon.get_bitmap(), rcContent.x/2+1, rcContent.y/2);
+ dc.DrawBitmap(icon.get_bitmap(), rcContent.x/2+1, rcContent.y/2-2); //y3
}
// y2
else if (m_ip_text == "" && m_name_text == "") {
diff --git a/src/slic3r/GUI/Widgets/DeviceButton.hpp b/src/slic3r/GUI/Widgets/DeviceButton.hpp
index 4c53801..2ed233e 100644
--- a/src/slic3r/GUI/Widgets/DeviceButton.hpp
+++ b/src/slic3r/GUI/Widgets/DeviceButton.hpp
@@ -31,6 +31,8 @@ public:
wxSize iconSize = wxSize(16, 16),
wxString name_text = "",
wxString ip_text = "");
+ //y3
+ DeviceButton(wxWindow *parent, wxString icon, long style);
bool Create(wxWindow* parent, wxString text, wxString icon = "", long style = 0, wxSize iconSize = wxSize(16, 16));
diff --git a/src/slic3r/GUI/Widgets/SwitchButton.cpp b/src/slic3r/GUI/Widgets/SwitchButton.cpp
index 7e6b83e..625816a 100644
--- a/src/slic3r/GUI/Widgets/SwitchButton.cpp
+++ b/src/slic3r/GUI/Widgets/SwitchButton.cpp
@@ -85,9 +85,10 @@ void SwitchButton::Rescale()
//thumbSize.x += BS * 12 *10;
//thumbSize.y += BS * 6;
thumbSize.x = m_size/2;
- thumbSize.y = 25;
+ //y3
+ thumbSize.y = 30;
trackSize.x = m_size;
- trackSize.y = 30;
+ trackSize.y = 35;
auto maxWidth = GetMaxWidth();
#ifdef __WXOSX__
@@ -105,7 +106,7 @@ void SwitchButton::Rescale()
memdc.SetBackground(wxBrush(GetBackgroundColour()));
memdc.Clear();
//memdc.SetFont(dc.GetFont());
- memdc.SetFont(wxFont(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
+ memdc.SetFont(wxFont(14, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
auto state = i == 0 ? StateColor::Enabled : (StateColor::Checked | StateColor::Enabled);
{
#ifdef __WXMSW__
@@ -119,18 +120,19 @@ void SwitchButton::Rescale()
dc2.SetBrush(wxBrush(track_color.colorForStates(state)));
dc2.SetPen(wxPen(track_color.colorForStates(state)));
dc2.DrawRectangle(wxRect({i == 0 ? BS : (trackSize.x - thumbSize.x - BS), BS}, thumbSize));
-
- dc2.SetPen(wxPen(thumb_color.colorForStates(StateColor::Checked | StateColor::Enabled)));
- //dc2.DrawLine(i == 0 ? 2 * BS + (thumbSize.x - textSize[0].x) / 2 :
- // trackSize.x - thumbSize.x + (thumbSize.x - textSize[1].x) / 2,
- // thumbSize.y, i == 0 ? thumbSize.x / 2 + textSize[0].x : trackSize.x - thumbSize.x / 2 - 2 * BS + textSize[1].x,
- // thumbSize.y);
+ //y3
+ dc2.SetPen(wxPen(thumb_color.colorForStates(StateColor::Checked | StateColor::Enabled), 3));
+ dc2.DrawLine(i == 0 ? 1 : trackSize.x / 2 + 2 * BS, thumbSize.y - 1, i == 0 ? trackSize.x / 2 - 2 * BS : trackSize.x,
+ thumbSize.y - 1);
+ dc2.SetPen(wxPen(wxColour(66, 66, 69), 1));
+ dc2.DrawLine(trackSize.x / 2, 1, trackSize.x / 2, thumbSize.y - 1);
+ dc2.DrawLine(0, thumbSize.y, trackSize.x, thumbSize.y);
}
memdc.SetTextForeground(text_color.colorForStates(state ^ StateColor::Checked));
- memdc.DrawText(labels[0], {BS + (thumbSize.x - textSize[0].x) / 2, BS + (thumbSize.y - textSize[0].y) / 2});
+ memdc.DrawText(labels[0], {BS + (thumbSize.x - textSize[0].x) / 2 - 7, BS + (thumbSize.y - textSize[0].y) / 2 - 4 * BS});
memdc.SetTextForeground(text_color.colorForStates(state));
- memdc.DrawText(labels[1], {trackSize.x - thumbSize.x - BS + (thumbSize.x - textSize[1].x) / 2, BS + (thumbSize.y - textSize[1].y) / 2});
+ memdc.DrawText(labels[1], {trackSize.x - thumbSize.x - BS + (thumbSize.x - textSize[1].x) / 2 - 4, BS + (thumbSize.y - textSize[1].y) / 2 - 4 * BS});
//memdc.SetPen(wxPen(wxColour(68, 121, 251)));
// if (!GetValue())