ConfigWizard: Show warning dialog when switching from the "Configuration Manager" page

+ Added "Open folder" button next to the repository path and show tooltips for both of them.
+ Deleted "Check for Configuration Updates" menu item
This commit is contained in:
YuSanka 2024-06-06 12:22:10 +02:00
parent de32cd70de
commit 89a70e7b94
6 changed files with 75 additions and 14 deletions

View File

@ -681,9 +681,13 @@ PageUpdateManager::PageUpdateManager(ConfigWizard* parent_in)
if (wizard_p()->is_first_start)
wizard_p()->is_first_start = false;
wxBusyCursor wait;
if (manager->set_selected_repositories())
wizard_p()->set_config_updated_from_archive(true);
if (wizard_p()->can_clear_printer_pages()) {
wxBusyCursor wait;
if (manager->set_selected_repositories())
wizard_p()->set_config_updated_from_archive(true);
else
CallAfter([this]() { wizard_p()->index->go_to(1); });
}
else
CallAfter([this]() { wizard_p()->index->go_to(1); });
}
@ -3658,6 +3662,23 @@ bool ConfigWizard::priv::any_installed_vendor_for_repo(const std::string& repo_i
return false;
}
static bool to_delete(PagePrinters* page, const std::set<std::string>& selected_uuids)
{
const PresetArchiveDatabase* pad = wxGetApp().plater()->get_preset_archive_database();
const ArchiveRepositoryVector& archs = pad->get_archive_repositories();
bool unselect_all = true;
for (const auto& archive : archs) {
if (page->get_vendor_repo_id() == archive->get_manifest().id) {
if (selected_uuids.find(archive->get_uuid()) != selected_uuids.end())
unselect_all = false;
//break; ! don't break here, because there can be several archives with same repo_id
}
}
return unselect_all;
}
static void unselect(PagePrinters* page)
{
const PresetArchiveDatabase* pad = wxGetApp().plater()->get_preset_archive_database();
@ -3677,6 +3698,35 @@ static void unselect(PagePrinters* page)
page->unselect_all_presets();
}
bool ConfigWizard::priv::can_clear_printer_pages()
{
const auto& selected_uuids = page_update_manager->manager->get_selected_uuids();
wxString msg;
for (Repository& repo : repositories) {
for (auto& [name, printers] : repo.printers_pages) {
if (PagePrinters* page = printers.first;
page && to_delete(page, selected_uuids))
msg += "* " + page->shortname + "\n";
if (PagePrinters* page = printers.second;
page && to_delete(page, selected_uuids))
msg += "* " + page->shortname + "\n";
}
}
if (msg.IsEmpty())
return false;
wxString message = format_wxstr( _L("Next pages will be deleted after configuration update:%1%\n"
"Installed presets will be uninstalled.\n"
"Would you like to process it?"), "\n\n"+ msg);
MessageDialog msg_dlg(this->q, message, _L("Notice"), wxYES_NO);
return msg_dlg.ShowModal() == wxID_YES;
}
void ConfigWizard::priv::clear_printer_pages()
{
auto delelete_page = [this](PagePrinters* page) {

View File

@ -715,6 +715,7 @@ struct ConfigWizard::priv
// and return true if any of vendors_for_repo is installed (is in app_config)
bool any_installed_vendor_for_repo(const std::string& repo_id, std::vector<const VendorProfile*>& );
bool can_clear_printer_pages();
void clear_printer_pages();
void load_pages_from_archive();
};

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 + 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())
@ -2600,9 +2599,6 @@ 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;

View File

@ -96,7 +96,6 @@ enum ConfigMenuIDs {
ConfigMenuWizard,
ConfigMenuSnapshots,
ConfigMenuTakeSnapshot,
ConfigMenuUpdateConf,
ConfigMenuUpdateApp,
ConfigMenuDesktopIntegration,
ConfigMenuPreferences,

View File

@ -44,7 +44,7 @@ RepositoryUpdateUIManager::RepositoryUpdateUIManager(wxWindow* parent, PresetArc
m_main_sizer->Add(offline_label, 0, wxTOP | wxLEFT, 2 * em);
m_offline_sizer = new wxFlexGridSizer(6, 0.75 * em, 1.5 * em);
m_offline_sizer = new wxFlexGridSizer(7, 0.75 * em, 1.5 * em);
m_offline_sizer->AddGrowableCol(1);
m_offline_sizer->AddGrowableCol(2);
m_offline_sizer->AddGrowableCol(4);
@ -76,7 +76,7 @@ void RepositoryUpdateUIManager::fill_entries(bool init_selection/* = false*/)
}
else {
// offline repo
m_offline_entries.push_back({ is_selected, uuid, data.name, data.description, data.source_path.filename().string(), fs::exists(data.source_path) });
m_offline_entries.push_back({ is_selected, uuid, data.name, data.description, data.source_path.filename().string(), fs::exists(data.source_path), data.source_path });
}
}
}
@ -137,7 +137,7 @@ void RepositoryUpdateUIManager::fill_grids()
// header
for (const wxString& l : std::initializer_list<wxString>{ _L("Use"), _L("Name"), _L("Descrition"), "", _L("Source file"), "" }) {
for (const wxString& l : std::initializer_list<wxString>{ _L("Use"), _L("Name"), _L("Descrition"), "", _L("Source file"), "", "" }) {
auto text = new wxStaticText(m_parent, wxID_ANY, l);
text->SetFont(wxGetApp().bold_font());
add(text);
@ -168,7 +168,20 @@ void RepositoryUpdateUIManager::fill_grids()
add(bmp);
}
add(new wxStaticText(m_parent, wxID_ANY, from_u8(entry.source)));
{
auto path_str = new wxStaticText(m_parent, wxID_ANY, from_u8(entry.source));
path_str->SetToolTip(from_u8(entry.source_path.string()));
add(path_str);
}
{
ScalableButton* btn = new ScalableButton(m_parent, wxID_ANY, "open");
btn->SetToolTip(_L("Open folder"));
btn->Bind(wxEVT_BUTTON, [this, &entry](wxCommandEvent& event) {
GUI::desktop_open_folder(entry.source_path.parent_path().make_preferred());
});
add(btn);
}
{
wxButton* btn = new wxButton(m_parent, wxID_ANY, " " + _L("Remove") + " ");

View File

@ -29,8 +29,8 @@ class RepositoryUpdateUIManager
};
struct OfflineEntry {
OfflineEntry(bool use, const std::string &id, const std::string &name, const std::string &description, const std::string &source, bool is_ok) :
use(use), id(id), name(name), description(description), source(source), is_ok(is_ok) {}
OfflineEntry(bool use, const std::string &id, const std::string &name, const std::string &description, const std::string &source, bool is_ok, boost::filesystem::path source_path) :
use(use), id(id), name(name), description(description), source(source), is_ok(is_ok), source_path(source_path) {}
bool use;
std::string id;
@ -38,6 +38,7 @@ class RepositoryUpdateUIManager
std::string description;
std::string source;
bool is_ok;
boost::filesystem::path source_path;
};
PresetArchiveDatabase* m_pad { nullptr };
@ -71,6 +72,7 @@ public:
bool set_selected_repositories();
bool is_selection_changed() const { return m_is_selection_changed; }
bool has_selections() const { return !m_selected_uuids.empty(); }
const std::set<std::string>& get_selected_uuids() const { return m_selected_uuids; }
};
class ManagePresetRepositoriesDialog : public DPIDialog