ENH:filter characters not supported by windows system

Change-Id: I0dcbf9535df7bdc4b19e095aa0c23223efa5087b
This commit is contained in:
tao wang 2023-06-16 11:43:50 +08:00 committed by Lane.Wei
parent fa49bdebd3
commit d8349610f7
6 changed files with 52 additions and 18 deletions

View File

@ -220,8 +220,6 @@ void PrintJob::process()
params.dev_id = m_dev_id;
params.ftp_folder = m_ftp_folder;
params.filename = job_data._3mf_path.string();
params.config_filename = job_data._3mf_config_path.string();
params.plate_index = curr_plate_idx;

View File

@ -3365,6 +3365,19 @@ void SelectMachineDialog::set_flow_calibration_state(bool state)
}
}
std::string SelectMachineDialog::filter_characters(const std::string& str, const std::string& filterChars)
{
std::string filteredStr = str;
auto removeFunc = [&filterChars](char ch) {
return filterChars.find(ch) != std::string::npos;
};
filteredStr.erase(std::remove_if(filteredStr.begin(), filteredStr.end(), removeFunc), filteredStr.end());
return filteredStr;
}
void SelectMachineDialog::set_default()
{
if (m_print_type == PrintFromType::FROM_NORMAL) {
@ -3397,6 +3410,10 @@ void SelectMachineDialog::set_default()
fs::path filename_path(filename.c_str());
m_current_project_name = wxString::FromUTF8(filename_path.filename().string());
//unsupported character filter
m_current_project_name = filter_characters(m_current_project_name.ToStdString(), "<>[]:/\\|?*\"");
m_rename_text->SetLabelText(m_current_project_name);
m_rename_normal_panel->Layout();
@ -4008,7 +4025,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
wxString info_line;
auto new_dev_name = m_textCtr->GetTextCtrl()->GetValue();
const char * unusable_symbols = "@~.<>[]:/\\|?*\"";
const char * unusable_symbols = "<>[]:/\\|?*\"";
const std::string unusable_suffix = PresetCollection::get_suffix_modified();
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {

View File

@ -455,6 +455,7 @@ public:
wxWindow* create_item_checkbox(wxString title, wxWindow* parent, wxString tooltip, std::string param);
wxImage * LoadImageFromBlob(const unsigned char *data, int size);
PrintDialogStatus get_status() { return m_print_status; }
std::string filter_characters(const std::string& str, const std::string& filterChars);
std::vector<std::string> sort_string(std::vector<std::string> strArray);
};

View File

@ -1211,6 +1211,19 @@ void SendToPrinterDialog::on_dpi_changed(const wxRect &suggested_rect)
Refresh();
}
std::string SendToPrinterDialog::filter_characters(const std::string& str, const std::string& filterChars)
{
std::string filteredStr = str;
auto removeFunc = [&filterChars](char ch) {
return filterChars.find(ch) != std::string::npos;
};
filteredStr.erase(std::remove_if(filteredStr.begin(), filteredStr.end(), removeFunc), filteredStr.end());
return filteredStr;
}
void SendToPrinterDialog::set_default()
{
//project name
@ -1229,6 +1242,10 @@ void SendToPrinterDialog::set_default()
fs::path filename_path(filename.c_str());
m_current_project_name = wxString::FromUTF8(filename_path.filename().string());
//unsupported character filter
m_current_project_name = filter_characters(m_current_project_name.ToStdString(), "<>[]:/\\|?*\"");
m_rename_text->SetLabelText(m_current_project_name);
m_rename_normal_panel->Layout();

View File

@ -153,6 +153,7 @@ public:
void show_print_failed_info(bool show, int code = 0, wxString description = wxEmptyString, wxString extra = wxEmptyString);
void update_print_error_info(int code, std::string msg, std::string extra);
wxString format_text(wxString& m_msg);
std::string filter_characters(const std::string& str, const std::string& filterChars);
std::vector<std::string> sort_string(std::vector<std::string> strArray);
};