mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 11:29:04 +08:00
Automatically change extension in output_filename_format when switching to/from binary gcode format in Print Settings
This commit is contained in:
parent
0f939409b8
commit
a0dfb33b49
@ -1719,6 +1719,33 @@ void TabPrint::build()
|
||||
optgroup->append_single_option_line(option);
|
||||
optgroup->append_single_option_line("gcode_binary");
|
||||
|
||||
optgroup->m_on_change = [this](const t_config_option_key& opt_key, boost::any value)
|
||||
{
|
||||
if (opt_key == "gcode_binary") {
|
||||
const bool is_binary = m_config->opt_bool("gcode_binary");
|
||||
std::string output_filename_format = m_config->opt_string("output_filename_format");
|
||||
bool modified = false;
|
||||
if (is_binary && boost::iends_with(output_filename_format, ".gcode")) {
|
||||
output_filename_format = output_filename_format.substr(0, output_filename_format.length() - 5) + "bgcode";
|
||||
modified = true;
|
||||
}
|
||||
else if (!is_binary && boost::iends_with(output_filename_format, ".bgcode")) {
|
||||
output_filename_format = output_filename_format.substr(0, output_filename_format.length() - 6) + "gcode";
|
||||
modified = true;
|
||||
}
|
||||
if (modified) {
|
||||
DynamicPrintConfig new_conf = *m_config;
|
||||
auto off_option = static_cast<ConfigOptionString*>(m_config->option("output_filename_format")->clone());
|
||||
off_option->value = output_filename_format;
|
||||
new_conf.set_key_value("output_filename_format", off_option);
|
||||
load_config(new_conf);
|
||||
}
|
||||
}
|
||||
|
||||
update_dirty();
|
||||
update();
|
||||
};
|
||||
|
||||
optgroup = page->new_optgroup(L("Other"));
|
||||
|
||||
create_line_with_widget(optgroup.get(), "gcode_substitutions", "g-code-substitutions_301694", [this](wxWindow* parent) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user