Unsaved Changes: bug fix and improvements
- changed width of the "Save dialog" - SavePresetDialog: added info for Print/Filament user presets incompatible with selected printer_technology - fixed missed "modified" suffix when options are moved to the another preset - "move selected options" button is added for dependent presets
This commit is contained in:
parent
15545bbd90
commit
d8487b1458
@ -1059,7 +1059,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string& suffix, wxBox
|
||||
|
||||
m_valid_bmp = new wxStaticBitmap(m_parent, wxID_ANY, create_scaled_bitmap("tick_mark", m_parent));
|
||||
|
||||
m_combo = new wxComboBox(m_parent, wxID_ANY, from_u8(preset_name));
|
||||
m_combo = new wxComboBox(m_parent, wxID_ANY, from_u8(preset_name), wxDefaultPosition, wxSize(35 * wxGetApp().em_unit(), -1));
|
||||
for (const std::string& value : values)
|
||||
m_combo->Append(from_u8(value));
|
||||
|
||||
@ -1131,8 +1131,10 @@ void SavePresetDialog::Item::update()
|
||||
|
||||
if (m_valid_type == Valid && existing && m_preset_name != m_presets->get_selected_preset_name())
|
||||
{
|
||||
info_line = from_u8((boost::format(_u8L("Preset with name \"%1%\" already exists.")) % m_preset_name).str()) + "\n" +
|
||||
_L("Note: This preset will be replaced after saving");
|
||||
info_line = from_u8((boost::format(_u8L("Preset with name \"%1%\" already exists.")) % m_preset_name).str());
|
||||
if (!existing->is_compatible)
|
||||
info_line += "\n" + _L("And selected preset is imcopatible with selected printer.");
|
||||
info_line += "\n" + _L("Note: This preset will be replaced after saving");
|
||||
m_valid_type = Warning;
|
||||
}
|
||||
|
||||
|
@ -1103,6 +1103,21 @@ void Tab::apply_searcher()
|
||||
wxGetApp().sidebar().get_searcher().apply(m_config, m_type, m_mode);
|
||||
}
|
||||
|
||||
void Tab::cache_config_diff(const std::vector<std::string>& selected_options)
|
||||
{
|
||||
m_cache_config.apply_only(m_presets->get_edited_preset().config, selected_options);
|
||||
}
|
||||
|
||||
void Tab::apply_config_from_cache()
|
||||
{
|
||||
if (!m_cache_config.empty()) {
|
||||
m_presets->get_edited_preset().config.apply(m_cache_config);
|
||||
m_cache_config.clear();
|
||||
|
||||
update_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Call a callback to update the selection of presets on the plater:
|
||||
// To update the content of the selection boxes,
|
||||
@ -1122,9 +1137,12 @@ void Tab::on_presets_changed()
|
||||
// Printer selected at the Printer tab, update "compatible" marks at the print and filament selectors.
|
||||
for (auto t: m_dependent_tabs)
|
||||
{
|
||||
Tab* tab = wxGetApp().get_tab(t);
|
||||
// If the printer tells us that the print or filament/sla_material preset has been switched or invalidated,
|
||||
// refresh the print or filament/sla_material tab page.
|
||||
wxGetApp().get_tab(t)->load_current_preset();
|
||||
// But if there are options, moved from the previously selected preset, update them to edited preset
|
||||
tab->apply_config_from_cache();
|
||||
tab->load_current_preset();
|
||||
}
|
||||
// clear m_dependent_tabs after first update from select_preset()
|
||||
// to avoid needless preset loading from update() function
|
||||
@ -3136,10 +3154,7 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
|
||||
static_cast<TabPrinter*>(this)->apply_extruder_cnt_from_cache();
|
||||
|
||||
// check if there is something in the cache to move to the new selected preset
|
||||
if (!m_cache_config.empty()) {
|
||||
m_presets->get_edited_preset().config.apply(m_cache_config);
|
||||
m_cache_config.clear();
|
||||
}
|
||||
apply_config_from_cache();
|
||||
|
||||
load_current_preset();
|
||||
}
|
||||
@ -3189,17 +3204,23 @@ bool Tab::may_discard_current_dirty_preset(PresetCollection* presets /*= nullptr
|
||||
else if (dlg.move_preset()) // move selected changes
|
||||
{
|
||||
std::vector<std::string> selected_options = dlg.get_selected_options();
|
||||
auto it = std::find(selected_options.begin(), selected_options.end(), "extruders_count");
|
||||
if (it != selected_options.end()) {
|
||||
// erase "extruders_count" option from the list
|
||||
selected_options.erase(it);
|
||||
// cache the extruders count
|
||||
if (m_type == Preset::TYPE_PRINTER)
|
||||
static_cast<TabPrinter*>(this)->cache_extruder_cnt();
|
||||
}
|
||||
if (m_type == presets->type()) // move changes for the current preset from this tab
|
||||
{
|
||||
if (m_type == Preset::TYPE_PRINTER) {
|
||||
auto it = std::find(selected_options.begin(), selected_options.end(), "extruders_count");
|
||||
if (it != selected_options.end()) {
|
||||
// erase "extruders_count" option from the list
|
||||
selected_options.erase(it);
|
||||
// cache the extruders count
|
||||
static_cast<TabPrinter*>(this)->cache_extruder_cnt();
|
||||
}
|
||||
}
|
||||
|
||||
// copy selected options to the cache from edited preset
|
||||
m_cache_config.apply_only(*m_config, selected_options);
|
||||
// copy selected options to the cache from edited preset
|
||||
cache_config_diff(selected_options);
|
||||
}
|
||||
else
|
||||
wxGetApp().get_tab(presets->type())->cache_config_diff(selected_options);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -231,12 +231,13 @@ protected:
|
||||
}
|
||||
m_highlighter;
|
||||
|
||||
DynamicPrintConfig m_cache_config;
|
||||
|
||||
public:
|
||||
PresetBundle* m_preset_bundle;
|
||||
bool m_show_btn_incompatible_presets = false;
|
||||
PresetCollection* m_presets;
|
||||
DynamicPrintConfig* m_config;
|
||||
DynamicPrintConfig m_cache_config;
|
||||
ogStaticText* m_parent_preset_description_line;
|
||||
ScalableButton* m_detach_preset_btn = nullptr;
|
||||
|
||||
@ -330,6 +331,8 @@ public:
|
||||
void update_wiping_button_visibility();
|
||||
void activate_option(const std::string& opt_key, const wxString& category);
|
||||
void apply_searcher();
|
||||
void cache_config_diff(const std::vector<std::string>& selected_options);
|
||||
void apply_config_from_cache();
|
||||
|
||||
protected:
|
||||
void create_line_with_widget(ConfigOptionsGroup* optgroup, const std::string& opt_key, widget_t widget);
|
||||
|
@ -590,8 +590,8 @@ void UnsavedChangesDialog::build(Preset::Type type, PresetCollection* dependent_
|
||||
|
||||
int btn_idx = 0;
|
||||
add_btn(&m_save_btn, m_save_btn_id, "save", Action::Save, btn_idx++);
|
||||
if (type != Preset::TYPE_INVALID && type == dependent_presets->type() &&
|
||||
dependent_presets->get_edited_preset().printer_technology() == dependent_presets->find_preset(new_selected_preset)->printer_technology())
|
||||
if (dependent_presets && (type != dependent_presets->type() ? true :
|
||||
dependent_presets->get_edited_preset().printer_technology() == dependent_presets->find_preset(new_selected_preset)->printer_technology()))
|
||||
add_btn(&m_move_btn, m_move_btn_id, "paste_menu", Action::Move, btn_idx++);
|
||||
add_btn(&m_continue_btn, m_continue_btn_id, "cross", Action::Continue, btn_idx, false);
|
||||
|
||||
@ -666,12 +666,11 @@ void UnsavedChangesDialog::show_info_line(Action action, std::string preset_name
|
||||
else if (action == Action::Continue)
|
||||
text = _L("All changed options will be reverted.");
|
||||
else {
|
||||
if (action == Action::Save && preset_name.empty())
|
||||
text = _L("Press to save the selected options");
|
||||
else {
|
||||
std::string act_string = action == Action::Save ? _u8L("saved") : _u8L("moved");
|
||||
std::string act_string = action == Action::Save ? _u8L("save") : _u8L("move");
|
||||
if (preset_name.empty())
|
||||
text = from_u8((boost::format("Press to %1% selected options.") % act_string).str());
|
||||
else
|
||||
text = from_u8((boost::format("Press to %1% selected options to the preset \"%2%\".") % act_string % preset_name).str());
|
||||
}
|
||||
text += "\n" + _L("Unselected options will be reverted.");
|
||||
}
|
||||
m_info_line->SetLabel(text);
|
||||
@ -856,8 +855,10 @@ void UnsavedChangesDialog::update(Preset::Type type, PresetCollection* dependent
|
||||
|
||||
// activate buttons and labels
|
||||
m_save_btn ->Bind(wxEVT_ENTER_WINDOW, [this, presets] (wxMouseEvent& e) { show_info_line(Action::Save, presets ? presets->get_selected_preset().name : ""); e.Skip(); });
|
||||
if (m_move_btn)
|
||||
m_move_btn ->Bind(wxEVT_ENTER_WINDOW, [this, new_selected_preset] (wxMouseEvent& e) { show_info_line(Action::Move, new_selected_preset); e.Skip(); });
|
||||
if (m_move_btn) {
|
||||
bool is_empty_name = type != dependent_presets->type();
|
||||
m_move_btn ->Bind(wxEVT_ENTER_WINDOW, [this, new_selected_preset, is_empty_name] (wxMouseEvent& e) { show_info_line(Action::Move, is_empty_name ? "" : new_selected_preset); e.Skip(); });
|
||||
}
|
||||
m_continue_btn ->Bind(wxEVT_ENTER_WINDOW, [this] (wxMouseEvent& e) { show_info_line(Action::Continue); e.Skip(); });
|
||||
|
||||
m_continue_btn->SetLabel(_L("Continue without changes"));
|
||||
@ -879,6 +880,9 @@ void UnsavedChangesDialog::update(Preset::Type type, PresetCollection* dependent
|
||||
_L("is not compatible with print profile");
|
||||
action_msg += " \"" + from_u8(new_selected_preset) + "\"\n";
|
||||
action_msg += _L("and it has the following unsaved changes:");
|
||||
|
||||
if (m_move_btn)
|
||||
m_move_btn->SetLabel(_L("Move selected to the first compatible preset"));
|
||||
}
|
||||
m_action_line->SetLabel(from_u8((boost::format(_utf8(L("Preset \"%1%\" %2%"))) % _utf8(presets->get_edited_preset().name) % action_msg).str()));
|
||||
m_save_btn->SetLabel(from_u8((boost::format(_u8L("Save selected to preset: %1%")) % ("\"" + presets->get_selected_preset().name + "\"")).str()));
|
||||
|
Loading…
Reference in New Issue
Block a user