Skip to content

Commit

Permalink
ENH: [6510] enh save user preset logic
Browse files Browse the repository at this point in the history
Jira: 6510

Change-Id: Ide0328253bb4cfd4c761bb2569c246515dee65c2
Signed-off-by: maosheng.wei <[email protected]>
  • Loading branch information
DanBao-Bambu authored and lanewei120 committed Mar 25, 2024
1 parent dcdedb2 commit f9cbb9a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/slic3r/GUI/SavePresetDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ SavePresetDialog::Item::Item(Preset::Type type, const std::string &suffix, wxBox
m_input_ctrl->SetBackgroundColor(input_bg);
m_input_ctrl->Bind(wxEVT_TEXT, [this](wxCommandEvent &) {
update();
if (m_can_save)
if (m_valid_type != NoValid)
m_parent->m_confirm->Enable();
else
m_parent->m_confirm->Disable();
Expand Down Expand Up @@ -185,23 +185,20 @@ void SavePresetDialog::Item::update()

m_valid_type = Valid;
wxString info_line;
m_can_save = true;
const char *unusable_symbols = "<>[]:/\\|?*\"";

const std::string unusable_suffix = PresetCollection::get_suffix_modified(); //"(modified)";
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
if (m_preset_name.find_first_of(unusable_symbols[i]) != std::string::npos) {
info_line = _L("Name is invalid;") + "\n" + _L("illegal characters:") + " " + unusable_symbols;
m_valid_type = NoValid;
m_can_save = false;
break;
}
}

if (m_valid_type == Valid && m_preset_name.find(unusable_suffix) != std::string::npos) {
info_line = _L("Name is invalid;") + "\n" + _L("illegal suffix:") + "\n\t" + from_u8(PresetCollection::get_suffix_modified());
m_valid_type = NoValid;
m_can_save = false;
}

if (m_valid_type == Valid &&
Expand Down Expand Up @@ -257,7 +254,7 @@ void SavePresetDialog::Item::update()
m_radio_user->Disable();
m_radio_project->Disable();
} else {
if (m_can_save) {
if (m_valid_type != NoValid) {
m_radio_user->Enable();
m_radio_project->Enable();
} else {
Expand Down
1 change: 0 additions & 1 deletion src/slic3r/GUI/SavePresetDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class SavePresetDialog : public DPIDialog
RadioBox * m_radio_user{nullptr};
RadioBox * m_radio_project{nullptr};
bool m_save_to_project {false};
bool m_can_save{true};

void update();
};
Expand Down

0 comments on commit f9cbb9a

Please sign in to comment.