feature add tips dialog for no update on preset

This commit is contained in:
alves
2025-12-31 16:18:55 +08:00
parent 1947fd1551
commit 0163f9b31a
5 changed files with 55 additions and 15 deletions

View File

@@ -2578,6 +2578,12 @@ bool GUI_App::on_init_inner()
});
dlg.ShowModal();
});
Bind(EVT_NO_PRESET_UPDATE, [this](const wxCommandEvent& evt) {
wxString msg = _L("This is the newest version.");
InfoDialog dlg(nullptr, _L("Info"), msg);
dlg.ShowModal();
});
}
else {
#ifdef __WXMSW__
@@ -4724,12 +4730,10 @@ void maybe_attach_updater_signature(Http& http, const std::string& canonical_que
} // namespace
bool GUI_App::check_preset_version()
{
bool is_newest_version = false;
return is_newest_version;
void GUI_App::check_preset_version()
{
if (preset_updater != nullptr)
preset_updater->sync_config_async();
}
void GUI_App::check_new_version_sf(bool show_tips, bool by_user)
{

View File

@@ -578,7 +578,7 @@ private:
bool m_studio_active = true;
std::chrono::system_clock::time_point last_active_point;
bool check_preset_version();
void check_preset_version();
void check_new_version_sf(bool show_tips = false, bool by_user = false);
void process_network_msg(std::string dev_id, std::string msg);
void enter_force_upgrade();

View File

@@ -2300,10 +2300,8 @@ static wxMenu* generate_help_menu()
append_menu_item(
helpMenu, wxID_ANY, _L("Check for Preset Update"), _L("Check for Preset Update"),
[](wxCommandEvent&) {
wxGetApp().check_preset_version();
wxString msg = _L("This is the newest version.");
InfoDialog dlg(nullptr, _L("Info"), msg);
dlg.ShowModal();
},
"", nullptr, []() { return true; });

View File

@@ -182,6 +182,7 @@ struct Updates
};
wxDEFINE_EVENT(EVT_NO_PRESET_UPDATE, wxCommandEvent);
wxDEFINE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
wxDEFINE_EVENT(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE, wxCommandEvent);
@@ -226,7 +227,7 @@ struct PresetUpdater::priv
void sync_version() const;
void parse_version_string(const std::string& body) const;
void sync_resources(std::string http_url, std::map<std::string, Resource> &resources, bool check_patch = false, std::string current_version="", std::string changelog_file="");
void sync_config();
void sync_config(bool isAuto_check = true);
bool download_file(const std::string& url, const std::string& target_path, int timeout_sec = 30, bool* cancel_flag = nullptr);
void sync_tooltip(std::string http_url, std::string language);
void sync_plugins(std::string http_url, std::string plugin_version);
@@ -709,7 +710,7 @@ bool PresetUpdater::priv::download_file(const std::string& url,
return res;
}
// Orca: sync config update for currect App version
void PresetUpdater::priv::sync_config()
void PresetUpdater::priv::sync_config(bool isAuto_check)
{
auto cache_profile_path = cache_path;
@@ -720,13 +721,13 @@ void PresetUpdater::priv::sync_config()
// parse the assets section and get the latest asset by comparing the name
Http::get(profile_update_url)
.on_error([cache_profile_path ](std::string body, std::string error, unsigned http_status) {
.on_error([cache_profile_path, isAuto_check](std::string body, std::string error, unsigned http_status) {
// Orca: we check the response body to see if it's "Not Found", if so, it means for the current Orca version we don't have OTA
// updates, we can delete the cache file
BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_config_orca", http_status, error);
})
.timeout_connect(5)
.on_complete([this, cache_profile_path](std::string body, unsigned http_status) {
.on_complete([this, cache_profile_path, isAuto_check](std::string body, unsigned http_status) {
// Http response OK
if (http_status != 200)
return;
@@ -755,13 +756,27 @@ void PresetUpdater::priv::sync_config()
Semver localOtaVersion = get_version_from_json(localProfilesjson.string());
if (localOtaVersion >= remoteVersion) {
BOOST_LOG_TRIVIAL(info) << format("this the newest preset config for snapmaker orca");
if (!isAuto_check)
{
wxCommandEvent* evt = new wxCommandEvent(EVT_NO_PRESET_UPDATE);
GUI::wxGetApp().QueueEvent(evt);
BOOST_LOG_TRIVIAL(info) << format("use check the preset update.");
}
return;
}
}
if (currentPresetVersion < remoteVersion)
download_file(fileUrl, fileName);
{
if (!isAuto_check) {
wxCommandEvent* evt = new wxCommandEvent(EVT_NO_PRESET_UPDATE);
GUI::wxGetApp().QueueEvent(evt);
BOOST_LOG_TRIVIAL(info) << format("use check the preset update local no profiles.");
}
}
} catch (...) {}
})
@@ -1540,6 +1555,26 @@ bool PresetUpdater::install_bundles_rsrc(std::vector<std::string> bundles, bool
return p->install_bundles_rsrc(bundles, snapshot);
}
void PresetUpdater::sync_config_async()
{
if (p->thread.joinable()) {
p->cancel = true;
p->thread.join();
}
p->cancel = false;
p->thread = std::thread([this]() {
BOOST_LOG_TRIVIAL(debug) << "[Orca Updater] sync_config_async started";
this->p->sync_config(false);
GUI::wxGetApp().CallAfter([] {
BOOST_LOG_TRIVIAL(debug) << "[Orca Updater] sync_config_async completed, checking updates...";
GUI::wxGetApp().check_config_updates_from_updater();
});
});
}
void PresetUpdater::on_update_notification_confirm()
{
if (!p->has_waiting_updates)

View File

@@ -65,11 +65,14 @@ public:
void import_flutter_web();
void sync_config_async();
public:
struct priv;
std::unique_ptr<priv> p;
};
wxDECLARE_EVENT(EVT_NO_PRESET_UPDATE, wxCommandEvent);
wxDECLARE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
wxDECLARE_EVENT(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE, wxCommandEvent);