From fd8caee3dbbb5e9e4bb495fcb95c4dcbbb2957d2 Mon Sep 17 00:00:00 2001 From: "tao.jin" Date: Fri, 19 Aug 2022 18:36:57 +0800 Subject: [PATCH] NEW:Add search printer for debug Change-Id: I3d8db835331e1ce4699f02a3571b3978544b8e77 --- src/slic3r/GUI/SelectMachine.cpp | 36 ++++++++++++++++++++++++++++++++ src/slic3r/GUI/SelectMachine.hpp | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 7a17ca95f..f5dab138a 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -341,6 +341,15 @@ SelectMachinePopup::SelectMachinePopup(wxWindow *parent) m_scrolledWindow->Layout(); m_sizxer_scrolledWindow->Fit(m_scrolledWindow); +#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) + m_sizer_search_bar = new wxBoxSizer(wxVERTICAL); + m_search_bar = new wxSearchCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_search_bar->ShowSearchButton( true ); + m_search_bar->ShowCancelButton( false ); + m_sizer_search_bar->Add( m_search_bar, 1, wxALL| wxEXPAND, 1 ); + m_sizer_main->Add(m_sizer_search_bar, 0, wxALL | wxEXPAND, FromDIP(2)); + m_search_bar->Bind( wxEVT_COMMAND_TEXT_UPDATED, &SelectMachinePopup::update_machine_list, this ); +#endif auto own_title = create_title_panel(_L("My Device")); m_sizer_my_devices = new wxBoxSizer(wxVERTICAL); auto other_title = create_title_panel(_L("Other Device")); @@ -505,6 +514,11 @@ void SelectMachinePopup::update_other_devices() if (i < m_other_list_machine_panel.size()) { op = m_other_list_machine_panel[i]->mPanel; op->Show(); +#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) + if (!search_for_printer(mobj)) { + op->Hide(); + } +#endif } else { op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY); MachinePanel* mpanel = new MachinePanel(); @@ -590,6 +604,11 @@ void SelectMachinePopup::update_user_devices() if (i < m_user_list_machine_panel.size()) { op = m_user_list_machine_panel[i]->mPanel; op->Show(); +#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) + if (!search_for_printer(mobj)) { + op->Hide(); + } +#endif } else { op = new MachineObjectPanel(m_scrolledWindow, wxID_ANY); MachinePanel* mpanel = new MachinePanel(); @@ -683,6 +702,23 @@ void SelectMachinePopup::update_user_devices() this->Thaw(); } +bool SelectMachinePopup::search_for_printer(MachineObject* obj) +{ + std::string search_text = std::string((m_search_bar->GetValue()).mb_str()); + if (search_text.empty()) { + return true; + } + auto name = obj->dev_name; + auto ip = obj->dev_ip; + auto name_it = name.find(search_text); + auto ip_it = ip.find(search_text); + if ((name_it != std::string::npos)||(ip_it != std::string::npos)) { + return true; + } + + return false; +} + void SelectMachinePopup::on_dissmiss_win(wxCommandEvent &event) { Dismiss(); diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index b41e1a69e..c74d3a499 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "AmsMappingPopup.hpp" #include "GUI_Utils.hpp" @@ -197,6 +198,8 @@ private: wxBoxSizer * m_sizer_body{nullptr}; wxBoxSizer * m_sizer_my_devices{nullptr}; wxBoxSizer * m_sizer_other_devices{nullptr}; + wxBoxSizer * m_sizer_search_bar{nullptr}; + wxSearchCtrl* m_search_bar{nullptr}; wxScrolledWindow * m_scrolledWindow{nullptr}; wxWindow * m_panel_body{nullptr}; wxTimer * m_refresh_timer{nullptr}; @@ -215,6 +218,7 @@ private: void update_other_devices(); void update_user_devices(); + bool search_for_printer(MachineObject* obj); void on_dissmiss_win(wxCommandEvent &event); wxWindow *create_title_panel(wxString text); };