From 1a534ade892e8e6f95fb742b359db4b3acf398df Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Mon, 24 Jan 2022 20:30:54 -0500 Subject: [PATCH] Remove UpdateUI from preferences pdf viewer option Partial fix for https://gitlab.com/kicad/code/kicad/-/issues/10590 --- common/dialogs/panel_common_settings.cpp | 42 +++++++++++-------- common/dialogs/panel_common_settings_base.cpp | 10 ++--- common/dialogs/panel_common_settings_base.fbp | 4 +- common/dialogs/panel_common_settings_base.h | 4 +- include/dialogs/panel_common_settings.h | 5 ++- 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/common/dialogs/panel_common_settings.cpp b/common/dialogs/panel_common_settings.cpp index 30f532ea53..ca8f8ee7a4 100644 --- a/common/dialogs/panel_common_settings.cpp +++ b/common/dialogs/panel_common_settings.cpp @@ -144,32 +144,32 @@ PANEL_COMMON_SETTINGS::PANEL_COMMON_SETTINGS( DIALOG_SHIM* aDialog, wxWindow* aP if( m_iconScaleSlider ) { - m_iconScaleSlider->Connect( wxEVT_SCROLL_TOP, - wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), + m_iconScaleSlider->Connect( wxEVT_SCROLL_TOP, + wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), nullptr, this ); - m_iconScaleSlider->Connect( wxEVT_SCROLL_BOTTOM, - wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), + m_iconScaleSlider->Connect( wxEVT_SCROLL_BOTTOM, + wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), nullptr, this ); - m_iconScaleSlider->Connect( wxEVT_SCROLL_LINEUP, - wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), + m_iconScaleSlider->Connect( wxEVT_SCROLL_LINEUP, + wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), nullptr, this ); m_iconScaleSlider->Connect( wxEVT_SCROLL_LINEDOWN, - wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), + wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), nullptr, this ); m_iconScaleSlider->Connect( wxEVT_SCROLL_PAGEUP, - wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), + wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), nullptr, this ); m_iconScaleSlider->Connect( wxEVT_SCROLL_PAGEDOWN, - wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), + wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), nullptr, this ); - m_iconScaleSlider->Connect( wxEVT_SCROLL_THUMBTRACK, - wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), + m_iconScaleSlider->Connect( wxEVT_SCROLL_THUMBTRACK, + wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), nullptr, this ); - m_iconScaleSlider->Connect( wxEVT_SCROLL_THUMBRELEASE, - wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), + m_iconScaleSlider->Connect( wxEVT_SCROLL_THUMBRELEASE, + wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), nullptr, this ); m_iconScaleSlider->Connect( wxEVT_SCROLL_CHANGED, - wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), + wxScrollEventHandler( PANEL_COMMON_SETTINGS::OnScaleSlider ), nullptr, this ); m_iconScaleAuto->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS::OnIconScaleAuto ), @@ -241,6 +241,7 @@ bool PANEL_COMMON_SETTINGS::TransferDataToWindow() m_defaultPDFViewer->SetValue( Pgm().UseSystemPdfBrowser() ); m_otherPDFViewer->SetValue( !Pgm().UseSystemPdfBrowser() ); m_PDFViewerPath->SetValue( Pgm().GetPdfBrowserName() ); + setPdfViewerPathState(); return true; } @@ -316,6 +317,7 @@ void PANEL_COMMON_SETTINGS::ResetPanel() m_defaultPDFViewer->SetValue( defaultSettings.m_System.use_system_pdf_viewer ); m_otherPDFViewer->SetValue( !defaultSettings.m_System.use_system_pdf_viewer ); m_PDFViewerPath->SetValue( defaultSettings.m_System.pdf_viewer_name ); + setPdfViewerPathState(); } @@ -464,8 +466,14 @@ void PANEL_COMMON_SETTINGS::OnPDFViewerClick( wxCommandEvent& event ) } -void PANEL_COMMON_SETTINGS::onUpdateUIPdfPath( wxUpdateUIEvent& event ) +void PANEL_COMMON_SETTINGS::OnRadioButtonPdfViewer( wxCommandEvent& aEvent ) { - // Used by both the m_pdfViewerBtn and m_PDFViewerPath - event.Enable( m_otherPDFViewer->GetValue() ); + setPdfViewerPathState(); } + + +void PANEL_COMMON_SETTINGS::setPdfViewerPathState() +{ + m_PDFViewerPath->Enable( m_otherPDFViewer->GetValue() ); + m_pdfViewerBtn->Enable( m_otherPDFViewer->GetValue() ); +} \ No newline at end of file diff --git a/common/dialogs/panel_common_settings_base.cpp b/common/dialogs/panel_common_settings_base.cpp index 2790bd3d8f..df245a83b6 100644 --- a/common/dialogs/panel_common_settings_base.cpp +++ b/common/dialogs/panel_common_settings_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -326,9 +326,9 @@ PANEL_COMMON_SETTINGS_BASE::PANEL_COMMON_SETTINGS_BASE( wxWindow* parent, wxWind // Connect Events m_textEditorBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnTextEditorClick ), NULL, this ); - m_PDFViewerPath->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_COMMON_SETTINGS_BASE::onUpdateUIPdfPath ), NULL, this ); + m_defaultPDFViewer->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnRadioButtonPdfViewer ), NULL, this ); + m_otherPDFViewer->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnRadioButtonPdfViewer ), NULL, this ); m_pdfViewerBtn->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnPDFViewerClick ), NULL, this ); - m_pdfViewerBtn->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_COMMON_SETTINGS_BASE::onUpdateUIPdfPath ), NULL, this ); m_canvasScaleAuto->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnCanvasScaleAuto ), NULL, this ); } @@ -336,9 +336,9 @@ PANEL_COMMON_SETTINGS_BASE::~PANEL_COMMON_SETTINGS_BASE() { // Disconnect Events m_textEditorBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnTextEditorClick ), NULL, this ); - m_PDFViewerPath->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_COMMON_SETTINGS_BASE::onUpdateUIPdfPath ), NULL, this ); + m_defaultPDFViewer->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnRadioButtonPdfViewer ), NULL, this ); + m_otherPDFViewer->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnRadioButtonPdfViewer ), NULL, this ); m_pdfViewerBtn->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnPDFViewerClick ), NULL, this ); - m_pdfViewerBtn->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( PANEL_COMMON_SETTINGS_BASE::onUpdateUIPdfPath ), NULL, this ); m_canvasScaleAuto->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PANEL_COMMON_SETTINGS_BASE::OnCanvasScaleAuto ), NULL, this ); } diff --git a/common/dialogs/panel_common_settings_base.fbp b/common/dialogs/panel_common_settings_base.fbp index f8fe78e651..2edac54052 100644 --- a/common/dialogs/panel_common_settings_base.fbp +++ b/common/dialogs/panel_common_settings_base.fbp @@ -662,6 +662,7 @@ + OnRadioButtonPdfViewer @@ -737,6 +738,7 @@ + OnRadioButtonPdfViewer @@ -801,7 +803,6 @@ - onUpdateUIPdfPath @@ -876,7 +877,6 @@ OnPDFViewerClick - onUpdateUIPdfPath diff --git a/common/dialogs/panel_common_settings_base.h b/common/dialogs/panel_common_settings_base.h index 467d44abf3..38e883ec84 100644 --- a/common/dialogs/panel_common_settings_base.h +++ b/common/dialogs/panel_common_settings_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5) +// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -88,7 +88,7 @@ class PANEL_COMMON_SETTINGS_BASE : public RESETTABLE_PANEL // Virtual event handlers, override them in your derived class virtual void OnTextEditorClick( wxCommandEvent& event ) { event.Skip(); } - virtual void onUpdateUIPdfPath( wxUpdateUIEvent& event ) { event.Skip(); } + virtual void OnRadioButtonPdfViewer( wxCommandEvent& event ) { event.Skip(); } virtual void OnPDFViewerClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnCanvasScaleAuto( wxCommandEvent& event ) { event.Skip(); } diff --git a/include/dialogs/panel_common_settings.h b/include/dialogs/panel_common_settings.h index 3aba49136a..7b02e9cbf2 100644 --- a/include/dialogs/panel_common_settings.h +++ b/include/dialogs/panel_common_settings.h @@ -50,7 +50,7 @@ protected: void OnIconScaleAuto( wxCommandEvent& aEvent ); void OnTextEditorClick( wxCommandEvent& event ) override; void OnPDFViewerClick( wxCommandEvent& event ) override; - void onUpdateUIPdfPath( wxUpdateUIEvent& event ) override; + void OnRadioButtonPdfViewer( wxCommandEvent& event ) override; /** * Event fired when the canvas scale field is modified @@ -62,6 +62,9 @@ protected: */ void OnCanvasScaleAuto( wxCommandEvent& aEvent ) override; +private: + void setPdfViewerPathState(); + protected: DIALOG_SHIM* m_dialog;