SPE 2553: Do a silent removal of desktop files.

This commit is contained in:
David Kocik 2024-12-10 13:30:00 +01:00 committed by Lukas Matena
parent 57d383d585
commit 66e362e2dd
3 changed files with 3 additions and 62 deletions

View File

@ -238,11 +238,6 @@ void AppConfig::set_defaults()
set("sys_menu_enabled", "1"); set("sys_menu_enabled", "1");
#endif // _WIN32 #endif // _WIN32
#ifdef __linux__
if (get("check_old_desktop_files").empty())
set("check_old_desktop_files", "1"); // /"0" - dont check, "1" - check and ask, "auto" - check and dont ask
#endif // __linux__
// Remove legacy window positions/sizes // Remove legacy window positions/sizes
erase("", "main_frame_maximized"); erase("", "main_frame_maximized");
erase("", "main_frame_pos"); erase("", "main_frame_pos");

View File

@ -1314,55 +1314,12 @@ static int get_app_font_pt_size(const AppConfig* app_config)
#if defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION) #if defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION)
void GUI_App::remove_desktop_files_dialog() void GUI_App::remove_desktop_files_dialog()
{ {
if (app_config->get("check_old_desktop_files") == "0") {
return;
}
// Find all old existing desktop file // Find all old existing desktop file
std::vector<boost::filesystem::path> found_desktop_files; std::vector<boost::filesystem::path> found_desktop_files;
DesktopIntegrationDialog::find_all_desktop_files(found_desktop_files); DesktopIntegrationDialog::find_all_desktop_files(found_desktop_files);
if(found_desktop_files.empty()) { if(found_desktop_files.empty()) {
return; return;
} }
// Some files might be unaccessible for us, if already tried, it is saved in appconfig.
std::vector<std::string> old_fails;
std::string old_fails_serialized = app_config->get("old_desktop_files_fails");
boost::split(old_fails, old_fails_serialized, boost::is_any_of(";"));
if (found_desktop_files.size() <= old_fails.size()) {
bool all_are_fails = true;
for (const boost::filesystem::path& entry : found_desktop_files) {
if (std::find(old_fails.begin(), old_fails.end(), entry.string()) == old_fails.end()) {
all_are_fails = false;
break;
}
}
if (all_are_fails) {
BOOST_LOG_TRIVIAL(debug) << "Only desktop files that failed to remove before were found.";
return;
}
}
wxString text;
// Dialog asking to delete the files.
if (app_config->get("check_old_desktop_files") == "1") {
text = _L("Some outdated desktop files related to PrusaSlicer were found on your system. "
"These files are no longer used by this version of PrusaSlicer and may cause issues, such as problems logging in via third-party accounts.");
text += "\n\n";
for (const boost::filesystem::path& entry : found_desktop_files) {
text += GUI::format_wxstr("%1%\n",entry.string());
}
text += "\n";
text += _L("Would you like to remove these files now?");
RichMessageDialog dialog(nullptr, text, _L("Outdated Desktop Files Detected"), wxICON_QUESTION | wxYES_NO);
dialog.ShowCheckBox(_L("Dont show this message again"));
// Wait for modal.
bool is_yes = dialog.ShowModal() == wxID_YES;
if (dialog.IsCheckBoxChecked()) {
app_config->set("check_old_desktop_files", is_yes ? "auto" : "0");
}
if (!is_yes) {
return;
}
}
// Delete files. // Delete files.
std::vector<boost::filesystem::path> fails; std::vector<boost::filesystem::path> fails;
DesktopIntegrationDialog::remove_desktop_file_list(found_desktop_files, fails); DesktopIntegrationDialog::remove_desktop_file_list(found_desktop_files, fails);
@ -1371,17 +1328,13 @@ void GUI_App::remove_desktop_files_dialog()
} }
// Inform about fails. // Inform about fails.
std::string fails_serialized; std::string fails_serialized;
text = _L("Failed to remove desktop files."); std::string text = _"Failed to remove desktop files:";
text += "\n\n"; text += "\n";
for (const boost::filesystem::path& entry : fails) { for (const boost::filesystem::path& entry : fails) {
text += GUI::format_wxstr("%1%\n",entry.string()); text += GUI::format_wxstr("%1%\n",entry.string());
fails_serialized += entry.string() + ";"; fails_serialized += entry.string() + ";";
} }
// Save fails for next run. BOOST_LOG_TRIVIAL(error) << text;
app_config->set("old_desktop_files_fails", fails_serialized);
RichMessageDialog dlg2(nullptr, text, _L("Desktop integration"), wxICON_WARNING | wxOK_DEFAULT);
dlg2.ShowModal();
} }
#endif //(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION) #endif //(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION)

View File

@ -637,13 +637,6 @@ void PreferencesDialog::build()
L("Show \"Log in\" button in application top bar"), L("Show \"Log in\" button in application top bar"),
L("If enabled, PrusaSlicer will show up \"Log in\" button in application top bar."), L("If enabled, PrusaSlicer will show up \"Log in\" button in application top bar."),
app_config->get_bool("show_login_button")); app_config->get_bool("show_login_button"));
#if defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION)
append_bool_option(m_optgroup_other, "check_old_desktop_files",
L("Check outdated desktop files for removal"),
L("If enabled, PrusaSlicer will search for outdated desktop files at startup and ask for removal."),
app_config->get("check_old_desktop_files") == "1");
#endif //defined(__linux__) && !defined(SLIC3R_DESKTOP_INTEGRATION)
append_bool_option(m_optgroup_other, "downloader_url_registered", append_bool_option(m_optgroup_other, "downloader_url_registered",
L("Allow downloads from Printables.com"), L("Allow downloads from Printables.com"),