mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-29 05:42:33 +00:00
feature add tips dialog for no update on preset
This commit is contained in:
@@ -2578,6 +2578,12 @@ bool GUI_App::on_init_inner()
|
|||||||
});
|
});
|
||||||
dlg.ShowModal();
|
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 {
|
else {
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
@@ -4724,12 +4730,10 @@ void maybe_attach_updater_signature(Http& http, const std::string& canonical_que
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool GUI_App::check_preset_version()
|
void GUI_App::check_preset_version()
|
||||||
{
|
{
|
||||||
bool is_newest_version = false;
|
if (preset_updater != nullptr)
|
||||||
|
preset_updater->sync_config_async();
|
||||||
|
|
||||||
return is_newest_version;
|
|
||||||
}
|
}
|
||||||
void GUI_App::check_new_version_sf(bool show_tips, bool by_user)
|
void GUI_App::check_new_version_sf(bool show_tips, bool by_user)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -578,7 +578,7 @@ private:
|
|||||||
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;
|
||||||
|
|
||||||
bool check_preset_version();
|
void check_preset_version();
|
||||||
void check_new_version_sf(bool show_tips = false, bool by_user = false);
|
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 process_network_msg(std::string dev_id, std::string msg);
|
||||||
void enter_force_upgrade();
|
void enter_force_upgrade();
|
||||||
|
|||||||
@@ -2300,10 +2300,8 @@ static wxMenu* generate_help_menu()
|
|||||||
append_menu_item(
|
append_menu_item(
|
||||||
helpMenu, wxID_ANY, _L("Check for Preset Update"), _L("Check for Preset Update"),
|
helpMenu, wxID_ANY, _L("Check for Preset Update"), _L("Check for Preset Update"),
|
||||||
[](wxCommandEvent&) {
|
[](wxCommandEvent&) {
|
||||||
|
wxGetApp().check_preset_version();
|
||||||
|
|
||||||
wxString msg = _L("This is the newest version.");
|
|
||||||
InfoDialog dlg(nullptr, _L("Info"), msg);
|
|
||||||
dlg.ShowModal();
|
|
||||||
},
|
},
|
||||||
"", nullptr, []() { return true; });
|
"", nullptr, []() { return true; });
|
||||||
|
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ struct Updates
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(EVT_NO_PRESET_UPDATE, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE, wxCommandEvent);
|
||||||
|
|
||||||
@@ -226,7 +227,7 @@ struct PresetUpdater::priv
|
|||||||
void sync_version() const;
|
void sync_version() const;
|
||||||
void parse_version_string(const std::string& body) 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_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);
|
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_tooltip(std::string http_url, std::string language);
|
||||||
void sync_plugins(std::string http_url, std::string plugin_version);
|
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;
|
return res;
|
||||||
}
|
}
|
||||||
// Orca: sync config update for currect App version
|
// 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;
|
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
|
// parse the assets section and get the latest asset by comparing the name
|
||||||
|
|
||||||
Http::get(profile_update_url)
|
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
|
// 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
|
// updates, we can delete the cache file
|
||||||
BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_config_orca", http_status, error);
|
BOOST_LOG_TRIVIAL(info) << format("Error getting: `%1%`: HTTP %2%, %3%", "sync_config_orca", http_status, error);
|
||||||
})
|
})
|
||||||
.timeout_connect(5)
|
.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
|
// Http response OK
|
||||||
if (http_status != 200)
|
if (http_status != 200)
|
||||||
return;
|
return;
|
||||||
@@ -755,13 +756,27 @@ void PresetUpdater::priv::sync_config()
|
|||||||
Semver localOtaVersion = get_version_from_json(localProfilesjson.string());
|
Semver localOtaVersion = get_version_from_json(localProfilesjson.string());
|
||||||
|
|
||||||
if (localOtaVersion >= remoteVersion) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentPresetVersion < remoteVersion)
|
if (currentPresetVersion < remoteVersion)
|
||||||
download_file(fileUrl, fileName);
|
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 (...) {}
|
} catch (...) {}
|
||||||
})
|
})
|
||||||
@@ -1540,6 +1555,26 @@ bool PresetUpdater::install_bundles_rsrc(std::vector<std::string> bundles, bool
|
|||||||
return p->install_bundles_rsrc(bundles, snapshot);
|
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()
|
void PresetUpdater::on_update_notification_confirm()
|
||||||
{
|
{
|
||||||
if (!p->has_waiting_updates)
|
if (!p->has_waiting_updates)
|
||||||
|
|||||||
@@ -65,11 +65,14 @@ public:
|
|||||||
|
|
||||||
void import_flutter_web();
|
void import_flutter_web();
|
||||||
|
|
||||||
|
void sync_config_async();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct priv;
|
struct priv;
|
||||||
std::unique_ptr<priv> p;
|
std::unique_ptr<priv> p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(EVT_NO_PRESET_UPDATE, wxCommandEvent);
|
||||||
wxDECLARE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
|
wxDECLARE_EVENT(EVT_SLIC3R_VERSION_ONLINE, wxCommandEvent);
|
||||||
wxDECLARE_EVENT(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE, wxCommandEvent);
|
wxDECLARE_EVENT(EVT_SLIC3R_EXPERIMENTAL_VERSION_ONLINE, wxCommandEvent);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user