Multiple fixes and refactoring after code review

This commit is contained in:
David Kocik 2024-05-22 17:57:09 +02:00
parent 37d57af09a
commit 900eca8dbb
11 changed files with 58 additions and 197 deletions

View File

@ -3,23 +3,23 @@
"description": "Prusa FFF printers",
"visibility": "",
"id": "prusa-fff",
"url": "http://10.24.3.3:8001/v1/repos/prusa-fff",
"index_url": "http://10.24.3.3:8001/v1/repos/prusa-fff/vendor_indices.zip",
"selected" : 1
"url": "https://preset-repo-api.prusa3d.com/v1/repos/prusa-fff/",
"index_url": "https://preset-repo-api.prusa3d.com/v1/repos/prusa-fff/vendor_indices.zip",
"selected": 1
}, {
"name": "Prusa SLA",
"description": "Prusa SLA printers",
"visibility": "",
"id": "prusa-sla",
"url": "http://10.24.3.3:8001/v1/repos/prusa-sla",
"index_url": "http://10.24.3.3:8001/v1/repos/prusa-sla/vendor_indices.zip",
"selected" : 1
"url": "https://preset-repo-api.prusa3d.com/v1/repos/prusa-sla/",
"index_url": "https://preset-repo-api.prusa3d.com/v1/repos/prusa-sla/vendor_indices.zip",
"selected": 1
}, {
"name": "Non Prusa FFF",
"description": "FFF printers by other vendors",
"visibility": "",
"id": "non-prusa-fff",
"url": "http://10.24.3.3:8001/v1/repos/non-prusa-fff/",
"index_url": "http://10.24.3.3:8001/v1/repos/non-prusa-fff/vendor_indices.zip",
"url": "https://preset-repo-api.prusa3d.com/v1/repos/non-prusa-fff/",
"index_url": "https://preset-repo-api.prusa3d.com/v1/repos/non-prusa-fff/vendor_indices.zip",
"selected": 1
}]

View File

@ -171,11 +171,11 @@ BundleMap BundleMap::load()
fs::path idx_path (archive_dir / (id + ".idx"));
if (!boost::filesystem::exists(idx_path)) {
BOOST_LOG_TRIVIAL(error) << format("Missing index %1% when loading bundle %2%. Going to search for it in cache folder.", idx_path.string(), id);
BOOST_LOG_TRIVIAL(info) << format("Missing index %1% when loading bundle %2%. Going to search for it in cache folder.", idx_path.string(), id);
idx_path = fs::path(cache_dir / (id + ".idx"));
}
if (!boost::filesystem::exists(idx_path)) {
BOOST_LOG_TRIVIAL(error) << format("Missing index %1% when loading bundle %2%. Going to search for it in vendor folder. Is it a 3rd party profile?", idx_path.string(), id);
BOOST_LOG_TRIVIAL(info) << format("Missing index %1% when loading bundle %2%. Going to search for it in vendor folder. Is it a 3rd party profile?", idx_path.string(), id);
idx_path = fs::path(vendor_dir / (id + ".idx"));
}
if (!boost::filesystem::exists(idx_path)) {
@ -229,109 +229,6 @@ BundleMap BundleMap::load()
return res;
}
#if 0
// Reload is a mockup of a function that takes existing BundleMap and reshapes it into current form.
// It would be called after calling preset_updater->sync_blocking() and preset_updater->config_update() instead of fully loading it from scratch.
// Some entries will stop existing because its repositories were unselected.
// Missing: Entries that changed location: e.g. newer ini is now ready in archive_dir, while previously it was in rsrc_vendor_dir
void BundleMap::reload(BundleMap& res)
{
const auto vendor_dir = (boost::filesystem::path(Slic3r::data_dir()) / "vendor").make_preferred();
const auto archive_dir = (boost::filesystem::path(Slic3r::data_dir()) / "cache" / "vendor").make_preferred();
const auto rsrc_vendor_dir = (boost::filesystem::path(resources_dir()) / "profiles").make_preferred();
const auto cache_dir = boost::filesystem::path(Slic3r::data_dir()) / "cache"; // for Index
// Load the other bundles in the datadir/vendor directory
// and then additionally from datadir/cache/vendor (archive) and resources/profiles.
// Should we concider case where archive has older profiles than resources (shouldnt happen)? -> YES, it happens during re-configuration when running older PS after newer version
typedef std::pair<const fs::path&, BundleLocation> DirData;
std::vector<DirData> dir_list{ {vendor_dir, BundleLocation::IN_VENDOR}, {archive_dir, BundleLocation::IN_ARCHIVE}, {rsrc_vendor_dir, BundleLocation::IN_RESOURCES} };
for (auto dir : dir_list) {
if (!fs::exists(dir.first))
continue;
for (const auto& dir_entry : boost::filesystem::directory_iterator(dir.first)) {
if (Slic3r::is_ini_file(dir_entry)) {
std::string id = dir_entry.path().stem().string(); // stem() = filename() without the trailing ".ini" part
// Don't load this bundle if we've already loaded it.
if (res.find(id) != res.end()) { continue; }
// Fresh index should be in archive_dir, otherwise look for it in cache
// Then if not in archive or cache - it could be 3rd party profile that user just copied to vendor folder (both ini and cache)
fs::path idx_path(archive_dir / (id + ".idx"));
if (!boost::filesystem::exists(idx_path)) {
BOOST_LOG_TRIVIAL(error) << format("Missing index %1% when loading bundle %2%. Going to search for it in cache folder.", idx_path.string(), id);
idx_path = fs::path(cache_dir / (id + ".idx"));
}
if (!boost::filesystem::exists(idx_path)) {
BOOST_LOG_TRIVIAL(error) << format("Missing index %1% when loading bundle %2%. Going to search for it in vendor folder. Is it a 3rd party profile?", idx_path.string(), id);
idx_path = fs::path(vendor_dir / (id + ".idx"));
}
if (!boost::filesystem::exists(idx_path)) {
BOOST_LOG_TRIVIAL(error) << format("Could not load bundle %1% due to missing index %2%.", id, idx_path.string());
continue;
}
Slic3r::GUI::Config::Index index;
try {
index.load(idx_path);
}
catch (const std::exception& /* err */) {
BOOST_LOG_TRIVIAL(error) << format("Could not load bundle %1% due to invalid index %2%.", id, idx_path.string());
continue;
}
const auto recommended_it = index.recommended();
if (recommended_it == index.end()) {
BOOST_LOG_TRIVIAL(error) << format("Could not load bundle %1% due to no recommended version in index %2%.", id, idx_path.string());
continue;
}
const auto recommended = recommended_it->config_version;
VendorProfile vp;
try {
vp = VendorProfile::from_ini(dir_entry, true);
}
catch (const std::exception& e) {
BOOST_LOG_TRIVIAL(error) << format("Could not load bundle %1% due to corrupted profile file %2%. Message: %3%", id, dir_entry.path().string(), e.what());
continue;
}
// Don't load
if (vp.config_version > recommended)
continue;
Bundle bundle;
if (bundle.load(dir_entry.path(), dir.second))
res.emplace(std::move(id), std::move(bundle));
}
}
}
// Delete no longer existing entries and not used repos
const PresetArchiveDatabase* pad = wxGetApp().plater()->get_preset_archive_database();
std::vector<std::string> to_erease;
for (const auto& entry : res) {
fs::path ini_path;
switch (entry.second.location) {
case IN_VENDOR: ini_path = vendor_dir / (entry.first + ".ini"); break;
case IN_ARCHIVE: ini_path = archive_dir / (entry.first + ".ini"); break;
case IN_RESOURCES: ini_path = rsrc_vendor_dir / (entry.first + ".ini"); break;
default: assert(true);
}
if (!fs::exists(ini_path)) {
to_erease.emplace_back(entry.first);
continue;
}
if (entry.second.vendor_profile->repo_id.empty() || !pad->is_selected_repository_by_id(entry.second.vendor_profile->repo_id))
{
to_erease.emplace_back(entry.first);
}
}
for (const std::string& id : to_erease)
{
res.erase(id);
}
}
#endif // 0
Bundle& BundleMap::prusa_bundle()
{
@ -732,11 +629,11 @@ PageUpdateManager::PageUpdateManager(ConfigWizard* parent_in)
const int em = em_unit(this);
m_manager = std::make_unique<UIManager>(this, wxGetApp().plater()->get_preset_archive_database(), em);
m_manager = std::make_unique<RepositoryUpdateUIManager>(this, wxGetApp().plater()->get_preset_archive_database(), em);
auto sizer = m_manager->get_sizer();
ScalableButton* btn = new ScalableButton(this, wxID_ANY, "", " " + _L("Confirm configuration update") + " ");
wxButton* btn = new wxButton(this, wxID_ANY, " " + _L("Confirm configuration update") + " ");
btn->SetFont(wxGetApp().bold_font());
wxGetApp().UpdateDarkUI(btn, true);
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) {

View File

@ -97,7 +97,7 @@ struct BundleMap : std::map<std::string /* = vendor ID */, Bundle>
struct Materials;
class UIManager;
class RepositoryUpdateUIManager;
struct PrinterPickerEvent;
@ -187,7 +187,7 @@ struct PageWelcome: ConfigWizardPage
struct PageUpdateManager : ConfigWizardPage
{
std::unique_ptr<UIManager> m_manager;
std::unique_ptr<RepositoryUpdateUIManager> m_manager;
PageUpdateManager(ConfigWizard* parent);
};

View File

@ -2569,7 +2569,6 @@ 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 + ConfigMenuManageUpdateConf, _L("Manage Configuration Updates"), _L("Manage Configuration Updates"));
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)
@ -2601,9 +2600,6 @@ wxMenu* GUI_App::get_config_menu()
case ConfigMenuWizard:
run_wizard(ConfigWizard::RR_USER);
break;
case ConfigMenuManageUpdateConf:
manage_updates();
break;
case ConfigMenuUpdateConf:
check_updates(true);
break;
@ -3226,7 +3222,6 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
m_login_dialog.reset();
}
#endif // 0
plater()->get_preset_archive_database()->set_wizard_lock(true);
plater()->get_preset_archive_database()->sync_blocking();
auto wizard = new ConfigWizard(mainframe);
@ -3246,7 +3241,6 @@ bool GUI_App::run_wizard(ConfigWizard::RunReason reason, ConfigWizard::StartPage
if (preset_bundle->printers.get_edited_preset().printer_technology() == ptSLA)
may_switch_to_SLA_preset(_L("Configuration is editing from ConfigWizard"));
}
plater()->get_preset_archive_database()->set_wizard_lock(false);
return res;
}
@ -3451,23 +3445,22 @@ bool GUI_App::config_wizard_startup()
return false;
}
void GUI_App::manage_updates()
void GUI_App::manage_preset_repositiories()
{
ManageUpdatesDialog dlg(plater()->get_preset_archive_database());
ManagePresetRepositoriesDialog dlg(plater()->get_preset_archive_database());
dlg.ShowModal();
}
bool GUI_App::check_updates(const bool verbose)
bool GUI_App::check_updates(const bool invoked_automatically)
{
// verbose means - not run after startup, but by user
if (verbose) {
if (invoked_automatically) {
// 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)
manage_updates();
manage_preset_repositiories();
// then its time for preset_updater sync
// BE CAREFUL! sync and sync_blocking sends event that calls check_updates(false)
preset_updater->sync_blocking(preset_bundle, this, plater()->get_preset_archive_database()->get_archive_repositories(), plater()->get_preset_archive_database()->get_selected_repositories_uuid());
// and then we check updates
}
@ -3475,7 +3468,7 @@ bool GUI_App::check_updates(const bool verbose)
PresetUpdater::UpdateResult updater_result;
try {
preset_updater->update_index_db();
updater_result = preset_updater->config_update(app_config->orig_version(), verbose ? PresetUpdater::UpdateParams::SHOW_TEXT_BOX : PresetUpdater::UpdateParams::SHOW_NOTIFICATION, plater()->get_preset_archive_database()->get_archive_repositories());
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_archive_repositories());
if (updater_result == PresetUpdater::R_INCOMPAT_EXIT) {
mainframe->Close();
// Applicaiton is closing.
@ -3484,7 +3477,7 @@ bool GUI_App::check_updates(const bool verbose)
else if (updater_result == PresetUpdater::R_INCOMPAT_CONFIGURED) {
m_app_conf_exists = true;
}
else if (verbose && updater_result == PresetUpdater::R_NOOP) {
else if (invoked_automatically && updater_result == PresetUpdater::R_NOOP) {
MsgNoUpdates dlg;
dlg.ShowModal();
}

View File

@ -96,7 +96,6 @@ enum ConfigMenuIDs {
ConfigMenuWizard,
ConfigMenuSnapshots,
ConfigMenuTakeSnapshot,
ConfigMenuManageUpdateConf,
ConfigMenuUpdateConf,
ConfigMenuUpdateApp,
ConfigMenuDesktopIntegration,
@ -441,10 +440,10 @@ private:
bool select_language();
bool config_wizard_startup();
void manage_updates();
void manage_preset_repositiories();
// Returns true if the configuration is fine.
// Returns true if the configuration is not compatible and the user decided to rather close the slicer instead of reconfiguring.
bool check_updates(const bool verbose);
bool check_updates(const bool invoked_automatically);
void on_version_read(wxCommandEvent& evt);
// if the data from version file are already downloaded, shows dialogs to start download of new version of app
void app_updater(bool from_user);

View File

@ -909,7 +909,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
wxGetApp().update_login_dialog();
#endif // 0
this->show_action_buttons(this->ready_to_slice);
preset_archive_database->set_access_token(user_account->get_access_token());
} else {
// data were corrupt and username was not retrieved
@ -923,7 +922,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
this->main_frame->refresh_account_menu(true);
// Update sidebar printer status
sidebar->update_printer_presets_combobox();
preset_archive_database->set_access_token({});
}
});
@ -937,7 +935,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
this->main_frame->refresh_account_menu(true);
// Update sidebar printer status
sidebar->update_printer_presets_combobox();
preset_archive_database->set_access_token({});
});
this->q->Bind(EVT_UA_FAIL, [this](UserAccountFailEvent& evt) {
BOOST_LOG_TRIVIAL(error) << "Failed communication with Prusa Account: " << evt.data;

View File

@ -660,15 +660,14 @@ std::string PresetArchiveDatabase::get_next_uuid()
}
namespace {
bool sync_inner(const std::string& token, std::string& manifest)
bool sync_inner(std::string& manifest)
{
bool ret = false;
#ifdef SLIC3R_REPO_URL
std::string url = SLIC3R_REPO_URL;
#else
std::string url = "http://10.24.3.3:8001/v1/repos";
std::string url = "https://preset-repo-api-stage.prusa3d.com/v1/repos";
#endif
// TODO: use token
auto http = Http::get(std::move(url));
add_authorization_header(http);
http
@ -688,23 +687,11 @@ bool sync_inner(const std::string& token, std::string& manifest)
void PresetArchiveDatabase::sync_blocking()
{
if (m_wizard_lock) {
m_staged_sync = true;
return;
}
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " " << std::this_thread::get_id();
std::string manifest;
if (!sync_inner(m_token, manifest))
if (!sync_inner(manifest))
return;
read_server_manifest(std::move(manifest));
}
void PresetArchiveDatabase::set_wizard_lock(bool lock)
{
m_wizard_lock = lock;
if (m_staged_sync) {
sync_blocking();
}
m_staged_sync = false;
}
}} // Slic3r::GUI

View File

@ -100,23 +100,20 @@ class PresetArchiveDatabase
public:
PresetArchiveDatabase(AppConfig* app_config, wxEvtHandler* evt_handler);
~PresetArchiveDatabase() {}
const ArchiveRepositoryVector& get_archive_repositories() const { return m_archive_repositories; }
void set_access_token(const std::string& token) { m_token = token; }
void sync_blocking();
//void set_local_archives(AppConfig* app_config);
void read_server_manifest(const std::string& json_body);
const ArchiveRepositoryVector& get_archive_repositories() const { return m_archive_repositories; }
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<std::string, bool>& get_selected_repositories_uuid() const { assert(m_selected_repositories_uuid.size() == m_archive_repositories.size()); return m_selected_repositories_uuid; }
bool set_selected_repositories(const std::vector<std::string>& used_uuids, std::string& msg);
std::string add_local_archive(const boost::filesystem::path path, std::string& msg);
void remove_local_archive(const std::string& uuid);
// should be called only from main UI thread.
void set_wizard_lock(bool lock);
private:
void load_app_manifest_json();
void copy_initial_manifest();
void read_server_manifest(const std::string& json_body);
void save_app_manifest_json() const;
void clear_online_repos();
bool is_selected(const std::string& id) const;
@ -127,10 +124,7 @@ private:
boost::filesystem::path m_unq_tmp_path;
ArchiveRepositoryVector m_archive_repositories;
std::map<std::string, bool> m_selected_repositories_uuid;
std::string m_token;
boost::uuids::random_generator m_uuid_generator;
bool m_wizard_lock { false };
bool m_staged_sync { false };
};
}} // Slic3r::GUI

View File

@ -20,7 +20,7 @@ namespace fs = boost::filesystem;
namespace Slic3r {
namespace GUI {
UIManager::UIManager(wxWindow* parent, PresetArchiveDatabase* pad, int em) :
RepositoryUpdateUIManager::RepositoryUpdateUIManager(wxWindow* parent, PresetArchiveDatabase* pad, int em) :
m_parent(parent)
,m_pad(pad)
,m_main_sizer(new wxBoxSizer(wxVERTICAL))
@ -56,7 +56,7 @@ UIManager::UIManager(wxWindow* parent, PresetArchiveDatabase* pad, int em) :
fill_grids();
}
void UIManager::fill_entries(bool init_selection/* = false*/)
void RepositoryUpdateUIManager::fill_entries(bool init_selection/* = false*/)
{
m_online_entries.clear();
m_offline_entries.clear();
@ -82,7 +82,7 @@ void UIManager::fill_entries(bool init_selection/* = false*/)
}
void UIManager::fill_grids()
void RepositoryUpdateUIManager::fill_grids()
{
// clear grids
m_online_sizer->Clear(true);
@ -169,7 +169,7 @@ void UIManager::fill_grids()
add(new wxStaticText(m_parent, wxID_ANY, from_u8(entry.source)));
{
ScalableButton* btn = new ScalableButton(m_parent, wxID_ANY, "", " " + _L("Remove") + " ");
wxButton* btn = new wxButton(m_parent, wxID_ANY, " " + _L("Remove") + " ");
wxGetApp().UpdateDarkUI(btn, true);
btn->Bind(wxEVT_BUTTON, [this, &entry](wxCommandEvent& event) { remove_offline_repos(entry.id); });
add(btn);
@ -178,7 +178,7 @@ void UIManager::fill_grids()
}
{
ScalableButton* btn = new ScalableButton(m_parent, wxID_ANY, "", " " + _L("Load") + "... ");
wxButton* btn = new wxButton(m_parent, wxID_ANY, " " + _L("Load") + "... ");
wxGetApp().UpdateDarkUI(btn, true);
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { load_offline_repos(); });
m_offline_sizer->Add(btn);
@ -186,7 +186,7 @@ void UIManager::fill_grids()
}
void UIManager::update()
void RepositoryUpdateUIManager::update()
{
fill_entries();
@ -207,7 +207,7 @@ void UIManager::update()
}
}
void UIManager::remove_offline_repos(const std::string& id)
void RepositoryUpdateUIManager::remove_offline_repos(const std::string& id)
{
m_pad->remove_local_archive(id);
m_selected_uuids.erase(id);
@ -220,10 +220,10 @@ void UIManager::remove_offline_repos(const std::string& id)
update();
}
void UIManager::load_offline_repos()
void RepositoryUpdateUIManager::load_offline_repos()
{
wxArrayString input_files;
wxFileDialog dialog(m_parent, _L("Choose one or more YIP-files") + ":",
wxFileDialog dialog(m_parent, _L("Choose one or more ZIP-files") + ":",
from_u8(wxGetApp().app_config->get_last_dir()), "",
file_wildcards(FT_ZIP), wxFD_OPEN | /*wxFD_MULTIPLE | */wxFD_FILE_MUST_EXIST);
@ -254,7 +254,7 @@ void UIManager::load_offline_repos()
}
}
bool UIManager::set_selected_repositories()
bool RepositoryUpdateUIManager::set_selected_repositories()
{
std::vector<std::string> used_ids;
std::copy(m_selected_uuids.begin(), m_selected_uuids.end(), std::back_inserter(used_ids));
@ -270,7 +270,7 @@ bool UIManager::set_selected_repositories()
}
ManageUpdatesDialog::ManageUpdatesDialog(PresetArchiveDatabase* pad)
ManagePresetRepositoriesDialog::ManagePresetRepositoriesDialog(PresetArchiveDatabase* pad)
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY,
format_wxstr("%1% - %2%", SLIC3R_APP_NAME, _L("Manage Updates")),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
@ -278,7 +278,7 @@ ManageUpdatesDialog::ManageUpdatesDialog(PresetArchiveDatabase* pad)
this->SetFont(wxGetApp().normal_font());
const int em = em_unit();
m_manager = std::make_unique<UIManager>(this, pad, em);
m_manager = std::make_unique<RepositoryUpdateUIManager>(this, pad, em);
auto sizer = m_manager->get_sizer();
@ -286,27 +286,27 @@ ManageUpdatesDialog::ManageUpdatesDialog(PresetArchiveDatabase* pad)
wxGetApp().SetWindowVariantForButton(buttons->GetCancelButton());
wxGetApp().UpdateDlgDarkUI(this, true);
this->SetEscapeId(wxID_CLOSE);
this->Bind(wxEVT_BUTTON, &ManageUpdatesDialog::onCloseDialog, this, wxID_CLOSE);
this->Bind(wxEVT_BUTTON, &ManageUpdatesDialog::onOkDialog, this, wxID_OK);
this->Bind(wxEVT_BUTTON, &ManagePresetRepositoriesDialog::onCloseDialog, this, wxID_CLOSE);
this->Bind(wxEVT_BUTTON, &ManagePresetRepositoriesDialog::onOkDialog, this, wxID_OK);
sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, em);
SetSizer(sizer);
sizer->SetSizeHints(this);
}
void ManageUpdatesDialog::on_dpi_changed(const wxRect &suggested_rect)
void ManagePresetRepositoriesDialog::on_dpi_changed(const wxRect &suggested_rect)
{
SetMinSize(GetBestSize());
Fit();
Refresh();
}
void ManageUpdatesDialog::onCloseDialog(wxEvent &)
void ManagePresetRepositoriesDialog::onCloseDialog(wxEvent &)
{
this->EndModal(wxID_CLOSE);
}
void ManageUpdatesDialog::onOkDialog(wxEvent&)
void ManagePresetRepositoriesDialog::onOkDialog(wxEvent&)
{
if (m_manager->set_selected_repositories())
this->EndModal(wxID_CLOSE);

View File

@ -15,7 +15,7 @@ namespace GUI {
class PresetArchiveDatabase;
class UIManager
class RepositoryUpdateUIManager
{
struct OnlineEntry {
OnlineEntry(bool use, const std::string &id, const std::string &name, const std::string &description, const std::string &visibility) :
@ -61,26 +61,26 @@ class UIManager
void load_offline_repos();
public:
UIManager() {}
UIManager(wxWindow* parent, PresetArchiveDatabase* pad, int em);
~UIManager() {}
RepositoryUpdateUIManager() {}
RepositoryUpdateUIManager(wxWindow* parent, PresetArchiveDatabase* pad, int em);
~RepositoryUpdateUIManager() {}
wxSizer* get_sizer() { return m_main_sizer; }
bool set_selected_repositories();
};
class ManageUpdatesDialog : public DPIDialog
class ManagePresetRepositoriesDialog : public DPIDialog
{
public:
ManageUpdatesDialog(PresetArchiveDatabase* pad);
~ManageUpdatesDialog() {}
ManagePresetRepositoriesDialog(PresetArchiveDatabase* pad);
~ManagePresetRepositoriesDialog() {}
protected:
void on_dpi_changed(const wxRect &suggested_rect) override;
private:
std::unique_ptr<UIManager> m_manager { nullptr };
std::unique_ptr<RepositoryUpdateUIManager> m_manager { nullptr };
void onCloseDialog(wxEvent &);
void onOkDialog(wxEvent &);

View File

@ -286,11 +286,7 @@ void PresetUpdater::priv::get_missing_resource(const GUI::ArchiveRepository& arc
// gets resource to vendor/<vendor_name>/
void PresetUpdater::priv::get_or_copy_missing_resource(const GUI::ArchiveRepository& archive, const std::string& vendor, const std::string& filename, const std::string& repository_id_from_ini) const
{
assert(!filename.empty() && !vendor.empty() /*&& !repository_id_from_ini.empty()*/);
//if (filename.empty() || vendor.empty()) {
// BOOST_LOG_TRIVIAL(error) << "PresetUpdater::get_or_copy_missing_resource - wrong input. vendor: " << vendor << " filename: " << filename;
// return;
//}
assert(!filename.empty() && !vendor.empty());
const fs::path file_in_vendor(vendor_path / (vendor + "/" + filename));
const fs::path file_in_rsrc(rsrc_path / (vendor + "/" + filename));
@ -337,7 +333,7 @@ void PresetUpdater::priv::sync_config(const VendorMap& vendors, const GUI::Archi
return;
}
if (cancel) {
return;
return;
}
enum class VendorStatus
@ -1138,8 +1134,6 @@ void PresetUpdater::sync_blocking(const PresetBundle* preset_bundle, wxEvtHandle
this->p->sync_config(preset_bundle->vendors, *archive);
}
}
wxCommandEvent* evt = new wxCommandEvent(EVT_CONFIG_UPDATER_SYNC_DONE);
evt_handler->QueueEvent(evt);
}
void PresetUpdater::slic3r_update_notify()