Follow-up to 1dffc40f32 - Fixed a message text.

+Improved context of the MessageDialogs. We can use hyperlinks now.
This commit is contained in:
YuSanka 2022-01-12 11:19:59 +01:00
parent 1dffc40f32
commit 5a2925466d
2 changed files with 38 additions and 14 deletions

View file

@ -1322,19 +1322,31 @@ bool GUI_App::on_init_inner()
m_initialized = true; m_initialized = true;
if (const std::string& crash_reason = app_config->get("restore_win_position"); if (const std::string& crash_reason = app_config->get("restore_win_position");
crash_reason.find_first_of("crashed") == 0) boost::starts_with(crash_reason,"crashed"))
{ {
MessageDialog dialog(mainframe, wxString preferences_item = _L("Restore window position on start");
format_wxstr(_L("PrusaSlicer was crashed during a previous start due to \"%1%\".\n" InfoDialog dialog(nullptr,
"PrusaSlicer works in save mode now.\n" _L("PrusaSlicer is started in save mode"),
"To avoid a next application crash you have to disable\n" format_wxstr(_L("PrusaSlicer was crashed last time due to \"%1%\".\n"
"\"%2%\" in \"Preferences\""), from_u8(crash_reason), _L("Restore window position on start")) "For more information see issues \"%2%\" and \"%3%\"\n\n"
+ "\n\n" + "To avoid an application crash next time you have to disable\n"
format_wxstr(_L("Do you want to disable \"%1%\"?"), _L("Restore window position on start")), "\"%4%\" in \"Preferences\""),
_L("Start PrusaSlicer in save mode"), "<b>" + from_u8(crash_reason) + "</b>",
wxICON_QUESTION | wxYES_NO); "<a href=http://github.com/prusa3d/PrusaSlicer/issues/2939>#2939</a>",
if (dialog.ShowModal() == wxID_YES) "<a href=http://github.com/prusa3d/PrusaSlicer/issues/5573>#5573</a>",
"<b>" + preferences_item + "</b>")
+ "\n\n" +
format_wxstr(_L("Note: Enabling of the \"%1%\" will caused an application crash on next start."), preferences_item),
true, wxYES_NO);
dialog.SetButtonLabel(wxID_YES, format_wxstr(_L("Disable \"%1%\""), preferences_item));
dialog.SetButtonLabel(wxID_NO, format_wxstr(_L("Enable \"%1%\"") , preferences_item));
auto answer = dialog.ShowModal();
if (answer == wxID_YES)
app_config->set("restore_win_position", "0"); app_config->set("restore_win_position", "0");
else if (answer == wxID_NO)
app_config->set("restore_win_position", "1");
} }
return true; return true;

View file

@ -24,7 +24,6 @@
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, long style, wxBitmap bitmap) MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, long style, wxBitmap bitmap)
: wxDialog(parent ? parent : dynamic_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) : wxDialog(parent ? parent : dynamic_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
, boldfont(wxGetApp().normal_font()) , boldfont(wxGetApp().normal_font())
@ -182,13 +181,26 @@ static void add_msg_content(wxWindow* parent, wxBoxSizer* content_sizer, wxStrin
} }
html->SetMinSize(page_size); html->SetMinSize(page_size);
std::string msg_escaped = xml_escape(msg.ToUTF8().data(), is_marked_msg); std::string msg_escaped = xml_escape(into_u8(msg), is_marked_msg);
boost::replace_all(msg_escaped, "\r\n", "<br>"); boost::replace_all(msg_escaped, "\r\n", "<br>");
boost::replace_all(msg_escaped, "\n", "<br>"); boost::replace_all(msg_escaped, "\n", "<br>");
if (monospaced_font) if (monospaced_font)
// Code formatting will be preserved. This is useful for reporting errors from the placeholder parser. // Code formatting will be preserved. This is useful for reporting errors from the placeholder parser.
msg_escaped = std::string("<pre><code>") + msg_escaped + "</code></pre>"; msg_escaped = std::string("<pre><code>") + msg_escaped + "</code></pre>";
html->SetPage("<html><body bgcolor=\"" + bgr_clr_str + "\"><font color=\"" + text_clr_str + "\">" + wxString::FromUTF8(msg_escaped.data()) + "</font></body></html>"); html->SetPage(format_wxstr("<html>"
"<body bgcolor=%1% link=%2%>"
"<font color=%2%>"
"%3%"
"</font>"
"</body>"
"</html>",
bgr_clr_str, text_clr_str, from_u8(msg_escaped)));
html->Bind(wxEVT_HTML_LINK_CLICKED, [parent](wxHtmlLinkEvent& event) {
wxGetApp().open_browser_with_warning_dialog(event.GetLinkInfo().GetHref(), parent, false);
event.Skip(false);
});
content_sizer->Add(html, 1, wxEXPAND); content_sizer->Add(html, 1, wxEXPAND);
wxGetApp().UpdateDarkUI(html); wxGetApp().UpdateDarkUI(html);
} }