From 8d0a4c7cd642b2047c55309c321f228e6ef3ae06 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 22 Oct 2021 15:35:51 +0200 Subject: [PATCH] SendSystemInfoDialog: Use button instead of hyperlink + Fixed wsWidgets asserts --- src/slic3r/GUI/SendSystemInfoDialog.cpp | 34 +++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/slic3r/GUI/SendSystemInfoDialog.cpp b/src/slic3r/GUI/SendSystemInfoDialog.cpp index 106617e769..f92060bfc8 100644 --- a/src/slic3r/GUI/SendSystemInfoDialog.cpp +++ b/src/slic3r/GUI/SendSystemInfoDialog.cpp @@ -67,8 +67,9 @@ public: SendSystemInfoDialog(wxWindow* parent); private: - bool send_info(); + wxString send_info(); const std::string m_system_info_json; + wxButton* m_btn_show_data; wxButton* m_btn_send; wxButton* m_btn_dont_send; wxButton* m_btn_ask_later; @@ -89,7 +90,7 @@ public: auto* btn = new wxButton(this, wxID_CANCEL, _L("Cancel")); auto* vsizer = new wxBoxSizer(wxVERTICAL); auto *top_sizer = new wxBoxSizer(wxVERTICAL); - vsizer->Add(text, 1, wxEXPAND|wxALIGN_CENTER_HORIZONTAL); + vsizer->Add(text, 1, wxEXPAND); vsizer->AddSpacer(5); vsizer->Add(btn, 0, wxALIGN_CENTER_HORIZONTAL); top_sizer->Add(vsizer, 1, wxEXPAND | wxLEFT | wxTOP | wxRIGHT | wxBOTTOM, 10); @@ -548,7 +549,6 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent) "installation are sent. PrusaSlicer is open source, if you want to " "inspect the code actually performing the communication, see %1%."), std::string("") + filename + ""); - wxString label3 = _L("Show verbatim data that will be sent"); auto* html_window = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxSize(70*em, 34*em), wxHW_SCROLLBAR_NEVER); wxString html = GUI::format_wxstr( @@ -560,17 +560,14 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent) + text1 + "

" "" + "" + label2 + "
" - + text2 + "

" - + "" + label3 + "
" + + text2 + "", bgr_clr_str, text_clr_str); html_window->SetPage(html); - html_window->Bind(wxEVT_HTML_LINK_CLICKED, [this](wxHtmlLinkEvent&) { - ShowJsonDialog dlg(this, m_system_info_json, GetSize().Scale(0.9, 0.7)); - dlg.ShowModal(); - }); vsizer->Add(html_window, 1, wxEXPAND); + m_btn_show_data = new wxButton(this, wxID_ANY, _L("Show verbatim data that will be sent")); + m_btn_ask_later = new wxButton(this, wxID_ANY, _L("Ask me next time")); m_btn_dont_send = new wxButton(this, wxID_ANY, _L("Do not send anything")); m_btn_send = new wxButton(this, wxID_ANY, _L("Send system info")); @@ -582,6 +579,7 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent) hsizer->AddSpacer(em); hsizer->Add(m_btn_send); + vsizer->Add(m_btn_show_data, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 20); vsizer->Add(hsizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 10); topSizer->Add(vsizer, 1, wxEXPAND | wxLEFT | wxTOP | wxRIGHT, 10); @@ -599,9 +597,15 @@ SendSystemInfoDialog::SendSystemInfoDialog(wxWindow* parent) CenterOnParent(); + m_btn_show_data->Bind(wxEVT_BUTTON, [this](wxEvent&) { + ShowJsonDialog dlg(this, m_system_info_json, GetSize().Scale(0.9, 0.7)); + dlg.ShowModal(); + }); + m_btn_send->Bind(wxEVT_BUTTON, [this](const wxEvent&) { - if (send_info()) { + if (wxString out = send_info(); !out.IsEmpty()) { + InfoDialog(nullptr, wxEmptyString, out).ShowModal(); save_version(); EndModal(0); } @@ -630,7 +634,7 @@ void SendSystemInfoDialog::on_dpi_changed(const wxRect&) // This actually sends the info. -bool SendSystemInfoDialog::send_info() +wxString SendSystemInfoDialog::send_info() { std::atomic job_done = false; // Flag to communicate between threads. struct Result { @@ -674,11 +678,9 @@ bool SendSystemInfoDialog::send_info() job_done = true; // In case the user closed the dialog, let the other thread know sending_thread.join(); // and wait until it terminates. - if (result.value != Result::Cancelled) { // user knows he cancelled, no need to tell him. - InfoDialog info_dlg(wxGetApp().mainframe, wxEmptyString, result.str); - info_dlg.ShowModal(); - } - return result.value == Result::Success; + if (result.value == Result::Cancelled) + return ""; + return result.str; }