ENH: [STUDIO-4005] support custom root preset

Change-Id: I0cf2142a2d3cee7269b53b73ad44e05934c2e9e6
Jira: STUDIO-4005
This commit is contained in:
chunmao.guo
2023-08-16 10:19:14 +08:00
committed by Lane.Wei
parent 375932aea0
commit f4ffe8621b
5 changed files with 148 additions and 44 deletions

View File

@@ -4481,7 +4481,7 @@ void GUI_App::sync_preset(Preset* preset)
if (preset->is_custom_defined()) return;
auto setting_id = preset->setting_id;
if (setting_id.empty() && preset->sync_info.empty() && !preset->base_id.empty()) {
if (setting_id.empty() && preset->sync_info.empty()) {
std::map<std::string, std::string> values_map;
int ret = preset_bundle->get_differed_values_to_update(*preset, values_map);
if (!ret) {
@@ -4507,7 +4507,7 @@ void GUI_App::sync_preset(Preset* preset)
updated_info = "hold";
}
}
else if ((preset->sync_info.compare("create") == 0) && !preset->base_id.empty()) {
else if (preset->sync_info.compare("create") == 0) {
std::map<std::string, std::string> values_map;
int ret = preset_bundle->get_differed_values_to_update(*preset, values_map);
if (!ret) {
@@ -4531,7 +4531,7 @@ void GUI_App::sync_preset(Preset* preset)
BOOST_LOG_TRIVIAL(trace) << "[sync_preset]create: can not generate differed preset";
}
}
else if ((preset->sync_info.compare("update") == 0) && !preset->base_id.empty()) {
else if (preset->sync_info.compare("update") == 0) {
if (!setting_id.empty()) {
std::map<std::string, std::string> values_map;
int ret = preset_bundle->get_differed_values_to_update(*preset, values_map);

View File

@@ -4702,12 +4702,31 @@ void Tab::delete_preset()
std::string action = _utf8(L("Delete"));
//std::string action = current_preset.is_external ? _utf8(L("remove")) : _utf8(L("delete"));
// TRN remove/delete
wxString msg;
if (m_presets->get_preset_base(current_preset) == &current_preset) {
int count = 0;
wxString presets;
for (auto &preset2 : *m_presets)
if (preset2.inherits() == current_preset.name) {
++count;
presets += "\n - " + preset2.name;
}
if (count > 0) {
msg = _L("Presets inherited by other presets cannot be deleted");
msg += "\n";
msg += _L_PLURAL("The following presets inherits this preset.",
"The following preset inherits this preset.", count);
wxString title = from_u8((boost::format(_utf8(L("%1% Preset"))) % action).str()); // action + _(L(" Preset"));
MessageDialog(parent(), msg + presets, title, wxOK | wxICON_ERROR).ShowModal();
return;
}
}
BOOST_LOG_TRIVIAL(info) << boost::format("delete preset %1%, setting_id %2%, user_id %3%, base_id %4%, sync_info %5%, type %6%")
%current_preset.name%current_preset.setting_id%current_preset.user_id%current_preset.base_id%current_preset.sync_info
%Preset::get_type_string(m_type);
PhysicalPrinterCollection& physical_printers = m_preset_bundle->physical_printers;
wxString msg;
if (m_type == Preset::TYPE_PRINTER && !physical_printers.empty())
{