diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 70c2efccb..68d894d65 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2005,19 +2005,36 @@ bool GUI_App::on_init_inner() dialog.SetExtendedMessage(extmsg);*/ - UpdateVersionDialog dialog(this->mainframe); - wxString extmsg = wxString::FromUTF8(version_info.description); - dialog.update_version_info(extmsg, version_info.version_str); - switch (dialog.ShowModal()) - { - case wxID_YES: - wxLaunchDefaultBrowser(version_info.url); - break; - case wxID_NO: - break; - default: - ; - } + std::string skip_version_str = this->app_config->get("app", "skip_version"); + bool skip_this_version = false; + if (!skip_version_str.empty()) { + BOOST_LOG_TRIVIAL(info) << "new version = " << version_info.version_str << ", skip version = " << skip_version_str; + if (version_info.version_str <= skip_version_str) { + skip_this_version = true; + } else { + app_config->set("skip_version", ""); + skip_this_version = false; + } + } + if (!skip_this_version + || evt.GetInt() != 0) { + UpdateVersionDialog dialog(this->mainframe); + wxString extmsg = wxString::FromUTF8(version_info.description); + dialog.update_version_info(extmsg, version_info.version_str); + if (evt.GetInt() != 0) { + dialog.m_remind_choice->Hide(); + } + switch (dialog.ShowModal()) + { + case wxID_YES: + wxLaunchDefaultBrowser(version_info.url); + break; + case wxID_NO: + break; + default: + ; + } + } } }); @@ -3283,7 +3300,7 @@ void GUI_App::reset_to_active() last_active_point = std::chrono::system_clock::now(); } -void GUI_App::check_update(bool show_tips) +void GUI_App::check_update(bool show_tips, int by_user) { if (version_info.version_str.empty()) return; if (version_info.url.empty()) return; @@ -3300,7 +3317,7 @@ void GUI_App::check_update(bool show_tips) GUI::wxGetApp().enter_force_upgrade(); } else { - GUI::wxGetApp().request_new_version(); + GUI::wxGetApp().request_new_version(by_user); } } else { wxGetApp().app_config->set("upgrade", "force_upgrade", false); @@ -3309,7 +3326,7 @@ void GUI_App::check_update(bool show_tips) } } -void GUI_App::check_new_version(bool show_tips) +void GUI_App::check_new_version(bool show_tips, int by_user) { std::string platform = "windows"; @@ -3332,7 +3349,7 @@ void GUI_App::check_new_version(bool show_tips) http.header("accept", "application/json") .timeout_max(10) - .on_complete([this, show_tips](std::string body, unsigned) { + .on_complete([this, show_tips, by_user](std::string body, unsigned) { try { json j = json::parse(body); if (j.contains("message")) { @@ -3352,8 +3369,8 @@ void GUI_App::check_new_version(bool show_tips) if (j["software"].contains("force_update")) { version_info.force_upgrade = j["software"]["force_update"].get(); } - CallAfter([this, show_tips](){ - this->check_update(show_tips); + CallAfter([this, show_tips, by_user](){ + this->check_update(show_tips, by_user); }); } } @@ -3372,10 +3389,11 @@ void GUI_App::check_new_version(bool show_tips) //BBS pop up a dialog and download files -void GUI_App::request_new_version() +void GUI_App::request_new_version(int by_user) { wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE); evt->SetString(GUI::from_u8(version_info.version_str)); + evt->SetInt(by_user); GUI::wxGetApp().QueueEvent(evt); } @@ -3385,6 +3403,16 @@ void GUI_App::enter_force_upgrade() GUI::wxGetApp().QueueEvent(evt); } +void GUI_App::set_skip_version(bool skip) +{ + BOOST_LOG_TRIVIAL(info) << "set_skip_version, skip = " << skip << ", version = " <set("skip_version", version_info.version_str); + }else { + app_config->set("skip_version", ""); + } +} + void GUI_App::no_new_version() { wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_NO_NEW_VERSION); diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 993197722..2cacc0cc2 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -140,6 +140,7 @@ public: ver_items[i] = 0; } force_upgrade = false; + version_str = ""; } void parse_version_str(std::string str) { @@ -384,10 +385,11 @@ public: bool m_studio_active = true; std::chrono::system_clock::time_point last_active_point; - void check_update(bool show_tips); - void check_new_version(bool show_tips = false); - void request_new_version(); + void check_update(bool show_tips, int by_user); + void check_new_version(bool show_tips = false, int by_user = 0); + void request_new_version(int by_user); void enter_force_upgrade(); + void set_skip_version(bool skip = true); void no_new_version(); void show_dialog(wxString msg); void reload_settings(); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 3b1e1708c..68d1c73b6 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1625,7 +1625,7 @@ static wxMenu* generate_help_menu() // Check New Version append_menu_item(helpMenu, wxID_ANY, _L("Check for Update"), _L("Check for Update"), [](wxCommandEvent&) { - wxGetApp().check_new_version(true); + wxGetApp().check_new_version(true, 1); }, "", nullptr, []() { return true; }); diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 9115182cb..a8eec9009 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -90,6 +90,10 @@ void ReleaseNoteDialog::update_release_note(wxString release_note, std::string v m_scrollwindw_release_note->Layout(); } +void UpdateVersionDialog::alter_choice(wxCommandEvent& event) +{ + wxGetApp().set_skip_version(m_remind_choice->GetValue()); +} UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent) : DPIDialog(parent, wxID_ANY, _L("New version of Bambu Studio"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) @@ -130,30 +134,33 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent) m_scrollwindw_release_note->SetBackgroundColour(wxColour(0xF8, 0xF8, 0xF8)); m_scrollwindw_release_note->SetMaxSize(wxSize(FromDIP(560), FromDIP(430))); + m_remind_choice = new wxCheckBox( this, wxID_ANY, _L("Don't remind me of this version again"), wxDefaultPosition, wxDefaultSize, 0 ); + m_remind_choice->SetValue(false); + m_remind_choice->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &UpdateVersionDialog::alter_choice,this); + auto sizer_button = new wxBoxSizer(wxHORIZONTAL); - - + StateColor btn_bg_green(std::pair(wxColour(27, 136, 68), StateColor::Pressed), std::pair(wxColour(61, 203, 115), StateColor::Hovered), std::pair(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal)); StateColor btn_bg_white(std::pair(wxColour(206, 206, 206), StateColor::Pressed), std::pair(wxColour(238, 238, 238), StateColor::Hovered), std::pair(*wxWHITE, StateColor::Normal)); - auto m_butto_ok = new Button(this, _L("OK")); - m_butto_ok->SetBackgroundColor(btn_bg_green); - m_butto_ok->SetBorderColor(*wxWHITE); - m_butto_ok->SetTextColor(*wxWHITE); - m_butto_ok->SetFont(Label::Body_12); - m_butto_ok->SetSize(wxSize(FromDIP(58), FromDIP(24))); - m_butto_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24))); - m_butto_ok->SetCornerRadius(FromDIP(12)); + m_button_ok = new Button(this, _L("OK")); + m_button_ok->SetBackgroundColor(btn_bg_green); + m_button_ok->SetBorderColor(*wxWHITE); + m_button_ok->SetTextColor(*wxWHITE); + m_button_ok->SetFont(Label::Body_12); + m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24))); + m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24))); + m_button_ok->SetCornerRadius(FromDIP(12)); - m_butto_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { + m_button_ok->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_YES); }); - auto m_button_cancel = new Button(this, _L("Cancel")); + m_button_cancel = new Button(this, _L("Cancel")); m_button_cancel->SetBackgroundColor(*wxWHITE); m_button_cancel->SetBorderColor(wxColour(38, 46, 48)); m_button_cancel->SetFont(Label::Body_12); @@ -164,15 +171,18 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent) m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent &e) { EndModal(wxID_NO); }); - - sizer_button->Add(0, 0, 1, wxEXPAND, 5); - sizer_button->Add(m_butto_ok, 0, wxALL, 5); - sizer_button->Add(m_button_cancel, 0, wxALL, 5); + + sizer_button->Add(m_remind_choice, 0, wxALL | wxEXPAND, FromDIP(5)); + sizer_button->AddStretchSpacer(); + sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5)); + sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5)); + m_sizer_right->Add(m_scrollwindw_release_note, 0, wxEXPAND | wxRIGHT, FromDIP(20)); + m_sizer_right->Add(sizer_button, 0, wxEXPAND | wxRIGHT, FromDIP(20)); + m_sizer_body->Add(m_sizer_right, 1, wxBOTTOM | wxEXPAND, FromDIP(8)); m_sizer_main->Add(m_sizer_body, 0, wxEXPAND, 0); - m_sizer_main->Add(sizer_button, 0, wxEXPAND, 0); m_sizer_main->Add(0, 0, 0, wxBOTTOM, 10); SetSizer(m_sizer_main); @@ -186,6 +196,8 @@ UpdateVersionDialog::~UpdateVersionDialog() {} void UpdateVersionDialog::on_dpi_changed(const wxRect &suggested_rect) { + m_button_ok->Rescale(); + m_button_cancel->Rescale(); } void UpdateVersionDialog::update_version_info(wxString release_note, wxString version) @@ -199,5 +211,4 @@ void UpdateVersionDialog::update_version_info(wxString release_note, wxString ve m_scrollwindw_release_note->Layout(); } - }} // namespace Slic3r::GUI diff --git a/src/slic3r/GUI/ReleaseNote.hpp b/src/slic3r/GUI/ReleaseNote.hpp index 1e0945f81..ec517c00c 100644 --- a/src/slic3r/GUI/ReleaseNote.hpp +++ b/src/slic3r/GUI/ReleaseNote.hpp @@ -57,11 +57,15 @@ public: void on_dpi_changed(const wxRect &suggested_rect) override; void update_version_info(wxString release_note, wxString version); + void alter_choice(wxCommandEvent& event); wxStaticText * m_text_up_info{nullptr}; wxScrolledWindow *m_scrollwindw_release_note{nullptr}; wxBoxSizer * sizer_text_release_note{nullptr}; wxStaticText * m_staticText_release_note{nullptr}; + wxCheckBox* m_remind_choice; + Button* m_button_ok; + Button* m_button_cancel; }; }} // namespace Slic3r::GUI