mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-01-30 23:48:44 +03:00
print_host
This commit is contained in:
@@ -59,6 +59,8 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <wx/regex.h>
|
#include <wx/regex.h>
|
||||||
|
|
||||||
|
//B55
|
||||||
|
#include "../Utils/PrintHost.hpp"
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
@@ -2147,16 +2149,6 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
|||||||
if (isValidIPAddress) {
|
if (isValidIPAddress) {
|
||||||
m_printer_view->AddButton(
|
m_printer_view->AddButton(
|
||||||
printer_name, host, (data->model_id), (data->fullname),
|
printer_name, host, (data->model_id), (data->fullname),
|
||||||
[host, this](wxMouseEvent &event) {
|
|
||||||
//B55
|
|
||||||
wxString formattedHost = host;
|
|
||||||
//wxString formattedHost = wxString::Format("http://%s", host);
|
|
||||||
if (!host.Lower().starts_with("http"))
|
|
||||||
formattedHost = wxString::Format("http://%s", host);
|
|
||||||
//if (!formattedHost.Lower().ends_with("10088"))
|
|
||||||
// formattedHost = wxString::Format("%s:10088", formattedHost);
|
|
||||||
this->m_printer_view->load_url(formattedHost);
|
|
||||||
},
|
|
||||||
(data->selected), cfg_t);
|
(data->selected), cfg_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2177,14 +2169,18 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
|||||||
if (host.empty()) {
|
if (host.empty()) {
|
||||||
tem_host = "";
|
tem_host = "";
|
||||||
host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
|
host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
|
||||||
}
|
} else {
|
||||||
//B55
|
//B55
|
||||||
else {
|
const auto opt = cfg->option<ConfigOptionEnum<PrintHostType>>("host_type");
|
||||||
|
const auto host_type = opt != nullptr ? opt->value : htOctoPrint;
|
||||||
if (!host.Lower().starts_with("http"))
|
if (!host.Lower().starts_with("http"))
|
||||||
host = wxString::Format("http://%s", host);
|
host = wxString::Format("http://%s", host);
|
||||||
// if (!host.Lower().ends_with("10088"))
|
if (host_type == htMoonraker) {
|
||||||
// host = wxString::Format("%s:10088", host);
|
if (!host.Lower().ends_with("10088"))
|
||||||
|
host = wxString::Format("%s:10088", host);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//B55
|
||||||
if (tem_host != host) {
|
if (tem_host != host) {
|
||||||
//B45
|
//B45
|
||||||
m_printer_view->load_url(host);
|
m_printer_view->load_url(host);
|
||||||
|
|||||||
@@ -747,14 +747,6 @@ void PhysicalPrinterDialog::OnOK(wxEvent& event)
|
|||||||
Field * printhost_field = m_optgroup->get_field("print_host");
|
Field * printhost_field = m_optgroup->get_field("print_host");
|
||||||
text_ctrl *printhost_win = printhost_field ? dynamic_cast<text_ctrl *>(printhost_field->getWindow()) : nullptr;
|
text_ctrl *printhost_win = printhost_field ? dynamic_cast<text_ctrl *>(printhost_field->getWindow()) : nullptr;
|
||||||
wxString temp_host = printhost_win->GetValue();
|
wxString temp_host = printhost_win->GetValue();
|
||||||
//B55
|
|
||||||
wxString formattedHost = temp_host;
|
|
||||||
/* if (!temp_host.Lower().starts_with("http"))
|
|
||||||
wxString formattedHost = wxString::Format("http://%s", temp_host);*/
|
|
||||||
if (!formattedHost.Lower().ends_with("10088"))
|
|
||||||
formattedHost = wxString::Format("%s:10088", formattedHost);
|
|
||||||
m_optgroup->set_value("print_host", formattedHost, true);
|
|
||||||
m_optgroup->get_field("print_host")->field_changed();
|
|
||||||
}
|
}
|
||||||
if (opt->value == htQIDIConnect) {
|
if (opt->value == htQIDIConnect) {
|
||||||
if (printhost_win && printhost_win->GetValue() != L"https://connect.qidi3d.com"){
|
if (printhost_win && printhost_win->GetValue() != L"https://connect.qidi3d.com"){
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
#include <wx/regex.h>
|
#include <wx/regex.h>
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
#include <wx/graphics.h>
|
#include <wx/graphics.h>
|
||||||
|
//B55
|
||||||
|
#include "../Utils/PrintHost.hpp"
|
||||||
namespace pt = boost::property_tree;
|
namespace pt = boost::property_tree;
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
@@ -331,11 +333,11 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//B55
|
||||||
void PrinterWebView::AddButton(const wxString & device_name,
|
void PrinterWebView::AddButton(const wxString & device_name,
|
||||||
const wxString & ip,
|
const wxString & ip,
|
||||||
const wxString & machine_type,
|
const wxString & machine_type,
|
||||||
const wxString & fullname,
|
const wxString & fullname,
|
||||||
const std::function<void(wxMouseEvent &)> &handler,
|
|
||||||
bool isSelected,
|
bool isSelected,
|
||||||
DynamicPrintConfig * cfg_t)
|
DynamicPrintConfig * cfg_t)
|
||||||
{
|
{
|
||||||
@@ -356,16 +358,28 @@ void PrinterWebView::AddButton(const wxString & devi
|
|||||||
customButton->SetIPText(ip);
|
customButton->SetIPText(ip);
|
||||||
customButton->SetStateText("standby");
|
customButton->SetStateText("standby");
|
||||||
customButton->SetProgressText("(0%)");
|
customButton->SetProgressText("(0%)");
|
||||||
customButton->SetClickHandler(handler);
|
const auto opt = cfg_t->option<ConfigOptionEnum<PrintHostType>>("host_type");
|
||||||
//customButton->Bind(wxEVT_BUTTON, std::bind(&PrinterWebView::OnCustomButtonClick, this,handler));
|
const auto host_type = opt != nullptr ? opt->value : htOctoPrint;
|
||||||
customButton->Bind(wxEVT_BUTTON, [this, ip, customButton](wxCommandEvent &event) {
|
wxString formattedHost = ip;
|
||||||
wxString host = ip;
|
if (!formattedHost.Lower().starts_with("http"))
|
||||||
|
formattedHost = wxString::Format("http://%s", formattedHost);
|
||||||
|
if (host_type == htMoonraker) {
|
||||||
|
if (!formattedHost.Lower().ends_with("10088"))
|
||||||
|
formattedHost = wxString::Format("%s:10088", formattedHost);
|
||||||
|
}
|
||||||
|
|
||||||
|
customButton->Bind(wxEVT_BUTTON, [this, ip, customButton, cfg_t](wxCommandEvent &event) {
|
||||||
//B55
|
//B55
|
||||||
if (!host.Lower().starts_with("http"))
|
const auto opt = cfg_t->option<ConfigOptionEnum<PrintHostType>>("host_type");
|
||||||
host = wxString::Format("http://%s", host);
|
const auto host_type = opt != nullptr ? opt->value : htOctoPrint;
|
||||||
// if (!host.Lower().ends_with("10088"))
|
wxString formattedHost = ip;
|
||||||
// host = wxString::Format("%s:10088", host);
|
if (!formattedHost.Lower().starts_with("http"))
|
||||||
load_url(host);
|
formattedHost = wxString::Format("http://%s", formattedHost);
|
||||||
|
if (host_type == htMoonraker) {
|
||||||
|
if (!formattedHost.Lower().ends_with("10088"))
|
||||||
|
formattedHost = wxString::Format("%s:10088", formattedHost);
|
||||||
|
}
|
||||||
|
load_url(formattedHost);
|
||||||
customButton->ResumeStatusThread();
|
customButton->ResumeStatusThread();
|
||||||
});
|
});
|
||||||
#if defined(__WIN32__) || defined(__WXMAC__)
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
@@ -391,7 +405,6 @@ void PrinterWebView::AddButton(const wxString & devi
|
|||||||
//B45
|
//B45
|
||||||
void PrinterWebView::PauseButton()
|
void PrinterWebView::PauseButton()
|
||||||
{
|
{
|
||||||
//BOOST_LOG_TRIVIAL(error) << " Pause";
|
|
||||||
|
|
||||||
if (m_buttons.empty()) {
|
if (m_buttons.empty()) {
|
||||||
BOOST_LOG_TRIVIAL(info) << " empty";
|
BOOST_LOG_TRIVIAL(info) << " empty";
|
||||||
@@ -404,7 +417,6 @@ void PrinterWebView::AddButton(const wxString & devi
|
|||||||
//B45
|
//B45
|
||||||
void PrinterWebView::ResumeButton()
|
void PrinterWebView::ResumeButton()
|
||||||
{
|
{
|
||||||
//BOOST_LOG_TRIVIAL(error) << " Resume";
|
|
||||||
|
|
||||||
if (m_buttons.empty()) {
|
if (m_buttons.empty()) {
|
||||||
BOOST_LOG_TRIVIAL(info) << " empty";
|
BOOST_LOG_TRIVIAL(info) << " empty";
|
||||||
@@ -418,7 +430,6 @@ void PrinterWebView::AddButton(const wxString & devi
|
|||||||
//B45
|
//B45
|
||||||
void PrinterWebView::StopAllThread()
|
void PrinterWebView::StopAllThread()
|
||||||
{
|
{
|
||||||
// BOOST_LOG_TRIVIAL(error) << " Stop";
|
|
||||||
|
|
||||||
if (m_buttons.empty()) {
|
if (m_buttons.empty()) {
|
||||||
BOOST_LOG_TRIVIAL(info) << " empty";
|
BOOST_LOG_TRIVIAL(info) << " empty";
|
||||||
@@ -432,7 +443,6 @@ void PrinterWebView::AddButton(const wxString & devi
|
|||||||
//B45
|
//B45
|
||||||
void PrinterWebView::UnSelectedButton()
|
void PrinterWebView::UnSelectedButton()
|
||||||
{
|
{
|
||||||
// BOOST_LOG_TRIVIAL(error) << " Resume";
|
|
||||||
|
|
||||||
if (m_buttons.empty()) {
|
if (m_buttons.empty()) {
|
||||||
BOOST_LOG_TRIVIAL(info) << " empty";
|
BOOST_LOG_TRIVIAL(info) << " empty";
|
||||||
@@ -529,6 +539,7 @@ void PrinterWebView::OnRightButtonClick(wxCommandEvent &event)
|
|||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//B55
|
||||||
void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
|
void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
PhysicalPrinterDialog dlg(this->GetParent(), wxEmptyString);
|
PhysicalPrinterDialog dlg(this->GetParent(), wxEmptyString);
|
||||||
@@ -541,13 +552,6 @@ void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
|
|||||||
std::string printer_name = printer.name;
|
std::string printer_name = printer.name;
|
||||||
wxString host = printer.config.opt_string("print_host");
|
wxString host = printer.config.opt_string("print_host");
|
||||||
|
|
||||||
//B55
|
|
||||||
wxString formattedHost = host;
|
|
||||||
// wxString formattedHost = wxString::Format("http://%s", host);
|
|
||||||
if (!host.Lower().starts_with("http"))
|
|
||||||
wxString formattedHost = wxString::Format("http://%s", host);
|
|
||||||
// if (!formattedHost.Lower().ends_with("10088"))
|
|
||||||
// formattedHost = wxString::Format("%s:10088", formattedHost);
|
|
||||||
|
|
||||||
std::string fullname = preset_bundle.physical_printers.get_selected_full_printer_name();
|
std::string fullname = preset_bundle.physical_printers.get_selected_full_printer_name();
|
||||||
std::string preset_name = printer.get_preset_name(fullname);
|
std::string preset_name = printer.get_preset_name(fullname);
|
||||||
@@ -565,14 +569,19 @@ void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
|
|||||||
bool isValidIPAddress = true;
|
bool isValidIPAddress = true;
|
||||||
DynamicPrintConfig *cfg_t = &(printer.config);
|
DynamicPrintConfig *cfg_t = &(printer.config);
|
||||||
|
|
||||||
|
const auto opt = cfg_t->option<ConfigOptionEnum<PrintHostType>>("host_type");
|
||||||
|
const auto host_type = opt != nullptr ? opt->value : htOctoPrint;
|
||||||
|
wxString formattedHost = host;
|
||||||
|
if (!formattedHost.Lower().starts_with("http"))
|
||||||
|
formattedHost = wxString::Format("http://%s", formattedHost);
|
||||||
|
if (host_type == htMoonraker) {
|
||||||
|
if (!formattedHost.Lower().ends_with("10088"))
|
||||||
|
formattedHost = wxString::Format("%s:10088", formattedHost);
|
||||||
|
}
|
||||||
UnSelectedButton();
|
UnSelectedButton();
|
||||||
if (isValidIPAddress)
|
if (isValidIPAddress)
|
||||||
AddButton(
|
AddButton(
|
||||||
printer_name, host, model_id, fullname,
|
printer_name, host, model_id, fullname,
|
||||||
[formattedHost, this](wxMouseEvent &event) {
|
|
||||||
wxString host = formattedHost;
|
|
||||||
load_url(host);
|
|
||||||
},
|
|
||||||
true, cfg_t);
|
true, cfg_t);
|
||||||
load_url(formattedHost);
|
load_url(formattedHost);
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
@@ -765,8 +774,10 @@ void PrinterWebView::load_url(wxString& url)
|
|||||||
m_browser->LoadURL(url);
|
m_browser->LoadURL(url);
|
||||||
|
|
||||||
//B55
|
//B55
|
||||||
|
if (url.Lower().starts_with("http"))
|
||||||
url.Remove(0, 7);
|
url.Remove(0, 7);
|
||||||
//url.Remove(url.length() - 6);
|
if (url.Lower().ends_with("10088"))
|
||||||
|
url.Remove(url.length() - 6);
|
||||||
for (MachineListButton *button : m_buttons) {
|
for (MachineListButton *button : m_buttons) {
|
||||||
if (url == (button->getIPLabel()))
|
if (url == (button->getIPLabel()))
|
||||||
button->SetSelect(true);
|
button->SetSelect(true);
|
||||||
|
|||||||
@@ -257,11 +257,11 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
//void SendRecentList(int images);
|
//void SendRecentList(int images);
|
||||||
void SetButtons(std::vector<MachineListButton *> buttons);
|
void SetButtons(std::vector<MachineListButton *> buttons);
|
||||||
|
//B55
|
||||||
void AddButton(const wxString & device_name,
|
void AddButton(const wxString & device_name,
|
||||||
const wxString & ip,
|
const wxString & ip,
|
||||||
const wxString & machine_type,
|
const wxString & machine_type,
|
||||||
const wxString & fullname,
|
const wxString & fullname,
|
||||||
const std::function<void(wxMouseEvent &)> &handler,
|
|
||||||
bool isSelected,
|
bool isSelected,
|
||||||
DynamicPrintConfig * cfg_t);
|
DynamicPrintConfig * cfg_t);
|
||||||
void DeleteButton();
|
void DeleteButton();
|
||||||
|
|||||||
Reference in New Issue
Block a user