ENH: support to skip current version in upgrading dialog
Change-Id: Iedcf595b146017fa26827900b446fd8782938341 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
4e1caa428d
commit
fbd6af069d
|
@ -2005,9 +2005,25 @@ bool GUI_App::on_init_inner()
|
||||||
|
|
||||||
dialog.SetExtendedMessage(extmsg);*/
|
dialog.SetExtendedMessage(extmsg);*/
|
||||||
|
|
||||||
|
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);
|
UpdateVersionDialog dialog(this->mainframe);
|
||||||
wxString extmsg = wxString::FromUTF8(version_info.description);
|
wxString extmsg = wxString::FromUTF8(version_info.description);
|
||||||
dialog.update_version_info(extmsg, version_info.version_str);
|
dialog.update_version_info(extmsg, version_info.version_str);
|
||||||
|
if (evt.GetInt() != 0) {
|
||||||
|
dialog.m_remind_choice->Hide();
|
||||||
|
}
|
||||||
switch (dialog.ShowModal())
|
switch (dialog.ShowModal())
|
||||||
{
|
{
|
||||||
case wxID_YES:
|
case wxID_YES:
|
||||||
|
@ -2019,6 +2035,7 @@ bool GUI_App::on_init_inner()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Bind(EVT_ENTER_FORCE_UPGRADE, [this](const wxCommandEvent& evt) {
|
Bind(EVT_ENTER_FORCE_UPGRADE, [this](const wxCommandEvent& evt) {
|
||||||
|
@ -3283,7 +3300,7 @@ void GUI_App::reset_to_active()
|
||||||
last_active_point = std::chrono::system_clock::now();
|
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.version_str.empty()) return;
|
||||||
if (version_info.url.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();
|
GUI::wxGetApp().enter_force_upgrade();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GUI::wxGetApp().request_new_version();
|
GUI::wxGetApp().request_new_version(by_user);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wxGetApp().app_config->set("upgrade", "force_upgrade", false);
|
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";
|
std::string platform = "windows";
|
||||||
|
|
||||||
|
@ -3332,7 +3349,7 @@ void GUI_App::check_new_version(bool show_tips)
|
||||||
|
|
||||||
http.header("accept", "application/json")
|
http.header("accept", "application/json")
|
||||||
.timeout_max(10)
|
.timeout_max(10)
|
||||||
.on_complete([this, show_tips](std::string body, unsigned) {
|
.on_complete([this, show_tips, by_user](std::string body, unsigned) {
|
||||||
try {
|
try {
|
||||||
json j = json::parse(body);
|
json j = json::parse(body);
|
||||||
if (j.contains("message")) {
|
if (j.contains("message")) {
|
||||||
|
@ -3352,8 +3369,8 @@ void GUI_App::check_new_version(bool show_tips)
|
||||||
if (j["software"].contains("force_update")) {
|
if (j["software"].contains("force_update")) {
|
||||||
version_info.force_upgrade = j["software"]["force_update"].get<bool>();
|
version_info.force_upgrade = j["software"]["force_update"].get<bool>();
|
||||||
}
|
}
|
||||||
CallAfter([this, show_tips](){
|
CallAfter([this, show_tips, by_user](){
|
||||||
this->check_update(show_tips);
|
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
|
//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);
|
wxCommandEvent* evt = new wxCommandEvent(EVT_SLIC3R_VERSION_ONLINE);
|
||||||
evt->SetString(GUI::from_u8(version_info.version_str));
|
evt->SetString(GUI::from_u8(version_info.version_str));
|
||||||
|
evt->SetInt(by_user);
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3385,6 +3403,16 @@ void GUI_App::enter_force_upgrade()
|
||||||
GUI::wxGetApp().QueueEvent(evt);
|
GUI::wxGetApp().QueueEvent(evt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI_App::set_skip_version(bool skip)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "set_skip_version, skip = " << skip << ", version = " <<version_info.version_str;
|
||||||
|
if (skip) {
|
||||||
|
app_config->set("skip_version", version_info.version_str);
|
||||||
|
}else {
|
||||||
|
app_config->set("skip_version", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GUI_App::no_new_version()
|
void GUI_App::no_new_version()
|
||||||
{
|
{
|
||||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_NO_NEW_VERSION);
|
wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_NO_NEW_VERSION);
|
||||||
|
|
|
@ -140,6 +140,7 @@ public:
|
||||||
ver_items[i] = 0;
|
ver_items[i] = 0;
|
||||||
}
|
}
|
||||||
force_upgrade = false;
|
force_upgrade = false;
|
||||||
|
version_str = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse_version_str(std::string str) {
|
void parse_version_str(std::string str) {
|
||||||
|
@ -384,10 +385,11 @@ public:
|
||||||
bool m_studio_active = true;
|
bool m_studio_active = true;
|
||||||
std::chrono::system_clock::time_point last_active_point;
|
std::chrono::system_clock::time_point last_active_point;
|
||||||
|
|
||||||
void check_update(bool show_tips);
|
void check_update(bool show_tips, int by_user);
|
||||||
void check_new_version(bool show_tips = false);
|
void check_new_version(bool show_tips = false, int by_user = 0);
|
||||||
void request_new_version();
|
void request_new_version(int by_user);
|
||||||
void enter_force_upgrade();
|
void enter_force_upgrade();
|
||||||
|
void set_skip_version(bool skip = true);
|
||||||
void no_new_version();
|
void no_new_version();
|
||||||
void show_dialog(wxString msg);
|
void show_dialog(wxString msg);
|
||||||
void reload_settings();
|
void reload_settings();
|
||||||
|
|
|
@ -1625,7 +1625,7 @@ static wxMenu* generate_help_menu()
|
||||||
// Check New Version
|
// Check New Version
|
||||||
append_menu_item(helpMenu, wxID_ANY, _L("Check for Update"), _L("Check for Update"),
|
append_menu_item(helpMenu, wxID_ANY, _L("Check for Update"), _L("Check for Update"),
|
||||||
[](wxCommandEvent&) {
|
[](wxCommandEvent&) {
|
||||||
wxGetApp().check_new_version(true);
|
wxGetApp().check_new_version(true, 1);
|
||||||
}, "", nullptr, []() {
|
}, "", nullptr, []() {
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
|
@ -90,6 +90,10 @@ void ReleaseNoteDialog::update_release_note(wxString release_note, std::string v
|
||||||
m_scrollwindw_release_note->Layout();
|
m_scrollwindw_release_note->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateVersionDialog::alter_choice(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxGetApp().set_skip_version(m_remind_choice->GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
||||||
: DPIDialog(parent, wxID_ANY, _L("New version of Bambu Studio"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
: DPIDialog(parent, wxID_ANY, _L("New version of Bambu Studio"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||||
|
@ -130,8 +134,11 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
||||||
m_scrollwindw_release_note->SetBackgroundColour(wxColour(0xF8, 0xF8, 0xF8));
|
m_scrollwindw_release_note->SetBackgroundColour(wxColour(0xF8, 0xF8, 0xF8));
|
||||||
m_scrollwindw_release_note->SetMaxSize(wxSize(FromDIP(560), FromDIP(430)));
|
m_scrollwindw_release_note->SetMaxSize(wxSize(FromDIP(560), FromDIP(430)));
|
||||||
|
|
||||||
auto sizer_button = new wxBoxSizer(wxHORIZONTAL);
|
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, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
|
||||||
|
@ -140,20 +147,20 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
||||||
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
|
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
|
||||||
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
|
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
|
||||||
|
|
||||||
auto m_butto_ok = new Button(this, _L("OK"));
|
m_button_ok = new Button(this, _L("OK"));
|
||||||
m_butto_ok->SetBackgroundColor(btn_bg_green);
|
m_button_ok->SetBackgroundColor(btn_bg_green);
|
||||||
m_butto_ok->SetBorderColor(*wxWHITE);
|
m_button_ok->SetBorderColor(*wxWHITE);
|
||||||
m_butto_ok->SetTextColor(*wxWHITE);
|
m_button_ok->SetTextColor(*wxWHITE);
|
||||||
m_butto_ok->SetFont(Label::Body_12);
|
m_button_ok->SetFont(Label::Body_12);
|
||||||
m_butto_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||||
m_butto_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
|
||||||
m_butto_ok->SetCornerRadius(FromDIP(12));
|
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);
|
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->SetBackgroundColor(*wxWHITE);
|
||||||
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
|
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
|
||||||
m_button_cancel->SetFont(Label::Body_12);
|
m_button_cancel->SetFont(Label::Body_12);
|
||||||
|
@ -165,14 +172,17 @@ UpdateVersionDialog::UpdateVersionDialog(wxWindow *parent)
|
||||||
EndModal(wxID_NO);
|
EndModal(wxID_NO);
|
||||||
});
|
});
|
||||||
|
|
||||||
sizer_button->Add(0, 0, 1, wxEXPAND, 5);
|
sizer_button->Add(m_remind_choice, 0, wxALL | wxEXPAND, FromDIP(5));
|
||||||
sizer_button->Add(m_butto_ok, 0, wxALL, 5);
|
sizer_button->AddStretchSpacer();
|
||||||
sizer_button->Add(m_button_cancel, 0, wxALL, 5);
|
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(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_body->Add(m_sizer_right, 1, wxBOTTOM | wxEXPAND, FromDIP(8));
|
||||||
m_sizer_main->Add(m_sizer_body, 0, wxEXPAND, 0);
|
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);
|
m_sizer_main->Add(0, 0, 0, wxBOTTOM, 10);
|
||||||
|
|
||||||
SetSizer(m_sizer_main);
|
SetSizer(m_sizer_main);
|
||||||
|
@ -186,6 +196,8 @@ UpdateVersionDialog::~UpdateVersionDialog() {}
|
||||||
|
|
||||||
|
|
||||||
void UpdateVersionDialog::on_dpi_changed(const wxRect &suggested_rect) {
|
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)
|
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();
|
m_scrollwindw_release_note->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
||||||
|
|
|
@ -57,11 +57,15 @@ public:
|
||||||
|
|
||||||
void on_dpi_changed(const wxRect &suggested_rect) override;
|
void on_dpi_changed(const wxRect &suggested_rect) override;
|
||||||
void update_version_info(wxString release_note, wxString version);
|
void update_version_info(wxString release_note, wxString version);
|
||||||
|
void alter_choice(wxCommandEvent& event);
|
||||||
|
|
||||||
wxStaticText * m_text_up_info{nullptr};
|
wxStaticText * m_text_up_info{nullptr};
|
||||||
wxScrolledWindow *m_scrollwindw_release_note{nullptr};
|
wxScrolledWindow *m_scrollwindw_release_note{nullptr};
|
||||||
wxBoxSizer * sizer_text_release_note{nullptr};
|
wxBoxSizer * sizer_text_release_note{nullptr};
|
||||||
wxStaticText * m_staticText_release_note{nullptr};
|
wxStaticText * m_staticText_release_note{nullptr};
|
||||||
|
wxCheckBox* m_remind_choice;
|
||||||
|
Button* m_button_ok;
|
||||||
|
Button* m_button_cancel;
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
||||||
|
|
Loading…
Reference in New Issue