Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuSanka <yusanka@gmail.com>2022-02-02 13:35:07 +0300
committerYuSanka <yusanka@gmail.com>2022-02-02 14:44:36 +0300
commitfc59a2c1b050af8cd2b257448b9d4b4931ff77c0 (patch)
treefcb92d3b2fcf4a76cf52e7cc2d356cadc74813db /src
parent1fb41a8e2242064a893ec1d03b3c3181e7232fa1 (diff)
Implemented FR #7850 - G-Code Substitutions: move [X Delete all] button or ask for confirmation
+ MsgDialog: * Added processing if the wxNO_DEFAULT and wxCANCEL_DEFAULT flags * Next improvements of get_wraped_wxString() function
Diffstat (limited to 'src')
-rw-r--r--src/slic3r/GUI/MsgDialog.cpp38
-rw-r--r--src/slic3r/GUI/Tab.cpp5
2 files changed, 20 insertions, 23 deletions
diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp
index db4972a5d..2b8657294 100644
--- a/src/slic3r/GUI/MsgDialog.cpp
+++ b/src/slic3r/GUI/MsgDialog.cpp
@@ -94,9 +94,9 @@ wxButton* MsgDialog::get_button(wxWindowID btn_id){
void MsgDialog::apply_style(long style)
{
if (style & wxOK) add_button(wxID_OK, true);
- if (style & wxYES) add_button(wxID_YES, true);
- if (style & wxNO) add_button(wxID_NO);
- if (style & wxCANCEL) add_button(wxID_CANCEL);
+ if (style & wxYES) add_button(wxID_YES, !(style & wxNO_DEFAULT));
+ if (style & wxNO) add_button(wxID_NO, (style & wxNO_DEFAULT));
+ if (style & wxCANCEL) add_button(wxID_CANCEL, (style & wxCANCEL_DEFAULT));
logo->SetBitmap( create_scaled_bitmap(style & wxICON_WARNING ? "exclamation" :
style & wxICON_INFORMATION ? "info" :
@@ -298,25 +298,12 @@ wxString get_wraped_wxString(const wxString& in, size_t line_len /*=80*/)
for (size_t i = 0; i < in.size();) {
// Overwrite the character (space or newline) starting at ibreak?
bool overwrite = false;
-#if wxUSE_UNICODE_WCHAR
- // On Windows, most likely the internal representation of wxString is wide char.
- size_t end = std::min(in.size(), i + line_len);
- size_t ibreak = end;
- for (size_t j = i; j < end; ++ j) {
- if (bool newline = in[j] == '\n'; in[j] == ' ' || in[j] == '\t' || newline) {
- ibreak = j;
- overwrite = true;
- if (newline)
- break;
- } else if (in[j] == '/' || in[j] == '\\')
- ibreak = j + 1;
- }
-#else
// UTF8 representation of wxString.
// Where to break the line, index of character at the start of a UTF-8 sequence.
size_t ibreak = size_t(-1);
// Overwrite the character at ibreak (it is a whitespace) or not?
- for (size_t cnt = 0, j = i; j < in.size();) {
+ size_t j = i;
+ for (size_t cnt = 0; j < in.size();) {
if (bool newline = in[j] == '\n'; in[j] == ' ' || in[j] == '\t' || newline) {
// Overwrite the whitespace.
ibreak = j ++;
@@ -325,16 +312,23 @@ wxString get_wraped_wxString(const wxString& in, size_t line_len /*=80*/)
break;
} else if (in[j] == '/') {
// Insert after the slash.
- ibreak = ++ j;
+ ibreak = ++ j;
+ overwrite = false;
} else
j += get_utf8_sequence_length(in.c_str() + j, in.size() - j);
if (++ cnt == line_len) {
- if (ibreak == size_t(-1))
- ibreak = j;
+ if (ibreak == size_t(-1)) {
+ ibreak = j;
+ overwrite = false;
+ }
break;
}
}
-#endif
+ if (j == in.size()) {
+ out.append(in.begin() + i, in.end());
+ break;
+ }
+ assert(ibreak != size_t(-1));
out.append(in.begin() + i, in.begin() + ibreak);
out.append('\n');
i = ibreak;
diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp
index 225887c98..9bfc091e4 100644
--- a/src/slic3r/GUI/Tab.cpp
+++ b/src/slic3r/GUI/Tab.cpp
@@ -4139,7 +4139,10 @@ wxSizer* TabPrint::create_manage_substitution_widget(wxWindow* parent)
});
create_btn(&m_del_all_substitutions_btn, _L("Delete all"), "cross");
- m_del_all_substitutions_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent e) {
+ m_del_all_substitutions_btn->Bind(wxEVT_BUTTON, [this, parent](wxCommandEvent e) {
+ if (MessageDialog(parent, _L("Are you sure you want to delete all substitutions?"), SLIC3R_APP_NAME, wxYES_NO | wxICON_QUESTION).
+ ShowModal() != wxID_YES)
+ return;
m_subst_manager.delete_all();
m_del_all_substitutions_btn->Hide();
});