diff --git a/resources/images/monitor_hms_new.svg b/resources/images/monitor_hms_new.svg new file mode 100644 index 000000000..eb8d6a147 --- /dev/null +++ b/resources/images/monitor_hms_new.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index d8e885e0c..f5270c19b 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -290,6 +290,7 @@ public: unsigned reserved; HMSMessageLevel msg_level = HMS_UNKNOWN; int msg_code = 0; + bool already_read = false; bool parse_hms_info(unsigned attr, unsigned code); std::string get_long_error_code(); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 9a2c14020..b0ec314bd 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1903,12 +1903,12 @@ void GUI_App::init_networking_callbacks() /* request_pushing */ MachineObject* obj = m_device_manager->get_my_machine(tunnel ? dev_id.substr(7) : dev_id); if (obj) { -#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) - if (obj->is_tunnel_mqtt && !tunnel) - boost::thread ping_thread = Slic3r::create_thread([] { - start_ping_test(); - }); -#endif +//#if !BBL_RELEASE_TO_PUBLIC && defined(__WINDOWS__) +// if (obj->is_tunnel_mqtt && !tunnel) +// boost::thread ping_thread = Slic3r::create_thread([] { +// start_ping_test(); +// }); +//#endif obj->is_tunnel_mqtt = tunnel; obj->command_request_push_all(true); obj->command_get_version(); diff --git a/src/slic3r/GUI/HMSPanel.cpp b/src/slic3r/GUI/HMSPanel.cpp index 9992e37af..98bba43f7 100644 --- a/src/slic3r/GUI/HMSPanel.cpp +++ b/src/slic3r/GUI/HMSPanel.cpp @@ -5,6 +5,8 @@ #include #include "GUI.hpp" #include "GUI_App.hpp" +#include "MainFrame.hpp" +#include "Monitor.hpp" namespace Slic3r { namespace GUI { @@ -12,9 +14,12 @@ namespace GUI { #define HMS_NOTIFY_ITEM_TEXT_SIZE wxSize(FromDIP(730), -1) #define HMS_NOTIFY_ITEM_SIZE wxSize(-1, FromDIP(80)) +wxDEFINE_EVENT(EVT_ALREADY_READ_HMS, wxCommandEvent); + HMSNotifyItem::HMSNotifyItem(wxWindow *parent, HMSItem& item) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL) , m_hms_item(item) + , long_error_code(item.get_long_error_code()) , m_url(get_hms_wiki_url(item.get_long_error_code())) { init_bitmaps(); @@ -114,6 +119,9 @@ HMSNotifyItem::HMSNotifyItem(wxWindow *parent, HMSItem& item) }); m_hms_content->Bind(wxEVT_LEFT_UP, [this](wxMouseEvent& e) { if (!m_url.empty()) wxLaunchDefaultBrowser(m_url); + wxCommandEvent evt(EVT_ALREADY_READ_HMS); + evt.SetString(long_error_code); + wxPostEvent(wxGetApp().mainframe->m_monitor, evt); }); #endif } @@ -201,9 +209,32 @@ void HMSPanel::update(MachineObject *obj) wxString hms_text; for (auto item : obj->hms_list) { if (wxGetApp().get_hms_query()) { + + auto key = item.get_long_error_code(); + auto iter = temp_hms_list.find(key); + if (iter == temp_hms_list.end()) { + temp_hms_list[key] = item; + } + append_hms_panel(item); } } + + for (auto thms : temp_hms_list) { + auto key = thms.second.get_long_error_code(); + auto inr = false; + for (auto hms : obj->hms_list) { + if (hms.get_long_error_code() == key) { + inr = true; + break; + } + } + + if (!inr) { + temp_hms_list.erase(key); + } + } + Layout(); this->Thaw(); } else { diff --git a/src/slic3r/GUI/HMSPanel.hpp b/src/slic3r/GUI/HMSPanel.hpp index f6fe00338..5733fcd59 100644 --- a/src/slic3r/GUI/HMSPanel.hpp +++ b/src/slic3r/GUI/HMSPanel.hpp @@ -16,6 +16,7 @@ class HMSNotifyItem : public wxPanel { HMSItem & m_hms_item; std::string m_url; + std::string long_error_code; wxPanel * m_panel_hms; wxStaticBitmap *m_bitmap_notify; @@ -39,6 +40,7 @@ public: void msw_rescale() {} }; + class HMSPanel : public wxPanel { protected: @@ -63,8 +65,11 @@ public: void show_status(int status); MachineObject *obj { nullptr }; + std::map temp_hms_list; }; +wxDECLARE_EVENT(EVT_ALREADY_READ_HMS, wxCommandEvent); + } } diff --git a/src/slic3r/GUI/Monitor.cpp b/src/slic3r/GUI/Monitor.cpp index cfb122f46..c28c2d104 100644 --- a/src/slic3r/GUI/Monitor.cpp +++ b/src/slic3r/GUI/Monitor.cpp @@ -121,6 +121,17 @@ AddMachinePanel::~AddMachinePanel() { m_select_machine.Bind(EVT_FINISHED_UPDATE_MACHINE_LIST, [this](wxCommandEvent& e) { m_side_tools->start_interval(); }); + + Bind(EVT_ALREADY_READ_HMS, [this](wxCommandEvent& e) { + auto key = e.GetString().ToStdString(); + auto iter = m_hms_panel->temp_hms_list.find(key); + if (iter != m_hms_panel->temp_hms_list.end()) { + m_hms_panel->temp_hms_list[key].already_read = true; + } + + update_hms_tag(); + e.Skip(); + }); } MonitorPanel::~MonitorPanel() @@ -410,6 +421,21 @@ void MonitorPanel::update_all() m_upgrade_panel->update(obj); } #endif + + update_hms_tag(); +} + +void MonitorPanel::update_hms_tag() +{ + for (auto hmsitem : m_hms_panel->temp_hms_list) { + if (!hmsitem.second.already_read) { + //show HMS new tag + m_tabpanel->GetBtnsListCtrl()->showNewTag(3, true); + return; + } + } + + m_tabpanel->GetBtnsListCtrl()->showNewTag(3, false); } bool MonitorPanel::Show(bool show) diff --git a/src/slic3r/GUI/Monitor.hpp b/src/slic3r/GUI/Monitor.hpp index 48a14f67c..d44f400b7 100644 --- a/src/slic3r/GUI/Monitor.hpp +++ b/src/slic3r/GUI/Monitor.hpp @@ -141,6 +141,7 @@ public: //void update_ams(MachineObject* obj); void update_all(); + void update_hms_tag(); bool Show(bool show); void update_side_panel(); diff --git a/src/slic3r/GUI/TabButton.cpp b/src/slic3r/GUI/TabButton.cpp index e075f9ae1..d4e22c0b5 100644 --- a/src/slic3r/GUI/TabButton.cpp +++ b/src/slic3r/GUI/TabButton.cpp @@ -43,6 +43,7 @@ TabButton::TabButton(wxWindow *parent, wxString text, ScalableBitmap &bmp, long bool TabButton::Create(wxWindow *parent, wxString text, ScalableBitmap &bmp, long style, int iconSize) { StaticBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style); + newtag_img = ScalableBitmap(this, "monitor_hms_new",7); state_handler.attach({&text_color, &border_color}); state_handler.update_binds(); //BBS set default font @@ -169,10 +170,17 @@ void TabButton::render(wxDC &dc) dc.DrawText(text, pt); } - if (icon.bmp().IsOk()) { - pt.x = size.x - icon.GetBmpWidth() - paddingSize.y; - pt.y = (size.y - icon.GetBmpHeight()) / 2; - dc.DrawBitmap(icon.bmp(), pt); + wxBitmap showimg = icon.bmp(); + int offset_left = 0; + if (show_new_tag) { + showimg = newtag_img.bmp(); + offset_left = FromDIP(4); + } + + if (showimg.IsOk()) { + pt.x = size.x - showimg.GetWidth() - paddingSize.y - offset_left; + pt.y = (size.y - showimg.GetHeight()) / 2; + dc.DrawBitmap(showimg, pt); } } diff --git a/src/slic3r/GUI/TabButton.hpp b/src/slic3r/GUI/TabButton.hpp index 8eb060b20..d7dbd2304 100644 --- a/src/slic3r/GUI/TabButton.hpp +++ b/src/slic3r/GUI/TabButton.hpp @@ -10,10 +10,12 @@ class TabButton : public StaticBox wxSize minSize; wxSize paddingSize; ScalableBitmap icon; + ScalableBitmap newtag_img; StateColor text_color; StateColor border_color; bool pressedDown = false; + bool show_new_tag = false; public: TabButton(); @@ -42,6 +44,8 @@ public: void Rescale(); + void ShowNewTag(bool tag = false) {show_new_tag = tag; Refresh();}; + private: void paintEvent(wxPaintEvent& evt); diff --git a/src/slic3r/GUI/Tabbook.cpp b/src/slic3r/GUI/Tabbook.cpp index d1feb9265..9b3174540 100644 --- a/src/slic3r/GUI/Tabbook.cpp +++ b/src/slic3r/GUI/Tabbook.cpp @@ -113,6 +113,12 @@ void TabButtonsListCtrl::SetSelection(int sel) Refresh(); } +void TabButtonsListCtrl::showNewTag(int sel, bool tag) +{ + m_pageButtons[sel]->ShowNewTag(tag); + Refresh(); +} + bool TabButtonsListCtrl::InsertPage(size_t n, const wxString &text, bool bSelect /* = false*/, const std::string &bmp_name /* = ""*/) { TabButton *btn = new TabButton(this, text, m_arrow_img, wxNO_BORDER); diff --git a/src/slic3r/GUI/Tabbook.hpp b/src/slic3r/GUI/Tabbook.hpp index 476354dd8..7dd19389d 100644 --- a/src/slic3r/GUI/Tabbook.hpp +++ b/src/slic3r/GUI/Tabbook.hpp @@ -23,6 +23,7 @@ public: void OnPaint(wxPaintEvent&); void SetSelection(int sel); + void showNewTag(int sel, bool show = false); void Rescale(); bool InsertPage(size_t n, const wxString& text, bool bSelect = false, const std::string& bmp_name = ""); void RemovePage(size_t n); @@ -31,6 +32,7 @@ public: wxString GetPageText(size_t n) const; const wxSize& GetPaddingSize(size_t n); void SetPaddingSize(const wxSize& size); + TabButton* pageButton; private: wxWindow* m_parent;