From 5fa35342fd3ebc946ed4de8c5504fdcf32733e96 Mon Sep 17 00:00:00 2001 From: Vovodroid Date: Sat, 23 Aug 2025 19:24:30 +0300 Subject: [PATCH] Add stl, step, etc. to recent list (#9481) * Add stl, step, etc. to recent list * Make configurable * Merge branch 'main' into recent-files-pr --- src/libslic3r/AppConfig.cpp | 4 ++++ src/slic3r/GUI/MainFrame.cpp | 2 +- src/slic3r/GUI/Plater.cpp | 12 +++++++++++- src/slic3r/GUI/Preferences.cpp | 6 +++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 9f174740dc..38cd03a8ac 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -362,6 +362,10 @@ void AppConfig::set_defaults() set("max_recent_count", "18"); } + if (get("recent_models").empty()) { + set("recent_models", "0"); + } + // if (get("staff_pick_switch").empty()) { // set_bool("staff_pick_switch", false); // } diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index f7cf8e12e7..ff030e111b 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -2329,7 +2329,7 @@ void MainFrame::init_menubar_as_editor() // Recent Project wxMenu* recent_projects_menu = new wxMenu(); - wxMenuItem* recent_projects_submenu = append_submenu(fileMenu, recent_projects_menu, wxID_ANY, _L("Recent projects"), ""); + wxMenuItem* recent_projects_submenu = append_submenu(fileMenu, recent_projects_menu, wxID_ANY, _L("Recent files"), ""); m_recent_projects.UseMenu(recent_projects_menu); Bind(wxEVT_MENU, [this](wxCommandEvent& evt) { size_t file_id = evt.GetId() - wxID_FILE1; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index c2a6e38b0b..5a9a7ecf65 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -11233,6 +11233,8 @@ void Plater::add_file() p->set_project_name(from_u8(full_path.stem().string())); } wxGetApp().mainframe->update_title(); + if (wxGetApp().app_config->get("recent_models") == "true") + wxGetApp().mainframe->add_to_recent_projects(paths[0].wstring()); } break; } @@ -11254,6 +11256,9 @@ void Plater::add_file() p->set_project_name(from_u8(full_path.stem().string())); } wxGetApp().mainframe->update_title(); + if (wxGetApp().app_config->get("recent_models") == "true") + for (auto &path : paths) + wxGetApp().mainframe->add_to_recent_projects(path.wstring()); } break; } @@ -11271,7 +11276,12 @@ void Plater::add_file() open_3mf_file(first_file[0]); load_files(tmf_file, LoadStrategy::LoadModel); - if (!load_files(other_file, LoadStrategy::LoadModel, false).empty()) { wxGetApp().mainframe->update_title();} + if (!load_files(other_file, LoadStrategy::LoadModel, false).empty()) { + wxGetApp().mainframe->update_title(); + if (wxGetApp().app_config->get("recent_models") == "true") + for (auto &file : other_file) + wxGetApp().mainframe->add_to_recent_projects(file.wstring()); + } break; default:break; } diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 77df4dd0c5..20376fad17 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -1249,11 +1249,14 @@ wxWindow* PreferencesDialog::create_general_page() std::vector projectLoadSettingsConfigOptions = { OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_ALL, OPTION_PROJECT_LOAD_BEHAVIOUR_ASK_WHEN_RELEVANT, OPTION_PROJECT_LOAD_BEHAVIOUR_ALWAYS_ASK, OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_GEOMETRY }; auto item_project_load_behaviour = create_item_combobox(_L("Load Behaviour"), page, _L("Should printer/filament/process settings be loaded when opening a .3mf?"), SETTING_PROJECT_LOAD_BEHAVIOUR, projectLoadSettingsBehaviourOptions, projectLoadSettingsConfigOptions); - auto item_max_recent_count = create_item_input(_L("Maximum recent projects"), "", page, _L("Maximum count of recent projects"), "max_recent_count", [](wxString value) { + auto item_max_recent_count = create_item_input(_L("Maximum recent files"), "", page, _L("Maximum count of recent files"), "max_recent_count", [](wxString value) { long max = 0; if (value.ToLong(&max)) wxGetApp().mainframe->set_max_recent_count(max); }); + + auto item_recent_models = create_item_checkbox(_L("Add model files (stl/step) to recent file list."), page, _L("Add model files (stl/step) to recent file list."), 50, "recent_models"); + auto item_save_choise = create_item_button(_L("Clear my choice on the unsaved projects."), _L("Clear"), page, L"", _L("Clear my choice on the unsaved projects."), []() { wxGetApp().app_config->set("save_project_choise", ""); }); @@ -1330,6 +1333,7 @@ wxWindow* PreferencesDialog::create_general_page() sizer_page->Add(title_project, 0, wxTOP| wxEXPAND, FromDIP(20)); sizer_page->Add(item_project_load_behaviour, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_max_recent_count, 0, wxTOP, FromDIP(3)); + sizer_page->Add(item_recent_models, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_save_choise, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_gcodes_warning, 0, wxTOP, FromDIP(3)); sizer_page->Add(item_backup, 0, wxTOP,FromDIP(3));