mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-31 20:02:00 +08:00
ConfigWizard and ManageUpdatesDialog: Enable "confirm" buttons in respect to the changed selections
This commit is contained in:
parent
944e5f6d79
commit
c325bb0629
@ -648,6 +648,12 @@ PageUpdateManager::PageUpdateManager(ConfigWizard* parent_in)
|
|||||||
if (m_manager->set_selected_repositories())
|
if (m_manager->set_selected_repositories())
|
||||||
wizard_p()->set_config_updated_from_archive(true);
|
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);
|
sizer->Add(btn, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, em);
|
||||||
|
|
||||||
@ -3583,6 +3589,8 @@ void ConfigWizard::priv::load_pages_from_archive()
|
|||||||
only_sla_mode = true;
|
only_sla_mode = true;
|
||||||
bool is_primary_printer_page_set = false;
|
bool is_primary_printer_page_set = false;
|
||||||
|
|
||||||
|
is_actual_archive_selection = true;
|
||||||
|
|
||||||
for (const auto& archive : archs) {
|
for (const auto& archive : archs) {
|
||||||
const auto& data = archive->get_manifest();
|
const auto& data = archive->get_manifest();
|
||||||
const bool is_selected_arch = pad->is_selected_repository_by_uuid(archive->get_uuid());
|
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))
|
if (is_already_added_repo || (!is_selected_arch && !any_installed_vendor))
|
||||||
continue;
|
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;
|
Pages3rdparty pages;
|
||||||
|
|
||||||
|
@ -662,6 +662,7 @@ struct ConfigWizard::priv
|
|||||||
std::vector<Repository> repositories;
|
std::vector<Repository> repositories;
|
||||||
|
|
||||||
bool is_config_from_archive{ false };
|
bool is_config_from_archive{ false };
|
||||||
|
bool is_actual_archive_selection{ true };
|
||||||
|
|
||||||
// Pointers to all pages (regardless or whether currently part of the ConfigWizardIndex)
|
// Pointers to all pages (regardless or whether currently part of the ConfigWizardIndex)
|
||||||
std::vector<ConfigWizardPage*> all_pages;
|
std::vector<ConfigWizardPage*> all_pages;
|
||||||
|
@ -113,6 +113,7 @@ void RepositoryUpdateUIManager::fill_grids()
|
|||||||
m_selected_uuids.emplace(entry.id);
|
m_selected_uuids.emplace(entry.id);
|
||||||
else
|
else
|
||||||
m_selected_uuids.erase(entry.id);
|
m_selected_uuids.erase(entry.id);
|
||||||
|
check_selection();
|
||||||
});
|
});
|
||||||
add(chb);
|
add(chb);
|
||||||
|
|
||||||
@ -153,6 +154,7 @@ void RepositoryUpdateUIManager::fill_grids()
|
|||||||
m_selected_uuids.emplace(entry.id);
|
m_selected_uuids.emplace(entry.id);
|
||||||
else
|
else
|
||||||
m_selected_uuids.erase(entry.id);
|
m_selected_uuids.erase(entry.id);
|
||||||
|
check_selection();
|
||||||
});
|
});
|
||||||
add(chb);
|
add(chb);
|
||||||
|
|
||||||
@ -211,6 +213,7 @@ void RepositoryUpdateUIManager::remove_offline_repos(const std::string& id)
|
|||||||
{
|
{
|
||||||
m_pad->remove_local_archive(id);
|
m_pad->remove_local_archive(id);
|
||||||
m_selected_uuids.erase(id);
|
m_selected_uuids.erase(id);
|
||||||
|
check_selection();
|
||||||
|
|
||||||
if (wxDialog* dlg = dynamic_cast<wxDialog*>(m_parent)) {
|
if (wxDialog* dlg = dynamic_cast<wxDialog*>(m_parent)) {
|
||||||
// Invalidate min_size for correct next Layout()
|
// Invalidate min_size for correct next Layout()
|
||||||
@ -245,6 +248,7 @@ void RepositoryUpdateUIManager::load_offline_repos()
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_selected_uuids.emplace(uuid);
|
m_selected_uuids.emplace(uuid);
|
||||||
|
check_selection();
|
||||||
update();
|
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::copy(m_selected_uuids.begin(), m_selected_uuids.end(), std::back_inserter(used_ids));
|
||||||
|
|
||||||
std::string msg;
|
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;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ErrorDialog(m_parent, msg, false).ShowModal();
|
ErrorDialog(m_parent, msg, false).ShowModal();
|
||||||
// update selection on UI
|
// update selection on UI
|
||||||
update();
|
update();
|
||||||
|
check_selection();
|
||||||
return false;
|
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)
|
ManagePresetRepositoriesDialog::ManagePresetRepositoriesDialog(PresetArchiveDatabase* pad)
|
||||||
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY,
|
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY,
|
||||||
@ -290,6 +309,11 @@ ManagePresetRepositoriesDialog::ManagePresetRepositoriesDialog(PresetArchiveData
|
|||||||
this->Bind(wxEVT_BUTTON, &ManagePresetRepositoriesDialog::onOkDialog, this, wxID_OK);
|
this->Bind(wxEVT_BUTTON, &ManagePresetRepositoriesDialog::onOkDialog, this, wxID_OK);
|
||||||
sizer->Add(buttons, 0, wxALIGN_CENTER_HORIZONTAL | wxBOTTOM, em);
|
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);
|
SetSizer(sizer);
|
||||||
sizer->SetSizeHints(this);
|
sizer->SetSizeHints(this);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ class RepositoryUpdateUIManager
|
|||||||
std::vector<OfflineEntry> m_offline_entries;
|
std::vector<OfflineEntry> m_offline_entries;
|
||||||
|
|
||||||
std::set<std::string> m_selected_uuids;
|
std::set<std::string> m_selected_uuids;
|
||||||
|
bool m_is_selection_changed{false};
|
||||||
|
|
||||||
void fill_entries(bool init_selection = false);
|
void fill_entries(bool init_selection = false);
|
||||||
void fill_grids();
|
void fill_grids();
|
||||||
@ -59,6 +60,7 @@ class RepositoryUpdateUIManager
|
|||||||
|
|
||||||
void remove_offline_repos(const std::string& id);
|
void remove_offline_repos(const std::string& id);
|
||||||
void load_offline_repos();
|
void load_offline_repos();
|
||||||
|
void check_selection();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RepositoryUpdateUIManager() {}
|
RepositoryUpdateUIManager() {}
|
||||||
@ -67,6 +69,8 @@ public:
|
|||||||
|
|
||||||
wxSizer* get_sizer() { return m_main_sizer; }
|
wxSizer* get_sizer() { return m_main_sizer; }
|
||||||
bool set_selected_repositories();
|
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
|
class ManagePresetRepositoriesDialog : public DPIDialog
|
||||||
|
Loading…
x
Reference in New Issue
Block a user