diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 2d7156eb03..fd4b777d30 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -648,6 +648,12 @@ PageUpdateManager::PageUpdateManager(ConfigWizard* parent_in) if (m_manager->set_selected_repositories()) wizard_p()->set_config_updated_from_archive(true); }); + btn->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& event) { + const bool is_actual_archive_selection = wizard_p()->is_actual_archive_selection; + const bool is_selection_changed = m_manager->is_selection_changed(); + const bool has_selections = m_manager->has_selections(); + event.Enable(!is_actual_archive_selection || (is_selection_changed && has_selections)); + }); sizer->Add(btn, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, em); @@ -3583,6 +3589,8 @@ void ConfigWizard::priv::load_pages_from_archive() only_sla_mode = true; bool is_primary_printer_page_set = false; + is_actual_archive_selection = true; + for (const auto& archive : archs) { const auto& data = archive->get_manifest(); const bool is_selected_arch = pad->is_selected_repository_by_uuid(archive->get_uuid()); @@ -3595,6 +3603,11 @@ void ConfigWizard::priv::load_pages_from_archive() if (is_already_added_repo || (!is_selected_arch && !any_installed_vendor)) continue; + if (!is_selected_arch && any_installed_vendor) { + // ys/dkFIXME - There is a case, when local and web archives have a same repo_id and + // some of them isn't selected but is processed as first + is_actual_archive_selection = false; + } Pages3rdparty pages; diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp index 28a5d81218..d5c50e0ea6 100644 --- a/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/src/slic3r/GUI/ConfigWizard_private.hpp @@ -662,6 +662,7 @@ struct ConfigWizard::priv std::vector repositories; bool is_config_from_archive{ false }; + bool is_actual_archive_selection{ true }; // Pointers to all pages (regardless or whether currently part of the ConfigWizardIndex) std::vector all_pages; diff --git a/src/slic3r/GUI/UpdatesUIManager.cpp b/src/slic3r/GUI/UpdatesUIManager.cpp index e0669d2f3d..dedaa80853 100644 --- a/src/slic3r/GUI/UpdatesUIManager.cpp +++ b/src/slic3r/GUI/UpdatesUIManager.cpp @@ -113,6 +113,7 @@ void RepositoryUpdateUIManager::fill_grids() m_selected_uuids.emplace(entry.id); else m_selected_uuids.erase(entry.id); + check_selection(); }); add(chb); @@ -153,6 +154,7 @@ void RepositoryUpdateUIManager::fill_grids() m_selected_uuids.emplace(entry.id); else m_selected_uuids.erase(entry.id); + check_selection(); }); add(chb); @@ -211,6 +213,7 @@ void RepositoryUpdateUIManager::remove_offline_repos(const std::string& id) { m_pad->remove_local_archive(id); m_selected_uuids.erase(id); + check_selection(); if (wxDialog* dlg = dynamic_cast(m_parent)) { // Invalidate min_size for correct next Layout() @@ -245,6 +248,7 @@ void RepositoryUpdateUIManager::load_offline_repos() } else { m_selected_uuids.emplace(uuid); + check_selection(); update(); } } @@ -260,15 +264,30 @@ bool RepositoryUpdateUIManager::set_selected_repositories() std::copy(m_selected_uuids.begin(), m_selected_uuids.end(), std::back_inserter(used_ids)); std::string msg; - if (m_pad->set_selected_repositories(used_ids, msg)) + + if (m_pad->set_selected_repositories(used_ids, msg)) { + check_selection(); return true; + } ErrorDialog(m_parent, msg, false).ShowModal(); // update selection on UI update(); + check_selection(); return false; } +void RepositoryUpdateUIManager::check_selection() +{ + for (const auto& [uuid, is_selected] : m_pad->get_selected_repositories_uuid() ) + if (is_selected && m_selected_uuids.find(uuid) == m_selected_uuids.end() || + !is_selected && m_selected_uuids.find(uuid) != m_selected_uuids.end()) { + m_is_selection_changed = true; + return; + } + + m_is_selection_changed = false; +} ManagePresetRepositoriesDialog::ManagePresetRepositoriesDialog(PresetArchiveDatabase* pad) : DPIDialog(static_cast(wxGetApp().mainframe), wxID_ANY, @@ -290,6 +309,11 @@ ManagePresetRepositoriesDialog::ManagePresetRepositoriesDialog(PresetArchiveData this->Bind(wxEVT_BUTTON, &ManagePresetRepositoriesDialog::onOkDialog, this, wxID_OK); sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, em); + + buttons->GetAffirmativeButton()->Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& event) { + event.Enable(m_manager->is_selection_changed() && m_manager->has_selections()); + }); + SetSizer(sizer); sizer->SetSizeHints(this); } diff --git a/src/slic3r/GUI/UpdatesUIManager.hpp b/src/slic3r/GUI/UpdatesUIManager.hpp index 4245b75849..4f01ef6fd5 100644 --- a/src/slic3r/GUI/UpdatesUIManager.hpp +++ b/src/slic3r/GUI/UpdatesUIManager.hpp @@ -51,6 +51,7 @@ class RepositoryUpdateUIManager std::vector m_offline_entries; std::set m_selected_uuids; + bool m_is_selection_changed{false}; void fill_entries(bool init_selection = false); void fill_grids(); @@ -59,6 +60,7 @@ class RepositoryUpdateUIManager void remove_offline_repos(const std::string& id); void load_offline_repos(); + void check_selection(); public: RepositoryUpdateUIManager() {} @@ -67,6 +69,8 @@ public: wxSizer* get_sizer() { return m_main_sizer; } bool set_selected_repositories(); + bool is_selection_changed() const { return m_is_selection_changed; } + bool has_selections() const { return !m_selected_uuids.empty(); } }; class ManagePresetRepositoriesDialog : public DPIDialog