mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-01-30 23:48:44 +03:00
Device_Machine_List_Button
This commit is contained in:
6
resources/icons/add_machine_list.svg
Normal file
6
resources/icons/add_machine_list.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
|
||||||
|
<path fill="#4EC256" d="M11,11V5h2v6h6v2h-6v6h-2v-6H5v-2H11z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 437 B |
6
resources/icons/delete_machine_list.svg
Normal file
6
resources/icons/delete_machine_list.svg
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
|
||||||
|
<path fill="#FC5151" d="M5,13v-2h14v2H5z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 417 B |
7
resources/icons/edit_machine_list.svg
Normal file
7
resources/icons/edit_machine_list.svg
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
width="24px" height="24px" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
|
||||||
|
<path fill="#ADADAF" d="M16.8,3l-2,2H5v14h14V9.2l2-2V20c0,0.6-0.4,1-1,1H4c-0.6,0-1-0.4-1-1V4c0-0.6,0.4-1,1-1H16.8z M20.5,2.1
|
||||||
|
l1.4,1.4l-9.2,9.2l-1.4,0l0-1.4L20.5,2.1z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 543 B |
@@ -57,6 +57,7 @@
|
|||||||
|
|
||||||
//B45
|
//B45
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <wx/regex.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
@@ -897,6 +898,30 @@ void MainFrame::create_preset_tabs()
|
|||||||
#endif
|
#endif
|
||||||
m_tabpanel->AddPage(m_guide_view, _L("Guide"));
|
m_tabpanel->AddPage(m_guide_view, _L("Guide"));
|
||||||
//B45
|
//B45
|
||||||
|
m_printer_view->SetUpdateHandler([this](wxCommandEvent &event) {
|
||||||
|
wxGetApp().get_tab(Preset::TYPE_PRINTER)->update_preset_choice();
|
||||||
|
wxGetApp().get_tab(Preset::TYPE_PRINTER)->update_btns_enabling();
|
||||||
|
wxGetApp().plater()->sidebar().update_presets(Preset::TYPE_PRINTER);
|
||||||
|
});
|
||||||
|
|
||||||
|
m_printer_view->SetDeleteHandler([this](wxCommandEvent &event) {
|
||||||
|
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
||||||
|
|
||||||
|
const std::string &printer_name = preset_bundle.physical_printers.get_selected_full_printer_name();
|
||||||
|
if (printer_name.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
//if (!note_string.IsEmpty())
|
||||||
|
// msg += note_string + "\n";
|
||||||
|
msg += format_wxstr(_L("Are you sure you want to delete \"%1%\" printer?"), printer_name);
|
||||||
|
|
||||||
|
if (MessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() != wxID_YES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
preset_bundle.physical_printers.delete_selected_printer();
|
||||||
|
});
|
||||||
|
|
||||||
// #if defined(__WIN32__)
|
// #if defined(__WIN32__)
|
||||||
// m_tabpanel->Bind(wxCUSTOMEVT_NOTEBOOK_SEL_CHANGED, &MainFrame::OnTabPanelSelectionChanged, this);
|
// m_tabpanel->Bind(wxCUSTOMEVT_NOTEBOOK_SEL_CHANGED, &MainFrame::OnTabPanelSelectionChanged, this);
|
||||||
// #endif
|
// #endif
|
||||||
@@ -2142,8 +2167,8 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
|||||||
struct PhysicalPrinterPresetData
|
struct PhysicalPrinterPresetData
|
||||||
{
|
{
|
||||||
wxString lower_name; // just for sorting
|
wxString lower_name; // just for sorting
|
||||||
std::string name; // preset_name
|
wxString name; // preset_name
|
||||||
std::string fullname; // full name
|
wxString fullname; // full name
|
||||||
bool selected; // is selected
|
bool selected; // is selected
|
||||||
};
|
};
|
||||||
std::vector<PhysicalPrinterPresetData> preset_data;
|
std::vector<PhysicalPrinterPresetData> preset_data;
|
||||||
@@ -2191,11 +2216,12 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const PhysicalPrinterPresetData *data : missingPresets) {
|
for (const PhysicalPrinterPresetData *data : missingPresets) {
|
||||||
Preset *preset = m_collection->find_preset(data->name);
|
|
||||||
|
Preset *preset = m_collection->find_preset((data->name).ToStdString());
|
||||||
if (!preset || !preset->is_visible)
|
if (!preset || !preset->is_visible)
|
||||||
continue;
|
continue;
|
||||||
wxStringTokenizer tokenizer((data->fullname), " ");
|
wxStringTokenizer tokenizer((data->fullname), "*");
|
||||||
auto *printer = preset_bundle.physical_printers.find_printer(std::string(tokenizer.GetNextToken().mb_str()));
|
auto * printer = preset_bundle.physical_printers.find_printer(std::string(tokenizer.GetNextToken().Trim().mb_str()));
|
||||||
wxString host = (printer->config.opt_string("print_host"));
|
wxString host = (printer->config.opt_string("print_host"));
|
||||||
|
|
||||||
std::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
|
std::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
|
||||||
@@ -2204,9 +2230,15 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
|
|||||||
wxString machine_type = tokenizer2.GetNextToken();
|
wxString machine_type = tokenizer2.GetNextToken();
|
||||||
machine_type += " "+ tokenizer2.GetNextToken();
|
machine_type += " "+ tokenizer2.GetNextToken();
|
||||||
DynamicPrintConfig *cfg_t = &(printer->config);
|
DynamicPrintConfig *cfg_t = &(printer->config);
|
||||||
|
|
||||||
|
wxStringTokenizer tokenizer3((data->lower_name), wxT("*"), wxTOKEN_RET_EMPTY_ALL);
|
||||||
|
wxString printer_name = tokenizer3.GetNextToken();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isValidIPAddress) {
|
if (isValidIPAddress) {
|
||||||
m_printer_view->AddButton(
|
m_printer_view->AddButton(
|
||||||
printer->name, host, machine_type, (data->fullname),
|
printer_name, host, machine_type, (data->fullname),
|
||||||
[host, this](wxMouseEvent &event) {
|
[host, this](wxMouseEvent &event) {
|
||||||
wxString formattedHost = wxString::Format("http://%s", host);
|
wxString formattedHost = wxString::Format("http://%s", host);
|
||||||
if (!host.Lower().starts_with("http"))
|
if (!host.Lower().starts_with("http"))
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ public:
|
|||||||
void select_tab(Tab* tab);
|
void select_tab(Tab* tab);
|
||||||
void select_tab(size_t tab = size_t(-1));
|
void select_tab(size_t tab = size_t(-1));
|
||||||
//B45
|
//B45
|
||||||
void OnTabPanelSelectionChanged(wxCommandEvent &event);
|
//void OnTabPanelSelectionChanged(wxCommandEvent &event);
|
||||||
|
|
||||||
void select_view(const std::string& direction);
|
void select_view(const std::string& direction);
|
||||||
// Propagate changed configuration from the Tab to the Plater and save changes to the AppConfig
|
// Propagate changed configuration from the Tab to the Plater and save changes to the AppConfig
|
||||||
|
|||||||
@@ -12,13 +12,16 @@
|
|||||||
|
|
||||||
#include <slic3r/GUI/Widgets/WebView.hpp>
|
#include <slic3r/GUI/Widgets/WebView.hpp>
|
||||||
|
|
||||||
|
#include "PhysicalPrinterDialog.hpp"
|
||||||
|
//B45
|
||||||
|
#include <wx/regex.h>
|
||||||
|
|
||||||
namespace pt = boost::property_tree;
|
namespace pt = boost::property_tree;
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(MachineListButton, wxButton) EVT_PAINT(MachineListButton::OnPaint) EVT_ENTER_WINDOW(MachineListButton::OnMouseEnter)
|
wxBEGIN_EVENT_TABLE(MachineListButton, wxButton) EVT_PAINT(MachineListButton::OnPaint) EVT_ENTER_WINDOW(MachineListButton::OnMouseEnter)
|
||||||
EVT_LEAVE_WINDOW(MachineListButton::OnMouseLeave) EVT_LEFT_DOWN(MachineListButton::OnMouseLeftDown) EVT_LEFT_UP(MachineListButton::OnMouseLeftUp)
|
EVT_LEAVE_WINDOW(MachineListButton::OnMouseLeave) EVT_LEFT_DOWN(MachineListButton::OnMouseLeftDown) EVT_LEFT_UP(MachineListButton::OnMouseLeftUp)
|
||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
@@ -123,16 +126,46 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
|
|
||||||
titlesizer->Add(text_static, wxSizerFlags().Align(wxALIGN_LEFT).Border(wxALL, 5));
|
titlesizer->Add(text_static, wxSizerFlags().Align(wxALIGN_LEFT).Border(wxALL, 5));
|
||||||
titlesizer->AddStretchSpacer();
|
titlesizer->AddStretchSpacer();
|
||||||
|
wxBoxSizer *buttonsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
//wxBU_EXACTFIT wxBORDER_NONE
|
//wxBU_EXACTFIT wxBORDER_NONE
|
||||||
#if defined(__WIN32__) || defined(__WXMAC__)
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
|
wxButton *add_button = new wxButton(leftScrolledWindow, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
|
add_button->SetBackgroundColour(wxColour(100, 100, 105));
|
||||||
|
//add_button->SetForegroundColour(leftScrolledWindow->GetBackgroundColour());
|
||||||
|
|
||||||
|
add_button->SetMinSize(wxSize(40, -1));
|
||||||
|
add_button->SetBitmap(*get_bmp_bundle("add_machine_list", 20));
|
||||||
|
buttonsizer->Add(add_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
|
add_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnAddButtonClick, this);
|
||||||
|
|
||||||
|
|
||||||
|
wxButton *delete_button = new wxButton(leftScrolledWindow, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
|
delete_button->SetBackgroundColour(wxColour(100, 100, 105));
|
||||||
|
//delete_button->SetForegroundColour(leftScrolledWindow->GetBackgroundColour());
|
||||||
|
|
||||||
|
delete_button->SetMinSize(wxSize(40, -1));
|
||||||
|
delete_button->SetBitmap(*get_bmp_bundle("delete_machine_list", 20));
|
||||||
|
buttonsizer->Add(delete_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
|
delete_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnDeleteButtonClick, this);
|
||||||
|
|
||||||
|
wxButton *edit_button = new wxButton(leftScrolledWindow, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
|
edit_button->SetBackgroundColour(wxColour(100, 100, 105));
|
||||||
|
//edit_button->SetForegroundColour(leftScrolledWindow->GetBackgroundColour());
|
||||||
|
|
||||||
|
edit_button->SetMinSize(wxSize(40, -1));
|
||||||
|
edit_button->SetBitmap(*get_bmp_bundle("edit_machine_list", 20));
|
||||||
|
buttonsizer->Add(edit_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
|
edit_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnEditButtonClick, this);
|
||||||
|
|
||||||
|
|
||||||
wxButton *refresh_button = new wxButton(leftScrolledWindow, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
wxButton *refresh_button = new wxButton(leftScrolledWindow, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
refresh_button->SetBackgroundColour(leftScrolledWindow->GetBackgroundColour());
|
refresh_button->SetBackgroundColour(wxColour(100, 100, 105));
|
||||||
refresh_button->SetForegroundColour(leftScrolledWindow->GetBackgroundColour());
|
//refresh_button->SetForegroundColour(leftScrolledWindow->GetBackgroundColour());
|
||||||
|
|
||||||
refresh_button->SetMinSize(wxSize(40, -1));
|
refresh_button->SetMinSize(wxSize(40, -1));
|
||||||
refresh_button->SetBitmap(*get_bmp_bundle("refresh-line", 20));
|
refresh_button->SetBitmap(*get_bmp_bundle("refresh-line", 20));
|
||||||
//leftsizer->Add(button2, wxSizerFlags().Align(wxALIGN_RIGHT).Border(wxALL, 2));
|
buttonsizer->Add(refresh_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
titlesizer->Add(refresh_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
|
||||||
refresh_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnRightButtonClick, this);
|
refresh_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnRightButtonClick, this);
|
||||||
|
|
||||||
arrow_button = new wxButton(leftScrolledWindow, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
arrow_button = new wxButton(leftScrolledWindow, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
@@ -141,21 +174,22 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
arrow_button->SetForegroundColour(leftScrolledWindow->GetBackgroundColour());
|
arrow_button->SetForegroundColour(leftScrolledWindow->GetBackgroundColour());
|
||||||
arrow_button->SetMinSize(wxSize(40, -1));
|
arrow_button->SetMinSize(wxSize(40, -1));
|
||||||
arrow_button->SetBitmap(*get_bmp_bundle("arrow-left-s-line", 20));
|
arrow_button->SetBitmap(*get_bmp_bundle("arrow-left-s-line", 20));
|
||||||
// leftsizer->Add(arrow_button, wxSizerFlags().Align(wxALIGN_RIGHT | wxALIGN_TOP).Border(wxALL, 2));
|
|
||||||
titlesizer->Add(arrow_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
titlesizer->Add(arrow_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
arrow_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnLeftButtonClick, this);
|
arrow_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnLeftButtonClick, this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
titlesizer->Layout();
|
titlesizer->Layout();
|
||||||
|
buttonsizer->Layout();
|
||||||
|
|
||||||
leftsizer->Add(titlesizer, wxSizerFlags().Expand().Align(wxALIGN_TOP).Border(wxALL, 0));
|
leftsizer->Add(titlesizer, wxSizerFlags().Expand().Align(wxALIGN_TOP).Border(wxALL, 0));
|
||||||
|
leftsizer->Add(buttonsizer, wxSizerFlags().Expand().Align(wxALIGN_TOP).Border(wxALL, 0));
|
||||||
|
|
||||||
leftsizer->Layout();
|
leftsizer->Layout();
|
||||||
|
|
||||||
leftScrolledWindow->SetSizer(leftsizer);
|
leftScrolledWindow->SetSizer(leftsizer);
|
||||||
leftScrolledWindow->SetScrollRate(10, 10);
|
leftScrolledWindow->SetScrollRate(10, 10);
|
||||||
leftScrolledWindow->SetMinSize(wxSize(leftsizerWidth, -1));
|
leftScrolledWindow->SetMinSize(wxSize(leftsizerWidth, -1));
|
||||||
leftScrolledWindow->FitInside();
|
leftScrolledWindow->FitInside();
|
||||||
|
|
||||||
m_browser = WebView::CreateWebView(this, "");
|
m_browser = WebView::CreateWebView(this, "");
|
||||||
if (m_browser == nullptr) {
|
if (m_browser == nullptr) {
|
||||||
wxLogError("Could not init m_browser");
|
wxLogError("Could not init m_browser");
|
||||||
@@ -163,6 +197,7 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetSizer(topsizer);
|
SetSizer(topsizer);
|
||||||
|
|
||||||
topsizer->Add(leftScrolledWindow, wxSizerFlags(0).Expand());
|
topsizer->Add(leftScrolledWindow, wxSizerFlags(0).Expand());
|
||||||
topsizer->Add(m_browser, wxSizerFlags(1).Expand().Border(wxALL, 0));
|
topsizer->Add(m_browser, wxSizerFlags(1).Expand().Border(wxALL, 0));
|
||||||
|
|
||||||
@@ -257,6 +292,22 @@ void PrinterWebView::AddButton(const wxString & devi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// B45
|
||||||
|
void PrinterWebView::UnSelectedButton()
|
||||||
|
{
|
||||||
|
// BOOST_LOG_TRIVIAL(error) << " Resume";
|
||||||
|
|
||||||
|
if (m_buttons.empty()) {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << " empty";
|
||||||
|
} else {
|
||||||
|
for (MachineListButton *button : m_buttons) {
|
||||||
|
button->SetSelect(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//B45
|
//B45
|
||||||
void PrinterWebView::DeleteButton()
|
void PrinterWebView::DeleteButton()
|
||||||
{
|
{
|
||||||
@@ -328,6 +379,147 @@ void PrinterWebView::OnRightButtonClick(wxCommandEvent &event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
|
||||||
|
{
|
||||||
|
PhysicalPrinterDialog dlg(this->GetParent(), wxEmptyString);
|
||||||
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
|
if (m_handlerl) {
|
||||||
|
m_handlerl(event);
|
||||||
|
}
|
||||||
|
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
||||||
|
auto printer = preset_bundle.physical_printers.get_selected_printer();
|
||||||
|
std::string printer_name = printer.name;
|
||||||
|
wxString host = printer.config.opt_string("print_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::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
|
||||||
|
bool isValidIPAddress = std::regex_match(host.ToStdString(), ipRegex);
|
||||||
|
wxString machine_type = "X-MAX 3";
|
||||||
|
DynamicPrintConfig *cfg_t = &(printer.config);
|
||||||
|
std::regex regex1("\\*\\s(.*)(?=\\snozzle)");
|
||||||
|
|
||||||
|
std::smatch match;
|
||||||
|
|
||||||
|
if (std::regex_search(fullname, match, regex1)) {
|
||||||
|
std::string regexmatch = match.str(0);
|
||||||
|
std::regex regex2("(X-\\w+\\s\\d)");
|
||||||
|
if (std::regex_search(regexmatch, match, regex2))
|
||||||
|
machine_type = match.str(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
UnSelectedButton();
|
||||||
|
if (isValidIPAddress)
|
||||||
|
AddButton(
|
||||||
|
printer_name, host, machine_type, fullname,
|
||||||
|
[formattedHost, this](wxMouseEvent &event) {
|
||||||
|
wxString host = formattedHost;
|
||||||
|
load_url(host);
|
||||||
|
},
|
||||||
|
true, cfg_t);
|
||||||
|
load_url(formattedHost);
|
||||||
|
UpdateLayout();
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrinterWebView::OnDeleteButtonClick(wxCommandEvent &event) {
|
||||||
|
|
||||||
|
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
||||||
|
for (MachineListButton *button : m_buttons) {
|
||||||
|
if ((button->GetSelected())) {
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
//if (!note_string.IsEmpty())
|
||||||
|
// msg += note_string + "\n";
|
||||||
|
msg += format_wxstr(_L("Are you sure you want to delete \"%1%\" printer?"), (button->getLabel()));
|
||||||
|
|
||||||
|
if (MessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() != wxID_YES)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
button->StopStatusThread();
|
||||||
|
|
||||||
|
preset_bundle.physical_printers.delete_printer(std::string((button->GetNameText()).ToStdString()));
|
||||||
|
|
||||||
|
auto it = std::find(m_buttons.begin(), m_buttons.end(), button);
|
||||||
|
delete button;
|
||||||
|
|
||||||
|
if (it != m_buttons.end()) {
|
||||||
|
m_buttons.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
leftsizer->Detach(button);
|
||||||
|
for (MachineListButton *button : m_buttons) {
|
||||||
|
button->SetSelect(true);
|
||||||
|
wxString formattedHost = wxString::Format("http://%s:10088", button->getIPLabel());
|
||||||
|
|
||||||
|
load_url(formattedHost);
|
||||||
|
preset_bundle.physical_printers.select_printer((button->getLabel()).ToStdString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
UpdateLayout();
|
||||||
|
Refresh();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_handlerl) {
|
||||||
|
m_handlerl(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrinterWebView::OnEditButtonClick(wxCommandEvent &event) {
|
||||||
|
for (MachineListButton *button : m_buttons) {
|
||||||
|
if ((button->GetSelected())) {
|
||||||
|
PhysicalPrinterDialog dlg(this->GetParent(), (wxString::FromUTF8((button->getLabel()).ToStdString())));
|
||||||
|
//BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << (button->getLabel());
|
||||||
|
|
||||||
|
//BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << wxString::FromUTF8((button->getLabel()).ToStdString());
|
||||||
|
|
||||||
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
|
if (m_handlerl) {
|
||||||
|
m_handlerl(event);
|
||||||
|
}
|
||||||
|
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
|
||||||
|
auto printer = preset_bundle.physical_printers.get_selected_printer();
|
||||||
|
std::string printer_name = printer.name;
|
||||||
|
wxString host = printer.config.opt_string("print_host");
|
||||||
|
std::string fullname = preset_bundle.physical_printers.get_selected_full_printer_name();
|
||||||
|
|
||||||
|
std::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
|
||||||
|
bool isValidIPAddress = std::regex_match(host.ToStdString(), ipRegex);
|
||||||
|
wxString machine_type = "X-MAX 3";
|
||||||
|
DynamicPrintConfig *cfg_t = &(printer.config);
|
||||||
|
std::regex regex1("\\*\\s(.*)(?=\\snozzle)");
|
||||||
|
|
||||||
|
std::smatch match;
|
||||||
|
|
||||||
|
if (std::regex_search(fullname, match, regex1)) {
|
||||||
|
std::string regexmatch = match.str(0);
|
||||||
|
std::regex regex2("(X-\\w+\\s\\d)");
|
||||||
|
if (std::regex_search(regexmatch, match, regex2))
|
||||||
|
machine_type = match.str(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
button->SetNameText((wxString::FromUTF8(printer_name)));
|
||||||
|
button->SetIPText(host);
|
||||||
|
button->SetLabel(fullname);
|
||||||
|
wxString Machine_Name = Machine_Name.Format("%s%s", machine_type, "_thumbnail");
|
||||||
|
|
||||||
|
button->SetBitMap(get_bmp_bundle(std::string(Machine_Name.mb_str()), 80)->GetBitmapFor(this));
|
||||||
|
UpdateLayout();
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//void PrinterWebView::SendRecentList(int images)
|
//void PrinterWebView::SendRecentList(int images)
|
||||||
@@ -368,6 +560,10 @@ void PrinterWebView::OnScriptMessage(wxWebViewEvent &evt)
|
|||||||
void PrinterWebView::UpdateLayout()
|
void PrinterWebView::UpdateLayout()
|
||||||
{
|
{
|
||||||
//leftScrolledWindow->SetVirtualSize(leftsizer->GetMinSize());
|
//leftScrolledWindow->SetVirtualSize(leftsizer->GetMinSize());
|
||||||
|
leftsizer->Layout();
|
||||||
|
|
||||||
|
leftScrolledWindow->Layout();
|
||||||
|
|
||||||
leftScrolledWindow->FitInside();
|
leftScrolledWindow->FitInside();
|
||||||
topsizer->Layout();
|
topsizer->Layout();
|
||||||
if (!m_buttons.empty()) {
|
if (!m_buttons.empty()) {
|
||||||
@@ -392,19 +588,26 @@ void PrinterWebView::load_url(wxString& url)
|
|||||||
// this->Raise();
|
// this->Raise();
|
||||||
if (m_browser == nullptr)
|
if (m_browser == nullptr)
|
||||||
return;
|
return;
|
||||||
|
m_browser->LoadURL(url);
|
||||||
|
|
||||||
|
url.Remove(0, 7);
|
||||||
|
url.Remove(url.length() - 6);
|
||||||
for (MachineListButton *button : m_buttons) {
|
for (MachineListButton *button : m_buttons) {
|
||||||
|
|
||||||
size_t pos = url.Find((button->getIPLabel()));
|
if (url == (button->getIPLabel()))
|
||||||
if (pos != wxString::npos) {
|
|
||||||
button->SetSelect(true);
|
button->SetSelect(true);
|
||||||
} else {
|
else
|
||||||
button->SetSelect(false);
|
button->SetSelect(false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_browser->LoadURL(url);
|
//const char *data = "Hello from C++!";
|
||||||
|
//std::string switch_dark_mode_script = "SwitchDarkMode(";
|
||||||
|
//switch_dark_mode_script += wxGetApp().app_config->get("dark_color_mode") == "1" ? "true" : "false";
|
||||||
|
//switch_dark_mode_script += ");";
|
||||||
|
//RunScript("var valueFromCpp = '" + std::string(data) + "';");
|
||||||
|
//m_browser->RunScript(switch_dark_mode_script);
|
||||||
|
|
||||||
//m_browser->SetFocus();
|
//m_browser->SetFocus();
|
||||||
UpdateState();
|
UpdateState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,10 @@ public:
|
|||||||
SetBackgroundColour(wxColour(67, 67, 71));
|
SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
//Bind(wxEVT_BUTTON, &MachineListButton::OnMouseLeftUp, this);
|
//Bind(wxEVT_BUTTON, &MachineListButton::OnMouseLeftUp, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetLabel(const wxString &fullname) { full_label = fullname; }
|
||||||
|
|
||||||
|
|
||||||
wxString getLabel() { return full_label; }
|
wxString getLabel() { return full_label; }
|
||||||
wxString getIPLabel() { return m_ip_text; }
|
wxString getIPLabel() { return m_ip_text; }
|
||||||
|
|
||||||
@@ -80,6 +84,13 @@ public:
|
|||||||
m_name_text = text;
|
m_name_text = text;
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString GetNameText()
|
||||||
|
{
|
||||||
|
return m_name_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetIPText(const wxString &text)
|
void SetIPText(const wxString &text)
|
||||||
{
|
{
|
||||||
m_ip_text = text;
|
m_ip_text = text;
|
||||||
@@ -105,7 +116,7 @@ public:
|
|||||||
SetBackgroundColour(wxColour(67, 67, 71));
|
SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
bool GetSelected() { return m_isSelected;}
|
||||||
void SetSimpleMode(bool issimplemode)
|
void SetSimpleMode(bool issimplemode)
|
||||||
{
|
{
|
||||||
m_isSimpleMode = issimplemode;
|
m_isSimpleMode = issimplemode;
|
||||||
@@ -210,14 +221,20 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
void OnLeftButtonClick(wxCommandEvent &event);
|
void OnLeftButtonClick(wxCommandEvent &event);
|
||||||
void OnRightButtonClick(wxCommandEvent &event);
|
void OnRightButtonClick(wxCommandEvent &event);
|
||||||
|
void OnAddButtonClick(wxCommandEvent &event);
|
||||||
|
void OnDeleteButtonClick(wxCommandEvent &event);
|
||||||
|
void OnEditButtonClick(wxCommandEvent &event);
|
||||||
|
|
||||||
void RunScript(const wxString &javascript);
|
void RunScript(const wxString &javascript);
|
||||||
//void OnScriptMessageReceived(wxWebViewEvent &event);
|
//void OnScriptMessageReceived(wxWebViewEvent &event);
|
||||||
void OnScriptMessage(wxWebViewEvent &evt);
|
void OnScriptMessage(wxWebViewEvent &evt);
|
||||||
|
|
||||||
void UpdateLayout();
|
void UpdateLayout();
|
||||||
void OnScroll(wxScrollWinEvent &event);
|
void OnScroll(wxScrollWinEvent &event);
|
||||||
|
|
||||||
|
void SetUpdateHandler(const std::function<void(wxCommandEvent &)> &handler) { m_handlerl = handler; }
|
||||||
|
void SetDeleteHandler(const std::function<void(wxCommandEvent &)> &handler) { m_delete_handlerl = handler; }
|
||||||
|
|
||||||
|
|
||||||
//B45
|
//B45
|
||||||
//void SendRecentList(int images);
|
//void SendRecentList(int images);
|
||||||
void SetButtons(std::vector<MachineListButton *> buttons);
|
void SetButtons(std::vector<MachineListButton *> buttons);
|
||||||
@@ -231,18 +248,28 @@ public:
|
|||||||
void DeleteButton();
|
void DeleteButton();
|
||||||
void PauseButton();
|
void PauseButton();
|
||||||
void ResumeButton();
|
void ResumeButton();
|
||||||
|
void UnSelectedButton();
|
||||||
|
|
||||||
std::vector<MachineListButton *> GetButton() { return m_buttons; };
|
std::vector<MachineListButton *> GetButton() { return m_buttons; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//B45
|
//B45
|
||||||
|
wxBoxSizer *leftallsizer;
|
||||||
|
|
||||||
wxBoxSizer *leftsizer;
|
wxBoxSizer *leftsizer;
|
||||||
wxBoxSizer *topsizer;
|
wxBoxSizer *topsizer;
|
||||||
bool m_isSimpleMode = false;
|
bool m_isSimpleMode = false;
|
||||||
|
|
||||||
wxButton *arrow_button;
|
wxButton *arrow_button;
|
||||||
wxStaticText * text_static;
|
wxStaticText * text_static;
|
||||||
|
|
||||||
|
|
||||||
|
std::function<void(wxCommandEvent &)> m_handlerl;
|
||||||
|
std::function<void(wxCommandEvent &)> m_delete_handlerl;
|
||||||
|
|
||||||
|
|
||||||
wxScrolledWindow * leftScrolledWindow;
|
wxScrolledWindow * leftScrolledWindow;
|
||||||
|
wxPanel * leftPanel;
|
||||||
|
|
||||||
|
|
||||||
std::vector<MachineListButton *> m_buttons;
|
std::vector<MachineListButton *> m_buttons;
|
||||||
|
|
||||||
@@ -252,6 +279,8 @@ private:
|
|||||||
// DECLARE_EVENT_TABLE()
|
// DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
} // Slic3r
|
} // Slic3r
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user