NEW:add new msg notification for hms
jira:[STUDIO-6154] Change-Id: If1aa33030a99550d0c859d594a2711aea4dcea4a
This commit is contained in:
parent
aa8d7acf3b
commit
64c7487abb
|
@ -0,0 +1,3 @@
|
|||
<svg width="5" height="6" viewBox="0 0 5 6" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2.5 5.5C3.88071 5.5 5 4.38071 5 3C5 1.61929 3.88071 0.5 2.5 0.5C1.11929 0.5 0 1.61929 0 3C0 4.38071 1.11929 5.5 2.5 5.5Z" fill="#FC3722"/>
|
||||
</svg>
|
After Width: | Height: | Size: 248 B |
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <slic3r/GUI/I18N.hpp>
|
||||
#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 {
|
||||
|
|
|
@ -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<std::string, HMSItem> temp_hms_list;
|
||||
};
|
||||
|
||||
wxDECLARE_EVENT(EVT_ALREADY_READ_HMS, wxCommandEvent);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue