From f24f0d93a5fa98c37feba1f6d6c04d44301bbf22 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 22 Mar 2021 20:06:05 +0000 Subject: [PATCH] Make OK default in inspectors (and hook up to close window). Fixes https://gitlab.com/kicad/code/kicad/issues/7831 --- common/dialogs/dialog_HTML_reporter_base.cpp | 4 +++- common/dialogs/dialog_HTML_reporter_base.fbp | 3 ++- common/dialogs/dialog_HTML_reporter_base.h | 4 +++- pcbnew/dialogs/dialog_constraints_reporter.cpp | 1 + pcbnew/dialogs/dialog_constraints_reporter.h | 5 +++++ pcbnew/dialogs/dialog_constraints_reporter_base.cpp | 6 ++++++ pcbnew/dialogs/dialog_constraints_reporter_base.fbp | 1 + pcbnew/dialogs/dialog_constraints_reporter_base.h | 4 ++++ pcbnew/tools/board_inspection_tool.h | 10 +++++++++- 9 files changed, 34 insertions(+), 4 deletions(-) diff --git a/common/dialogs/dialog_HTML_reporter_base.cpp b/common/dialogs/dialog_HTML_reporter_base.cpp index 27029ed6c3..193d22c731 100644 --- a/common/dialogs/dialog_HTML_reporter_base.cpp +++ b/common/dialogs/dialog_HTML_reporter_base.cpp @@ -11,7 +11,7 @@ /////////////////////////////////////////////////////////////////////////// -DIALOG_HTML_REPORTER::DIALOG_HTML_REPORTER( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +DIALOG_HTML_REPORTER::DIALOG_HTML_REPORTER( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); @@ -39,11 +39,13 @@ DIALOG_HTML_REPORTER::DIALOG_HTML_REPORTER( wxWindow* parent, wxWindowID id, con // Connect Events m_Reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_HTML_REPORTER::OnErrorLinkClicked ), NULL, this ); + m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_HTML_REPORTER::OnOK ), NULL, this ); } DIALOG_HTML_REPORTER::~DIALOG_HTML_REPORTER() { // Disconnect Events m_Reporter->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_HTML_REPORTER::OnErrorLinkClicked ), NULL, this ); + m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_HTML_REPORTER::OnOK ), NULL, this ); } diff --git a/common/dialogs/dialog_HTML_reporter_base.fbp b/common/dialogs/dialog_HTML_reporter_base.fbp index 20bf985865..cbb13fd57a 100644 --- a/common/dialogs/dialog_HTML_reporter_base.fbp +++ b/common/dialogs/dialog_HTML_reporter_base.fbp @@ -47,7 +47,7 @@ wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER - ; ; forward_declare + DIALOG_SHIM; dialog_shim.h; forward_declare Report @@ -133,6 +133,7 @@ m_sdbSizer protected + OnOK diff --git a/common/dialogs/dialog_HTML_reporter_base.h b/common/dialogs/dialog_HTML_reporter_base.h index cd4e405804..a79e4830cf 100644 --- a/common/dialogs/dialog_HTML_reporter_base.h +++ b/common/dialogs/dialog_HTML_reporter_base.h @@ -12,6 +12,7 @@ #include class WX_HTML_REPORT_BOX; +#include "dialog_shim.h" #include #include #include @@ -28,7 +29,7 @@ class WX_HTML_REPORT_BOX; /////////////////////////////////////////////////////////////////////////////// /// Class DIALOG_HTML_REPORTER /////////////////////////////////////////////////////////////////////////////// -class DIALOG_HTML_REPORTER : public wxDialog +class DIALOG_HTML_REPORTER : public DIALOG_SHIM { private: @@ -38,6 +39,7 @@ class DIALOG_HTML_REPORTER : public wxDialog // Virtual event handlers, overide them in your derived class virtual void OnErrorLinkClicked( wxHtmlLinkEvent& event ) { event.Skip(); } + virtual void OnOK( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/dialogs/dialog_constraints_reporter.cpp b/pcbnew/dialogs/dialog_constraints_reporter.cpp index 5134b8909f..254849ebc7 100644 --- a/pcbnew/dialogs/dialog_constraints_reporter.cpp +++ b/pcbnew/dialogs/dialog_constraints_reporter.cpp @@ -36,6 +36,7 @@ DIALOG_CONSTRAINTS_REPORTER::DIALOG_CONSTRAINTS_REPORTER( PCB_EDIT_FRAME* aParen void DIALOG_CONSTRAINTS_REPORTER::FinishInitialization() { + m_sdbSizerOK->SetDefault(); finishDialogSettings(); } diff --git a/pcbnew/dialogs/dialog_constraints_reporter.h b/pcbnew/dialogs/dialog_constraints_reporter.h index 647c69bfef..6178518e82 100644 --- a/pcbnew/dialogs/dialog_constraints_reporter.h +++ b/pcbnew/dialogs/dialog_constraints_reporter.h @@ -37,6 +37,11 @@ public: void FinishInitialization(); + void OnOK( wxCommandEvent& event ) override + { + Close(); + } + void OnErrorLinkClicked( wxHtmlLinkEvent& event ); void DeleteAllPages(); diff --git a/pcbnew/dialogs/dialog_constraints_reporter_base.cpp b/pcbnew/dialogs/dialog_constraints_reporter_base.cpp index 07ed8b6b0d..7cc28b073a 100644 --- a/pcbnew/dialogs/dialog_constraints_reporter_base.cpp +++ b/pcbnew/dialogs/dialog_constraints_reporter_base.cpp @@ -35,8 +35,14 @@ DIALOG_CONSTRAINTS_REPORTER_BASE::DIALOG_CONSTRAINTS_REPORTER_BASE( wxWindow* pa bMainSizer->Fit( this ); this->Centre( wxBOTH ); + + // Connect Events + m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONSTRAINTS_REPORTER_BASE::OnOK ), NULL, this ); } DIALOG_CONSTRAINTS_REPORTER_BASE::~DIALOG_CONSTRAINTS_REPORTER_BASE() { + // Disconnect Events + m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONSTRAINTS_REPORTER_BASE::OnOK ), NULL, this ); + } diff --git a/pcbnew/dialogs/dialog_constraints_reporter_base.fbp b/pcbnew/dialogs/dialog_constraints_reporter_base.fbp index a71b0bb2db..32cc370426 100644 --- a/pcbnew/dialogs/dialog_constraints_reporter_base.fbp +++ b/pcbnew/dialogs/dialog_constraints_reporter_base.fbp @@ -133,6 +133,7 @@ m_sdbSizer protected + OnOK diff --git a/pcbnew/dialogs/dialog_constraints_reporter_base.h b/pcbnew/dialogs/dialog_constraints_reporter_base.h index d5deda4782..7f25e6628e 100644 --- a/pcbnew/dialogs/dialog_constraints_reporter_base.h +++ b/pcbnew/dialogs/dialog_constraints_reporter_base.h @@ -36,6 +36,10 @@ class DIALOG_CONSTRAINTS_REPORTER_BASE : public DIALOG_SHIM wxStdDialogButtonSizer* m_sdbSizer; wxButton* m_sdbSizerOK; + // Virtual event handlers, overide them in your derived class + virtual void OnOK( wxCommandEvent& event ) { event.Skip(); } + + public: DIALOG_CONSTRAINTS_REPORTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Constraints Resolution Report"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); diff --git a/pcbnew/tools/board_inspection_tool.h b/pcbnew/tools/board_inspection_tool.h index bc8b3aa4f3..b1b8ca74d1 100644 --- a/pcbnew/tools/board_inspection_tool.h +++ b/pcbnew/tools/board_inspection_tool.h @@ -41,10 +41,18 @@ public: DIALOG_INSPECTION_REPORTER( PCB_EDIT_FRAME* aFrame ) : DIALOG_HTML_REPORTER( aFrame ), m_frame( aFrame ) - { } + { + m_sdbSizerOK->SetDefault(); + SetInitialFocus( m_sdbSizerOK ); + } void OnErrorLinkClicked( wxHtmlLinkEvent& event ) override; + void OnOK( wxCommandEvent& event ) override + { + Close(); + } + protected: PCB_EDIT_FRAME* m_frame; };