mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-30 21:22:02 +08:00
Plater refactoring
* Extract unrelated functions
This commit is contained in:
parent
feac3b62ed
commit
818bb91449
@ -240,7 +240,7 @@ bool BitmapTextRenderer::GetValueFromEditorCtrl(wxWindow* ctrl, wxVariant& value
|
||||
if (!text_editor || text_editor->GetValue().IsEmpty())
|
||||
return false;
|
||||
|
||||
m_was_unusable_symbol = Slic3r::GUI::Plater::has_illegal_filename_characters(text_editor->GetValue());
|
||||
m_was_unusable_symbol = Slic3r::GUI::has_illegal_characters(text_editor->GetValue());
|
||||
if (m_was_unusable_symbol)
|
||||
return false;
|
||||
|
||||
|
@ -481,4 +481,26 @@ bool create_process(const boost::filesystem::path& path, const std::wstring& cmd
|
||||
}
|
||||
#endif //_WIN32
|
||||
|
||||
|
||||
bool has_illegal_characters(const wxString& wxs_name)
|
||||
{
|
||||
const std::string name = into_u8(wxs_name);
|
||||
return has_illegal_characters(name);
|
||||
}
|
||||
|
||||
bool has_illegal_characters(const std::string& name)
|
||||
{
|
||||
for (size_t i = 0; i < std::strlen(illegal_characters); i++)
|
||||
if (name.find_first_of(illegal_characters[i]) != std::string::npos)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void show_illegal_characters_warning(wxWindow* parent)
|
||||
{
|
||||
show_error(parent, format_wxstr("%1%\n%2% %3%", _L("The provided name is not valid;"),
|
||||
_L("the following characters are not allowed:"), illegal_characters));
|
||||
}
|
||||
|
||||
} } // namespaces GUI / Slic3r
|
||||
|
@ -29,6 +29,8 @@ class Print;
|
||||
|
||||
namespace GUI {
|
||||
|
||||
static constexpr char illegal_characters[] = "<>:/\\|?*\"";
|
||||
|
||||
void disable_screensaver();
|
||||
void enable_screensaver();
|
||||
bool debugged();
|
||||
@ -102,6 +104,10 @@ void desktop_execute_get_result(wxString command, wxArrayString& output);
|
||||
bool create_process(const boost::filesystem::path& path, const std::wstring& cmd_opt, std::string& error_msg);
|
||||
#endif //_WIN32
|
||||
|
||||
bool has_illegal_characters(const wxString& name);
|
||||
bool has_illegal_characters(const std::string& name);
|
||||
void show_illegal_characters_warning(wxWindow* parent);
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
||||
|
@ -4553,8 +4553,8 @@ void ObjectList::rename_item()
|
||||
if (new_name.IsEmpty())
|
||||
return;
|
||||
|
||||
if (Plater::has_illegal_filename_characters(new_name)) {
|
||||
Plater::show_illegal_characters_warning(this);
|
||||
if (has_illegal_characters(new_name)) {
|
||||
show_illegal_characters_warning(this);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -4780,7 +4780,7 @@ void ObjectList::OnEditingDone(wxDataViewEvent &event)
|
||||
const auto renderer = dynamic_cast<BitmapTextRenderer*>(GetColumn(colName)->GetRenderer());
|
||||
|
||||
if (renderer->WasCanceled())
|
||||
wxTheApp->CallAfter([this]{ Plater::show_illegal_characters_warning(this); });
|
||||
wxTheApp->CallAfter([this]{ show_illegal_characters_warning(this); });
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected.
|
||||
|
@ -150,29 +150,6 @@ wxDEFINE_EVENT(EVT_SLICING_COMPLETED, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_PROCESS_COMPLETED, SlicingProcessCompletedEvent);
|
||||
wxDEFINE_EVENT(EVT_EXPORT_BEGAN, wxCommandEvent);
|
||||
|
||||
|
||||
bool Plater::has_illegal_filename_characters(const wxString& wxs_name)
|
||||
{
|
||||
std::string name = into_u8(wxs_name);
|
||||
return has_illegal_filename_characters(name);
|
||||
}
|
||||
|
||||
bool Plater::has_illegal_filename_characters(const std::string& name)
|
||||
{
|
||||
const char* illegal_characters = "<>:/\\|?*\"";
|
||||
for (size_t i = 0; i < std::strlen(illegal_characters); i++)
|
||||
if (name.find_first_of(illegal_characters[i]) != std::string::npos)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Plater::show_illegal_characters_warning(wxWindow* parent)
|
||||
{
|
||||
show_error(parent, _L("The provided name is not valid;") + "\n" +
|
||||
_L("the following characters are not allowed:") + " <>:/\\|?*\"");
|
||||
}
|
||||
|
||||
// Plater::DropTarget
|
||||
|
||||
class PlaterDropTarget : public wxFileDropTarget
|
||||
@ -5233,7 +5210,7 @@ void Plater::export_gcode(bool prefer_removable)
|
||||
auto check_for_error = [this](const boost::filesystem::path& path, wxString& err_out) -> bool {
|
||||
const std::string filename = path.filename().string();
|
||||
const std::string ext = boost::algorithm::to_lower_copy(path.extension().string());
|
||||
if (has_illegal_filename_characters(filename)) {
|
||||
if (has_illegal_characters(filename)) {
|
||||
err_out = _L("The provided file name is not valid.") + "\n" +
|
||||
_L("The following characters are not allowed by a FAT file system:") + " <>:/\\|?*\"";
|
||||
return true;
|
||||
|
@ -418,10 +418,6 @@ public:
|
||||
wxMenu* layer_menu();
|
||||
wxMenu* multi_selection_menu();
|
||||
|
||||
static bool has_illegal_filename_characters(const wxString& name);
|
||||
static bool has_illegal_filename_characters(const std::string& name);
|
||||
static void show_illegal_characters_warning(wxWindow* parent);
|
||||
|
||||
private:
|
||||
void reslice_until_step_inner(int step, const ModelObject &object, bool postpone_error_messages);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user