From a3a701a95eb13af52bdeb64720c26cd0b7cfccb2 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Tue, 8 Aug 2023 00:51:22 +0100 Subject: [PATCH] Move preferences to an action instead of a wx event --- 3d-viewer/3d_viewer/3d_menubar.cpp | 5 +---- bitmap2component/bitmap2cmp_frame.cpp | 7 +------ common/eda_base_frame.cpp | 7 ------- common/tool/actions.cpp | 12 ++++++++---- common/tool/common_control.cpp | 5 +---- cvpcb/menubar.cpp | 8 +------- eeschema/menubar.cpp | 8 +------- eeschema/sim/toolbars_simulator_frame.cpp | 8 +------- eeschema/symbol_editor/menubar_symbol_editor.cpp | 8 +------- gerbview/menubar.cpp | 7 +------ include/eda_base_frame.h | 5 ----- kicad/menubar.cpp | 8 +------- pagelayout_editor/menubar.cpp | 7 +------ pcb_calculator/pcb_calculator_frame.cpp | 8 ++------ pcbnew/menubar_footprint_editor.cpp | 8 +------- pcbnew/menubar_pcb_editor.cpp | 8 +------- pcbnew/widgets/appearance_controls.cpp | 3 +-- 17 files changed, 23 insertions(+), 99 deletions(-) diff --git a/3d-viewer/3d_viewer/3d_menubar.cpp b/3d-viewer/3d_viewer/3d_menubar.cpp index 7b87619668..4886c5be61 100644 --- a/3d-viewer/3d_viewer/3d_menubar.cpp +++ b/3d-viewer/3d_viewer/3d_menubar.cpp @@ -109,10 +109,7 @@ void EDA_3D_VIEWER_FRAME::CreateMenuBar() BITMAPS::tools, ACTION_MENU::CHECK ); - prefsMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ), - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences ); prefsMenu->Add( _( "Reset to Default Settings" ), ID_MENU3D_RESET_DEFAULTS, BITMAPS::tools ); diff --git a/bitmap2component/bitmap2cmp_frame.cpp b/bitmap2component/bitmap2cmp_frame.cpp index a610e88bb1..3ce7c589cb 100644 --- a/bitmap2component/bitmap2cmp_frame.cpp +++ b/bitmap2component/bitmap2cmp_frame.cpp @@ -245,12 +245,7 @@ void BITMAP2CMP_FRAME::doReCreateMenuBar() // ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool ); - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,", - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences ); prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, tool ); diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 9603e4efb9..a339e80cb4 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -101,7 +101,6 @@ static const wxSize defaultSize( FRAME_T aFrameType ) BEGIN_EVENT_TABLE( EDA_BASE_FRAME, wxFrame ) EVT_MENU( wxID_ABOUT, EDA_BASE_FRAME::OnKicadAbout ) - EVT_MENU( wxID_PREFERENCES, EDA_BASE_FRAME::OnPreferences ) EVT_CHAR_HOOK( EDA_BASE_FRAME::OnCharHook ) EVT_MENU_OPEN( EDA_BASE_FRAME::OnMenuEvent ) @@ -1049,12 +1048,6 @@ void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event ) } -void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event ) -{ - ShowPreferences( wxEmptyString, wxEmptyString ); -} - - void EDA_BASE_FRAME::ShowPreferences( wxString aStartPage, wxString aStartParentPage ) { wxBeginBusyCursor( wxHOURGLASS_CURSOR ); diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index 39eed31db2..e4faccfa29 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -738,10 +738,14 @@ TOOL_ACTION ACTIONS::updateSchematicFromPcb( "common.Control.updateSchematicFrom _( "Update Schematic from PCB..." ), _( "Update schematic with changes made to PCB" ), BITMAPS::update_sch_from_pcb ); -TOOL_ACTION ACTIONS::openPreferences( "common.SuiteControl.openPreferences", - AS_GLOBAL, MD_CTRL + ',', "", - _( "Preferences..." ), _( "Show preferences for all open tools" ), - BITMAPS::preference ); +TOOL_ACTION ACTIONS::openPreferences( TOOL_ACTION_ARGS() + .Name( "common.SuiteControl.openPreferences" ) + .Scope( AS_GLOBAL ) + .DefaultHotkey( MD_CTRL + ',' ) + .MenuText( _( "Preferences..." ) ) + .Tooltip( _( "Show preferences for all open tools" ) ) + .Icon( BITMAPS::preference ) + .UIId( wxID_PREFERENCES ) ); TOOL_ACTION ACTIONS::configurePaths( "common.SuiteControl.configurePaths", AS_GLOBAL, 0, "", diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp index 994bb54d43..6dbc3c8a66 100644 --- a/common/tool/common_control.cpp +++ b/common/tool/common_control.cpp @@ -68,10 +68,7 @@ void COMMON_CONTROL::Reset( RESET_REASON aReason ) int COMMON_CONTROL::OpenPreferences( const TOOL_EVENT& aEvent ) { - wxCommandEvent dummy; - - m_frame->OnPreferences( dummy ); - + m_frame->ShowPreferences( wxEmptyString, wxEmptyString ); return 0; } diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index 50b88461b2..d446322c1e 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -68,13 +68,7 @@ void CVPCB_MAINFRAME::doReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showFootprintLibTable ); - - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - prefsMenu->Add( _( "Preferences..." ) + wxS( "\tCtrl+," ), - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences); prefsMenu->AppendSeparator(); prefsMenu->Add( CVPCB_ACTIONS::showEquFileTable); diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index e1cfafe22b..dadcd6b160 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -313,13 +313,7 @@ void SCH_EDIT_FRAME::doReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showSymbolLibTable ); - - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,", - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences ); prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); diff --git a/eeschema/sim/toolbars_simulator_frame.cpp b/eeschema/sim/toolbars_simulator_frame.cpp index 63d8b1248d..3b6063f5a4 100644 --- a/eeschema/sim/toolbars_simulator_frame.cpp +++ b/eeschema/sim/toolbars_simulator_frame.cpp @@ -146,13 +146,7 @@ void SIMULATOR_FRAME::doReCreateMenuBar() //prefsMenu->Add( ACTIONS::configurePaths ); //prefsMenu->Add( EE_ACTIONS::showSimLibTable ); - - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,", - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences ); prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, tool ); diff --git a/eeschema/symbol_editor/menubar_symbol_editor.cpp b/eeschema/symbol_editor/menubar_symbol_editor.cpp index 5d714a034e..a61cfacbc0 100644 --- a/eeschema/symbol_editor/menubar_symbol_editor.cpp +++ b/eeschema/symbol_editor/menubar_symbol_editor.cpp @@ -165,13 +165,7 @@ void SYMBOL_EDIT_FRAME::doReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showSymbolLibTable ); - - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,", - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences ); prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 64324953f5..5b711214a2 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -221,12 +221,7 @@ void GERBVIEW_FRAME::doReCreateMenuBar() // ACTION_MENU* preferencesMenu = new ACTION_MENU( false, selTool ); - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - preferencesMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ), - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + preferencesMenu->Add( ACTIONS::openPreferences ); preferencesMenu->AppendSeparator(); AddMenuLanguageList( preferencesMenu, selTool ); diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index d137568294..94a289f9cc 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -211,11 +211,6 @@ public: void OnKicadAbout( wxCommandEvent& event ); - /** - * Displays the preferences and settings of all opened editors paged dialog - */ - void OnPreferences( wxCommandEvent& event ); - /** * Displays the preferences and settings of all opened editors paged dialog, starting with * a particular page diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index f41bedf5a0..fdb3a38822 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -196,13 +196,7 @@ void KICAD_MANAGER_FRAME::doReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showSymbolLibTable ); prefsMenu->Add( ACTIONS::showFootprintLibTable ); - - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - prefsMenu->Add( _( "Preferences..." ) + wxS( "\tCtrl+," ), - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences ); prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, controlTool ); diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index 0d066090d9..72adbc3422 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -156,12 +156,7 @@ void PL_EDITOR_FRAME::doReCreateMenuBar() // ACTION_MENU* preferencesMenu = new ACTION_MENU( false, selTool ); - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - preferencesMenu->Add( _( "Preferences..." ) + "\tCtrl+,", - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + preferencesMenu->Add( ACTIONS::openPreferences ); // Language submenu AddMenuLanguageList( preferencesMenu, selTool ); diff --git a/pcb_calculator/pcb_calculator_frame.cpp b/pcb_calculator/pcb_calculator_frame.cpp index 691525ef72..e038a7cbdd 100644 --- a/pcb_calculator/pcb_calculator_frame.cpp +++ b/pcb_calculator/pcb_calculator_frame.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -213,12 +214,7 @@ void PCB_CALCULATOR_FRAME::doReCreateMenuBar() // ACTION_MENU* prefsMenu = new ACTION_MENU( false, tool ); - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - prefsMenu->Add( _( "Preferences..." ) + "\tCtrl+,", - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences ); prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, tool ); diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index f7f21dbc49..05314bcdf9 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -239,13 +239,7 @@ void FOOTPRINT_EDIT_FRAME::doReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showFootprintLibTable ); - - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - prefsMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ), - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences ); prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 9f92d934f6..f7b03b0f98 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -451,13 +451,7 @@ void PCB_EDIT_FRAME::doReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showFootprintLibTable ); - - // We can't use ACTIONS::showPreferences yet because wxWidgets moves this on - // Mac, and it needs the wxID_PREFERENCES id to find it. - prefsMenu->Add( _( "Preferences..." ) + wxT( "\tCtrl+," ), - _( "Show preferences for all open tools" ), - wxID_PREFERENCES, - BITMAPS::preference ); + prefsMenu->Add( ACTIONS::openPreferences ); prefsMenu->AppendSeparator(); AddMenuLanguageList( prefsMenu, selTool ); diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 7b6d4171d0..17e5dddac9 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -3278,8 +3278,7 @@ void APPEARANCE_CONTROLS::onReadOnlySwatch() button->Bind( wxEVT_COMMAND_HYPERLINK, std::function( [&]( wxHyperlinkEvent& aEvent ) { - wxCommandEvent dummy; - m_frame->OnPreferences( dummy ); + m_frame->ShowPreferences( wxEmptyString, wxEmptyString ); } ) ); infobar->RemoveAllButtons();