mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
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
5 changed files with 87 additions and 42 deletions
|
@ -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<bool>();
|
||||
}
|
||||
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 = " <<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()
|
||||
{
|
||||
wxCommandEvent* evt = new wxCommandEvent(EVT_SHOW_NO_NEW_VERSION);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue