From 983e1e1b6cf8719a87a3440abada99d428980120 Mon Sep 17 00:00:00 2001 From: David Kocik Date: Fri, 7 Jun 2024 13:14:19 +0200 Subject: [PATCH] Return Check for Config updates button. But remove the repository management of it. Do repo extraction before check. --- src/slic3r/GUI/GUI_App.cpp | 23 ++++++++++++++--------- src/slic3r/GUI/GUI_App.hpp | 1 + src/slic3r/GUI/PresetArchiveDatabase.cpp | 24 ++++++++++++++++++++++++ src/slic3r/GUI/PresetArchiveDatabase.hpp | 4 +++- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 803a342a69..e836a46745 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2569,6 +2569,7 @@ wxMenu* GUI_App::get_config_menu() local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_name + dots, config_wizard_tooltip); local_menu->Append(config_id_base + ConfigMenuSnapshots, _L("&Configuration Snapshots") + dots, _L("Inspect / activate configuration snapshots")); local_menu->Append(config_id_base + ConfigMenuTakeSnapshot, _L("Take Configuration &Snapshot"), _L("Capture a configuration snapshot")); + local_menu->Append(config_id_base + ConfigMenuUpdateConf, _L("Check for Configuration Updates"), _L("Check for configuration updates")); local_menu->Append(config_id_base + ConfigMenuUpdateApp, _L("Check for Application Updates"), _L("Check for new version of application")); #if defined(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION) //if (DesktopIntegrationDialog::integration_possible()) @@ -2599,6 +2600,9 @@ wxMenu* GUI_App::get_config_menu() case ConfigMenuWizard: run_wizard(ConfigWizard::RR_USER); break; + case ConfigMenuUpdateConf: + check_updates(true); + break; case ConfigMenuUpdateApp: app_version_check(true); break; @@ -3451,17 +3455,18 @@ bool GUI_App::config_wizard_startup() return false; } -bool GUI_App::check_updates(const bool invoked_automatically) +bool GUI_App::check_updates(const bool invoked_by_user) { - // verbose means - not run after startup, but by user - if (invoked_automatically) { + if (invoked_by_user) { // do preset_updater sync so if user runs slicer for a long time, check for updates actually delivers updates. // for preset_updater sync we need to sync archive database first plater()->get_preset_archive_database()->sync_blocking(); - // and we can have user to select the repos they want (thats additional dialog) - ManagePresetRepositoriesDialog dlg(plater()->get_preset_archive_database()); - if (dlg.ShowModal() != wxID_OK) - return true; + // Now re-extract offline repos + std::string extract_msg; + if (!plater()->get_preset_archive_database()->extract_archives_with_check(extract_msg)) { + extract_msg = GUI::format("%1%\n\n%2%", _L("Following repositories won't be updated:"), extract_msg); + show_error(nullptr, extract_msg); + } // then its time for preset_updater sync preset_updater->sync_blocking(preset_bundle, this, plater()->get_preset_archive_database()->get_selected_archive_repositories()); // and then we check updates @@ -3470,7 +3475,7 @@ bool GUI_App::check_updates(const bool invoked_automatically) PresetUpdater::UpdateResult updater_result; try { preset_updater->update_index_db(); - updater_result = preset_updater->config_update(app_config->orig_version(), invoked_automatically ? PresetUpdater::UpdateParams::SHOW_TEXT_BOX : PresetUpdater::UpdateParams::SHOW_NOTIFICATION, plater()->get_preset_archive_database()->get_selected_archive_repositories()); + updater_result = preset_updater->config_update(app_config->orig_version(), invoked_by_user ? PresetUpdater::UpdateParams::SHOW_TEXT_BOX : PresetUpdater::UpdateParams::SHOW_NOTIFICATION, plater()->get_preset_archive_database()->get_selected_archive_repositories()); if (updater_result == PresetUpdater::R_INCOMPAT_EXIT) { mainframe->Close(); // Applicaiton is closing. @@ -3479,7 +3484,7 @@ bool GUI_App::check_updates(const bool invoked_automatically) else if (updater_result == PresetUpdater::R_INCOMPAT_CONFIGURED) { m_app_conf_exists = true; } - else if (invoked_automatically && updater_result == PresetUpdater::R_NOOP) { + else if (invoked_by_user && updater_result == PresetUpdater::R_NOOP) { MsgNoUpdates dlg; dlg.ShowModal(); } diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 92c04f6d28..e540394f7f 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -96,6 +96,7 @@ enum ConfigMenuIDs { ConfigMenuWizard, ConfigMenuSnapshots, ConfigMenuTakeSnapshot, + ConfigMenuUpdateConf, ConfigMenuUpdateApp, ConfigMenuDesktopIntegration, ConfigMenuPreferences, diff --git a/src/slic3r/GUI/PresetArchiveDatabase.cpp b/src/slic3r/GUI/PresetArchiveDatabase.cpp index c05b5c80a9..51a1ce8a6e 100644 --- a/src/slic3r/GUI/PresetArchiveDatabase.cpp +++ b/src/slic3r/GUI/PresetArchiveDatabase.cpp @@ -378,6 +378,30 @@ bool PresetArchiveDatabase::set_selected_repositories(const std::vector &repo) { + return repo->get_uuid() == uuid; + }; + + const auto& archives_it =std::find_if(m_archive_repositories.begin(), m_archive_repositories.end(), compare_repo); + assert(archives_it != m_archive_repositories.end()); + if (!archives_it->get()->is_extracted()) { + // non existent local repo since start selected + msg += GUI::format( + _L("Offline repository from path: %1% was not extracted.\n"), + archives_it->get()->get_manifest().source_path + ); + } + } + return msg.empty(); +} void PresetArchiveDatabase::set_installed_printer_repositories(const std::vector &used_ids) { // set all uuids as not having installed printer diff --git a/src/slic3r/GUI/PresetArchiveDatabase.hpp b/src/slic3r/GUI/PresetArchiveDatabase.hpp index c693632f96..93284339cc 100644 --- a/src/slic3r/GUI/PresetArchiveDatabase.hpp +++ b/src/slic3r/GUI/PresetArchiveDatabase.hpp @@ -155,11 +155,13 @@ public: bool is_selected_repository_by_uuid(const std::string& uuid) const; bool is_selected_repository_by_id(const std::string& repo_id) const; const std::map& get_selected_repositories_uuid() const { assert(m_selected_repositories_uuid.size() == m_archive_repositories.size()); return m_selected_repositories_uuid; } - // Does re-estract all local archives + // Does re-extract all local archives bool set_selected_repositories(const std::vector& used_uuids, std::string& msg); void set_installed_printer_repositories(const std::vector &used_ids); std::string add_local_archive(const boost::filesystem::path path, std::string& msg); void remove_local_archive(const std::string& uuid); + bool extract_archives_with_check(std::string &msg); + private: void load_app_manifest_json(); void copy_initial_manifest();