FIX: [STUDIO-1525] not switch preset after cancel edit dialog
Change-Id: I91810298da40250e3c5def72737b2be6df764a3b
This commit is contained in:
parent
50a5f8bddf
commit
5a6263c9f3
|
@ -54,6 +54,7 @@ ParamsDialog::ParamsDialog(wxWindow * parent)
|
||||||
#else
|
#else
|
||||||
Hide();
|
Hide();
|
||||||
#endif
|
#endif
|
||||||
|
wxGetApp().sidebar().finish_param_edit();
|
||||||
});
|
});
|
||||||
|
|
||||||
wxGetApp().UpdateDlgDarkUI(this);
|
wxGetApp().UpdateDlgDarkUI(this);
|
||||||
|
|
|
@ -523,8 +523,9 @@ Sidebar::Sidebar(Plater *parent)
|
||||||
edit_btn->SetToolTip(_L("Click to edit preset"));
|
edit_btn->SetToolTip(_L("Click to edit preset"));
|
||||||
edit_btn->Bind(wxEVT_BUTTON, [this, combo_printer](wxCommandEvent)
|
edit_btn->Bind(wxEVT_BUTTON, [this, combo_printer](wxCommandEvent)
|
||||||
{
|
{
|
||||||
p->editing_filament = 0;
|
p->editing_filament = -1;
|
||||||
combo_printer->switch_to_tab();
|
if (combo_printer->switch_to_tab())
|
||||||
|
p->editing_filament = 0;
|
||||||
});
|
});
|
||||||
combo_printer->edit_btn = edit_btn;
|
combo_printer->edit_btn = edit_btn;
|
||||||
p->combo_printer = combo_printer;
|
p->combo_printer = combo_printer;
|
||||||
|
@ -741,7 +742,7 @@ Sidebar::Sidebar(Plater *parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->editing_filament >= filament_count) {
|
if (p->editing_filament >= filament_count) {
|
||||||
p->editing_filament = 0;
|
p->editing_filament = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGetApp().preset_bundle->set_num_filaments(filament_count);
|
wxGetApp().preset_bundle->set_num_filaments(filament_count);
|
||||||
|
@ -768,7 +769,7 @@ Sidebar::Sidebar(Plater *parent)
|
||||||
ScalableButton* set_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "settings");
|
ScalableButton* set_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "settings");
|
||||||
set_btn->SetToolTip(_L("Set filaments to use"));
|
set_btn->SetToolTip(_L("Set filaments to use"));
|
||||||
set_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
|
set_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
|
||||||
// p->editing_filament = -1;
|
p->editing_filament = -1;
|
||||||
// wxGetApp().params_dialog()->Popup();
|
// wxGetApp().params_dialog()->Popup();
|
||||||
// wxGetApp().get_tab(Preset::TYPE_FILAMENT)->restore_last_select_item();
|
// wxGetApp().get_tab(Preset::TYPE_FILAMENT)->restore_last_select_item();
|
||||||
wxGetApp().run_wizard(ConfigWizard::RR_USER, ConfigWizard::SP_FILAMENTS);
|
wxGetApp().run_wizard(ConfigWizard::RR_USER, ConfigWizard::SP_FILAMENTS);
|
||||||
|
@ -905,8 +906,9 @@ void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filame
|
||||||
PlaterPresetComboBox* combobox = (*combo);
|
PlaterPresetComboBox* combobox = (*combo);
|
||||||
edit_btn->Bind(wxEVT_BUTTON, [this, combobox, filament_idx](wxCommandEvent)
|
edit_btn->Bind(wxEVT_BUTTON, [this, combobox, filament_idx](wxCommandEvent)
|
||||||
{
|
{
|
||||||
p->editing_filament = filament_idx; // sync with TabPresetComboxBox's m_filament_idx
|
p->editing_filament = -1;
|
||||||
combobox->switch_to_tab();
|
if (combobox->switch_to_tab())
|
||||||
|
p->editing_filament = filament_idx; // sync with TabPresetComboxBox's m_filament_idx
|
||||||
});
|
});
|
||||||
combobox->edit_btn = edit_btn;
|
combobox->edit_btn = edit_btn;
|
||||||
|
|
||||||
|
@ -1496,6 +1498,8 @@ bool Sidebar::show_object_list(bool show) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sidebar::finish_param_edit() { p->editing_filament = -1; }
|
||||||
|
|
||||||
std::vector<PlaterPresetComboBox*>& Sidebar::combos_filament()
|
std::vector<PlaterPresetComboBox*>& Sidebar::combos_filament()
|
||||||
{
|
{
|
||||||
return p->combos_filament;
|
return p->combos_filament;
|
||||||
|
|
|
@ -149,6 +149,7 @@ public:
|
||||||
void update_searcher();
|
void update_searcher();
|
||||||
void update_ui_from_settings();
|
void update_ui_from_settings();
|
||||||
bool show_object_list(bool show) const;
|
bool show_object_list(bool show) const;
|
||||||
|
void finish_param_edit();
|
||||||
|
|
||||||
#ifdef _MSW_DARK_MODE
|
#ifdef _MSW_DARK_MODE
|
||||||
void show_mode_sizer(bool show);
|
void show_mode_sizer(bool show);
|
||||||
|
|
|
@ -773,11 +773,11 @@ void PlaterPresetComboBox::OnSelect(wxCommandEvent &evt)
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaterPresetComboBox::switch_to_tab()
|
bool PlaterPresetComboBox::switch_to_tab()
|
||||||
{
|
{
|
||||||
Tab* tab = wxGetApp().get_tab(m_type);
|
Tab* tab = wxGetApp().get_tab(m_type);
|
||||||
if (!tab)
|
if (!tab)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
//BBS Select NoteBook Tab params
|
//BBS Select NoteBook Tab params
|
||||||
if (tab->GetParent() == wxGetApp().params_panel())
|
if (tab->GetParent() == wxGetApp().params_panel())
|
||||||
|
@ -793,8 +793,12 @@ void PlaterPresetComboBox::switch_to_tab()
|
||||||
if (!boost::algorithm::starts_with(selected_preset, Preset::suffix_modified()))
|
if (!boost::algorithm::starts_with(selected_preset, Preset::suffix_modified()))
|
||||||
{
|
{
|
||||||
const std::string& preset_name = wxGetApp().preset_bundle->filaments.get_preset_name_by_alias(selected_preset);
|
const std::string& preset_name = wxGetApp().preset_bundle->filaments.get_preset_name_by_alias(selected_preset);
|
||||||
wxGetApp().get_tab(m_type)->select_preset(preset_name);
|
if (wxGetApp().get_tab(m_type)->select_preset(preset_name))
|
||||||
wxGetApp().get_tab(m_type)->get_combo_box()->set_filament_idx(m_filament_idx);
|
wxGetApp().get_tab(m_type)->get_combo_box()->set_filament_idx(m_filament_idx);
|
||||||
|
else {
|
||||||
|
wxGetApp().params_dialog()->Hide();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,6 +823,8 @@ void PlaterPresetComboBox::switch_to_tab()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaterPresetComboBox::change_extruder_color()
|
void PlaterPresetComboBox::change_extruder_color()
|
||||||
|
|
|
@ -170,7 +170,7 @@ public:
|
||||||
|
|
||||||
wxColor get_color() { return m_color; }
|
wxColor get_color() { return m_color; }
|
||||||
|
|
||||||
void switch_to_tab();
|
bool switch_to_tab();
|
||||||
void change_extruder_color();
|
void change_extruder_color();
|
||||||
void show_add_menu();
|
void show_add_menu();
|
||||||
void show_edit_menu();
|
void show_edit_menu();
|
||||||
|
|
|
@ -3728,7 +3728,7 @@ void Tab::update_preset_choice()
|
||||||
// Called by the UI combo box when the user switches profiles, and also to delete the current profile.
|
// Called by the UI combo box when the user switches profiles, and also to delete the current profile.
|
||||||
// Select a preset by a name.If !defined(name), then the default preset is selected.
|
// Select a preset by a name.If !defined(name), then the default preset is selected.
|
||||||
// If the current profile is modified, user is asked to save the changes.
|
// If the current profile is modified, user is asked to save the changes.
|
||||||
void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, const std::string& last_selected_ph_printer_name/* =""*/, bool force_select)
|
bool Tab::select_preset(std::string preset_name, bool delete_current /*=false*/, const std::string& last_selected_ph_printer_name/* =""*/, bool force_select)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("select preset, name %1%, delete_current %2%")
|
BOOST_LOG_TRIVIAL(info) << boost::format("select preset, name %1%, delete_current %2%")
|
||||||
%preset_name %delete_current;
|
%preset_name %delete_current;
|
||||||
|
@ -3956,6 +3956,8 @@ void Tab::select_preset(std::string preset_name, bool delete_current /*=false*/,
|
||||||
if (technology_changed)
|
if (technology_changed)
|
||||||
wxGetApp().mainframe->technology_changed();
|
wxGetApp().mainframe->technology_changed();
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("select preset, exit");
|
BOOST_LOG_TRIVIAL(info) << boost::format("select preset, exit");
|
||||||
|
|
||||||
|
return !canceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the current preset is dirty, the user is asked whether the changes may be discarded.
|
// If the current preset is dirty, the user is asked whether the changes may be discarded.
|
||||||
|
|
|
@ -322,7 +322,7 @@ public:
|
||||||
void update_btns_enabling();
|
void update_btns_enabling();
|
||||||
void update_preset_choice();
|
void update_preset_choice();
|
||||||
// Select a new preset, possibly delete the current one.
|
// Select a new preset, possibly delete the current one.
|
||||||
void select_preset(std::string preset_name = "", bool delete_current = false, const std::string& last_selected_ph_printer_name = "", bool force_select = false);
|
bool select_preset(std::string preset_name = "", bool delete_current = false, const std::string& last_selected_ph_printer_name = "", bool force_select = false);
|
||||||
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "", bool no_transfer = false);
|
bool may_discard_current_dirty_preset(PresetCollection* presets = nullptr, const std::string& new_printer_name = "", bool no_transfer = false);
|
||||||
|
|
||||||
virtual void clear_pages();
|
virtual void clear_pages();
|
||||||
|
|
|
@ -1383,7 +1383,8 @@ void UnsavedChangesDialog::update(Preset::Type type, PresetCollection* dependent
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString action_msg;
|
wxString action_msg;
|
||||||
action_msg = format_wxstr(_L("You have changed some preset settings. \nWould you like to keep these changed settings (new value) after switching preset?"));
|
action_msg = format_wxstr(_L("You have changed some settings of preset \"%1%\". \nWould you like to keep these changed settings (new value) after switching preset?"),
|
||||||
|
dependent_presets->get_edited_preset().name);
|
||||||
m_action_line->SetLabel(action_msg);
|
m_action_line->SetLabel(action_msg);
|
||||||
|
|
||||||
update_tree(type, presets);
|
update_tree(type, presets);
|
||||||
|
|
Loading…
Reference in New Issue