mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 23:29:02 +08:00
SPE-1954: Inform the user when loading/importing a project or a config file containing a post-processing script
This commit is contained in:
parent
44376443ea
commit
3f3a3dd190
@ -276,6 +276,19 @@ int CLI::run(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
const auto* post_process = m_print_config.opt<ConfigOptionStrings>("post_process");
|
||||
if (post_process != nullptr && !post_process->values.empty()) {
|
||||
boost::nowide::cout << "\nA post-processing script has been detected in the config data:\n\n";
|
||||
for (const auto& s : post_process->values) {
|
||||
boost::nowide::cout << "> " << s << "\n";
|
||||
}
|
||||
boost::nowide::cout << "\nContinue(Y/N) ? ";
|
||||
char in;
|
||||
boost::nowide::cin >> in;
|
||||
if (in != 'Y' && in != 'y')
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Apply command line options to a more specific DynamicPrintConfig which provides normalize()
|
||||
// (command line options override --load files)
|
||||
m_print_config.apply(m_extra_config, true);
|
||||
|
@ -1926,6 +1926,20 @@ void MainFrame::load_config_file()
|
||||
if (dlg.ShowModal() == wxID_OK)
|
||||
file = dlg.GetPath();
|
||||
if (! file.IsEmpty() && this->load_config_file(file.ToUTF8().data())) {
|
||||
DynamicPrintConfig config = wxGetApp().preset_bundle->full_config();
|
||||
const auto* post_process = config.opt<ConfigOptionStrings>("post_process");
|
||||
if (post_process != nullptr && !post_process->values.empty()) {
|
||||
const wxString msg = _L("The selected config file contains a post-processing script") + "\n" + _L("Please review the script carefully before running it.");
|
||||
wxString text;
|
||||
for (const auto& s : post_process->values) {
|
||||
text += s;
|
||||
}
|
||||
|
||||
InfoDialog msg_dlg(nullptr, msg, text, true, wxOK | wxICON_WARNING);
|
||||
msg_dlg.set_caption(wxString(SLIC3R_APP_NAME " - ") + _L("Attention!"));
|
||||
msg_dlg.ShowModal();
|
||||
}
|
||||
|
||||
wxGetApp().app_config->update_config_dir(get_dir_name(file));
|
||||
m_last_config = file;
|
||||
}
|
||||
|
@ -320,6 +320,8 @@ public:
|
||||
InfoDialog&operator=(const InfoDialog&) = delete;
|
||||
virtual ~InfoDialog() = default;
|
||||
|
||||
void set_caption(const wxString& caption) { this->SetTitle(caption); }
|
||||
|
||||
private:
|
||||
wxString msg;
|
||||
};
|
||||
|
@ -2574,6 +2574,21 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
|
||||
if (load_config) {
|
||||
if (!config.empty()) {
|
||||
const auto* post_process = config.opt<ConfigOptionStrings>("post_process");
|
||||
if (post_process != nullptr && !post_process->values.empty()) {
|
||||
wxString msg = type_3mf ? _L("The selected 3MF file contains a post-processing script") :
|
||||
_L("The selected AMF file contains a post-processing script");
|
||||
msg += "\n" + _L("Please review the script carefully before running it.");
|
||||
wxString text;
|
||||
for (const auto& s : post_process->values) {
|
||||
text += s;
|
||||
}
|
||||
|
||||
InfoDialog msg_dlg(nullptr, msg, text, true, wxOK | wxICON_WARNING);
|
||||
msg_dlg.set_caption(wxString(SLIC3R_APP_NAME " - ") + _L("Attention!"));
|
||||
msg_dlg.ShowModal();
|
||||
}
|
||||
|
||||
Preset::normalize(config);
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
preset_bundle->load_config_model(filename.string(), std::move(config));
|
||||
|
Loading…
x
Reference in New Issue
Block a user