mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-29 22:02:10 +00:00
feature: add filename validation & check the compatiblity of the filament from device (#132)
* Fix: didn't check the compatiblity of the filament which is gotten from machine * Optimize the filename validation
This commit is contained in:
@@ -1150,12 +1150,15 @@ void PlaterPresetComboBox::update()
|
||||
|
||||
for (auto iter = machine_filaments.begin(); iter != machine_filaments.end();) {
|
||||
std::string filament_name = iter->second.first;
|
||||
auto item_iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
[&filament_name, this](auto& f) { return f.name == filament_name; });
|
||||
|
||||
// First match: exact name + compatibility check
|
||||
auto item_iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
[&filament_name, this](auto& f) { return f.name == filament_name && f.is_compatible; });
|
||||
|
||||
// Second match: if first fails, try with @U1 suffix + compatibility check
|
||||
if (item_iter == filaments.end()) {
|
||||
item_iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
[&filament_name, this](auto& f) { return f.name == filament_name + " @U1"; });
|
||||
[&filament_name, this](auto& f) { return f.name == filament_name + " @U1" && f.is_compatible; });
|
||||
}
|
||||
|
||||
if (item_iter != filaments.end()) {
|
||||
@@ -1721,12 +1724,15 @@ void TabPresetComboBox::update()
|
||||
|
||||
for (auto iter = machine_filaments.begin(); iter != machine_filaments.end();) {
|
||||
std::string filament_name = iter->second.first;
|
||||
auto item_iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
[&filament_name, this](auto& f) { return f.name == filament_name; });
|
||||
|
||||
// First match: exact name + compatibility check
|
||||
auto item_iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
[&filament_name, this](auto& f) { return f.name == filament_name && f.is_compatible; });
|
||||
|
||||
// Second match: if first fails, try with @U1 suffix + compatibility check
|
||||
if (item_iter == filaments.end()) {
|
||||
item_iter = std::find_if(filaments.begin(), filaments.end(),
|
||||
[&filament_name, this](auto& f) { return f.name == filament_name + " @U1"; });
|
||||
[&filament_name, this](auto& f) { return f.name == filament_name + " @U1" && f.is_compatible; });
|
||||
}
|
||||
|
||||
if (item_iter != filaments.end()) {
|
||||
|
||||
@@ -68,7 +68,7 @@ void PrintHostSendDialog::init()
|
||||
|
||||
const AppConfig* app_config = wxGetApp().app_config;
|
||||
|
||||
auto *label_dir_hint = new wxStaticText(this, wxID_ANY, _L("Please do not include the special characters #, *, and ;in filenames."));
|
||||
auto *label_dir_hint = new wxStaticText(this, wxID_ANY, _L("Please do not include the special characters #, *, ;, \\, /, :, \", <, >, or | in filenames."));
|
||||
label_dir_hint->Wrap(CONTENT_WIDTH * wxGetApp().em_unit());
|
||||
|
||||
content_sizer->Add(txt_filename, 0, wxEXPAND);
|
||||
@@ -135,9 +135,9 @@ void PrintHostSendDialog::init()
|
||||
// .gcode suffix control
|
||||
auto validate_path = [this](const wxString &path) -> bool {
|
||||
// BBS: 检查文件名是否包含特殊字符
|
||||
if (path.find_first_of("#*;") != wxString::npos) {
|
||||
if (path.find_first_of("#*;\\/:\"<>|") != wxString::npos) {
|
||||
MessageDialog msg_window(this,
|
||||
wxString::Format(_L("The filename '%s' contains special characters (#, *, or ;) which may cause issues.Do you wish to continue?"), path),
|
||||
wxString::Format(_L("The filename '%s' contains special characters (#, *, ;, \\, /, :, \", <, >, or |) which may cause issues.Do you wish to continue?"), path),
|
||||
wxString(SLIC3R_APP_NAME), wxYES | wxNO | wxICON_WARNING);
|
||||
if (msg_window.ShowModal() == wxID_NO)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user