Skip to content

Commit d9b947c

Browse files
Add Reload Presets button and menu item (Cmd+R)
Features: - Reload button (refresh icon) next to preset dropdown on all tabs - File > Reload Presets menu item with Cmd+R shortcut - Reloads user presets from disk without app restart - Auto-selects newly found presets after reload - Properly updates all tab UI including delete button visibility Also: - Custom monochrome reload_preset.svg icon matching save/cross style - cmake 4.x compatibility fix for dependency builds
1 parent 6a3e8bb commit d9b947c

7 files changed

Lines changed: 61 additions & 0 deletions

File tree

deps/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function(bambustudio_add_cmake_project projectname)
133133
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
134134
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
135135
-DCMAKE_TOOLCHAIN_FILE:STRING=${CMAKE_TOOLCHAIN_FILE}
136+
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
136137
-DBUILD_SHARED_LIBS:BOOL=OFF
137138
${_cmake_osx_arch}
138139
"${_configs_line}"

resources/images/reload_preset.svg

Lines changed: 4 additions & 0 deletions
Loading

src/slic3r/GUI/GUI_App.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5686,6 +5686,48 @@ void GUI_App::reload_settings()
56865686
}
56875687
}
56885688

5689+
// Reload user presets from disk without restart
5690+
void GUI_App::reload_user_presets_from_disk()
5691+
{
5692+
if (!preset_bundle || !mainframe)
5693+
return;
5694+
5695+
std::string user_id = (m_agent && m_agent->is_user_login())
5696+
? m_agent->get_user_id()
5697+
: DEFAULT_USER_FOLDER_NAME;
5698+
5699+
// Snapshot existing preset names before reload
5700+
std::set<std::string> old_prints, old_filaments;
5701+
for (const auto& p : preset_bundle->prints)
5702+
if (p.is_user()) old_prints.insert(p.name);
5703+
for (const auto& p : preset_bundle->filaments)
5704+
if (p.is_user()) old_filaments.insert(p.name);
5705+
5706+
BOOST_LOG_TRIVIAL(info) << "Reloading user presets from disk for user: " << user_id;
5707+
preset_bundle->load_user_presets(user_id, ForwardCompatibilitySubstitutionRule::Enable);
5708+
mainframe->update_side_preset_ui();
5709+
5710+
// Find new presets and select the last one found
5711+
std::string new_print, new_filament;
5712+
for (const auto& p : preset_bundle->prints)
5713+
if (p.is_user() && old_prints.find(p.name) == old_prints.end())
5714+
new_print = p.name;
5715+
for (const auto& p : preset_bundle->filaments)
5716+
if (p.is_user() && old_filaments.find(p.name) == old_filaments.end())
5717+
new_filament = p.name;
5718+
5719+
if (!new_print.empty()) {
5720+
BOOST_LOG_TRIVIAL(info) << "New process preset found, selecting: " << new_print;
5721+
auto tab = get_tab(Preset::TYPE_PRINT);
5722+
if (tab) tab->select_preset(new_print);
5723+
}
5724+
if (!new_filament.empty()) {
5725+
BOOST_LOG_TRIVIAL(info) << "New filament preset found, selecting: " << new_filament;
5726+
auto tab = get_tab(Preset::TYPE_FILAMENT);
5727+
if (tab) tab->select_preset(new_filament);
5728+
}
5729+
}
5730+
56895731
//BBS reload when logout
56905732
void GUI_App::remove_user_presets()
56915733
{

src/slic3r/GUI/GUI_App.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ class GUI_App : public wxApp
336336

337337
boost::thread m_sync_update_thread;
338338
std::shared_ptr<int> m_user_sync_token;
339+
339340
bool m_is_dark_mode{ false };
340341
bool m_adding_script_handler { false };
341342
bool m_side_popup_status{false};
@@ -350,6 +351,9 @@ class GUI_App : public wxApp
350351
public:
351352
//try again when subscription fails
352353
void on_start_subscribe_again(std::string dev_id);
354+
355+
// Reload user presets from disk (triggered via menu: File > Reload Presets)
356+
void reload_user_presets_from_disk();
353357
std::string get_local_models_path();
354358
bool OnInit() override;
355359
int OnExit() override;

src/slic3r/GUI/MainFrame.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,11 @@ void MainFrame::init_menubar_as_editor()
26582658
append_menu_item(fileMenu, wxID_ANY, _L("Save Project") + "\t" + ctrl + "S", _L("Save current project to file"),
26592659
[this](wxCommandEvent&) { if (m_plater) m_plater->save_project(); }, "", nullptr,
26602660
[this](){return m_plater != nullptr && can_save(); }, this);
2661+
2662+
// Reload user presets from disk
2663+
append_menu_item(fileMenu, wxID_ANY, _L("Reload Presets") + "\t" + ctrl + "R", _L("Reload user presets from disk"),
2664+
[](wxCommandEvent&) { wxGetApp().reload_user_presets_from_disk(); }, "", nullptr,
2665+
[]() { return true; }, this);
26612666
#endif
26622667

26632668

src/slic3r/GUI/Tab.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ void Tab::create_preset_tab()
234234
});
235235

236236
//add_scaled_button(panel, &m_btn_compare_preset, "compare");
237+
add_scaled_button(m_top_panel, &m_btn_reload_presets, "reload_preset");
237238
add_scaled_button(m_top_panel, &m_btn_save_preset, "save");
238239
add_scaled_button(m_top_panel, &m_btn_delete_preset, "cross");
239240
//if (m_type == Preset::Type::TYPE_PRINTER)
@@ -372,6 +373,7 @@ void Tab::create_preset_tab()
372373
m_top_sizer->Add( m_undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL);
373374
m_top_sizer->AddSpacer(8);
374375
#endif
376+
m_top_sizer->Add( m_btn_reload_presets, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(12));
375377
m_top_sizer->Add( m_btn_save_preset, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(12));
376378
m_top_sizer->Add( m_btn_delete_preset, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, FromDIP(12) );
377379
m_top_sizer->Add( m_btn_search, 0, wxALIGN_CENTER_VERTICAL | wxLEFT , FromDIP(12) );
@@ -610,6 +612,8 @@ void Tab::create_preset_tab()
610612

611613
//m_btn_compare_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { compare_preset(); }));
612614
m_btn_save_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { save_preset(); }));
615+
m_btn_reload_presets->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { wxGetApp().reload_user_presets_from_disk(); }));
616+
m_btn_reload_presets->SetToolTip(_L("Reload presets from disk"));
613617
m_btn_delete_preset->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) { delete_preset(); }));
614618
/*m_btn_hide_incompatible_presets->Bind(wxEVT_BUTTON, ([this](wxCommandEvent e) {
615619
toggle_show_hide_incompatible();

src/slic3r/GUI/Tab.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class Tab: public wxPanel
156156

157157
ScalableButton* m_btn_compare_preset;
158158
ScalableButton* m_btn_save_preset;
159+
ScalableButton* m_btn_reload_presets;
159160
ScalableButton* m_btn_delete_preset;
160161
//ScalableButton* m_btn_edit_ph_printer {nullptr};
161162
//ScalableButton* m_btn_hide_incompatible_presets;

0 commit comments

Comments
 (0)