From b685cbf37cfb8fa1f0da830fb0c2bed5a306252a Mon Sep 17 00:00:00 2001 From: tao wang Date: Mon, 31 Oct 2022 15:52:07 +0800 Subject: [PATCH] NEW:add dont show again button on msgdialog Change-Id: Id532ba9c10f01863dbe0f0319e9c9fd509a818fe --- src/slic3r/GUI/MsgDialog.cpp | 33 +++++++++++++++++++++++++++++++++ src/slic3r/GUI/MsgDialog.hpp | 9 +++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index ad1b8e153..c97f9f851 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -26,6 +26,7 @@ namespace Slic3r { namespace GUI { +wxDEFINE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent); MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, long style, wxBitmap bitmap) : DPIDialog(parent ? parent : dynamic_cast(wxGetApp().mainframe), wxID_ANY, title, wxDefaultPosition, wxSize(360, -1),wxDEFAULT_DIALOG_STYLE) @@ -59,6 +60,10 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he btn_sizer->AddStretchSpacer(); main_sizer->Add(topsizer, 1, wxEXPAND); + + m_dsa_sizer = new wxBoxSizer(wxHORIZONTAL); + btn_sizer->Add(m_dsa_sizer,1,wxEXPAND,0); + btn_sizer->Add(0, 0, 1, wxEXPAND, 5); main_sizer->Add(btn_sizer, 0, wxBOTTOM | wxRIGHT | wxEXPAND, BORDER); apply_style(style); @@ -71,6 +76,34 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he for (auto mb : m_buttons) { delete mb.second->buttondata ; delete mb.second; } } +void MsgDialog::show_dsa_button() +{ + m_checkbox_dsa = new CheckBox(this); + m_dsa_sizer->Add(m_checkbox_dsa, 0, wxALL | wxALIGN_CENTER, FromDIP(2)); + m_checkbox_dsa->Bind(wxEVT_TOGGLEBUTTON, [this](wxCommandEvent& e) { + auto event = wxCommandEvent(EVT_CHECKBOX_CHANGE); + event.SetInt(m_checkbox_dsa->GetValue()?1:0); + event.SetEventObject(this); + wxPostEvent(this, event); + e.Skip(); + }); + + auto m_text_dsa = new wxStaticText(this, wxID_ANY, _L("Don't show again"), wxDefaultPosition, wxDefaultSize, 0); + m_dsa_sizer->Add(m_text_dsa, 0, wxALL | wxALIGN_CENTER, FromDIP(2)); + m_text_dsa->SetFont(::Label::Body_13); + m_text_dsa->SetForegroundColour(wxColour(0x32,0x3A,0x3D)); + btn_sizer->Layout(); + //Fit(); +} + +bool MsgDialog::get_checkbox_state() +{ + if (m_checkbox_dsa) { + return m_checkbox_dsa->GetValue(); + } + return false; +} + void MsgDialog::on_dpi_changed(const wxRect &suggested_rect) { if (m_buttons.size() > 0) { diff --git a/src/slic3r/GUI/MsgDialog.hpp b/src/slic3r/GUI/MsgDialog.hpp index a0e305079..7cdcdeb4d 100644 --- a/src/slic3r/GUI/MsgDialog.hpp +++ b/src/slic3r/GUI/MsgDialog.hpp @@ -13,6 +13,7 @@ #include #include #include "Widgets/Button.hpp" +#include "Widgets/CheckBox.hpp" #include "BBLStatusBar.hpp" #include "BBLStatusBarSend.hpp" @@ -59,7 +60,9 @@ struct MsgDialog : DPIDialog MsgDialog &operator=(const MsgDialog &) = delete; virtual ~MsgDialog(); - virtual void on_dpi_changed(const wxRect &suggested_rect); + void show_dsa_button(); + bool get_checkbox_state(); + virtual void on_dpi_changed(const wxRect& suggested_rect); void SetButtonLabel(wxWindowID btn_id, const wxString& label, bool set_focus = false); protected: @@ -84,10 +87,12 @@ protected: wxFont boldfont; wxBoxSizer *content_sizer; wxBoxSizer *btn_sizer; + wxBoxSizer *m_dsa_sizer; wxStaticBitmap *logo; MsgButtonsHash m_buttons; + CheckBox* m_checkbox_dsa{nullptr}; }; - +wxDECLARE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent); // Generic error dialog, used for displaying exceptions class ErrorDialog : public MsgDialog