From 81c7fb61f81c3b0bd9726b2dbc61c5c0e5e437b3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 29 May 2021 18:09:49 +0200 Subject: [PATCH] Sub-menu "Preferences..." in main menu "Preferences": fix not working accelerator key. Accelerator keys are disable in our WX_MENUBAR. A common ACTION_MENU is used and "Preferences..." is now shown in Hotkeys list. --- common/eda_base_frame.cpp | 5 ++--- common/tool/actions.cpp | 7 ++++++- common/tool/common_control.cpp | 9 +++++++++ cvpcb/menubar.cpp | 7 ++----- eeschema/menubar.cpp | 8 ++------ eeschema/symbol_editor/menubar_symbol_editor.cpp | 7 ++----- gerbview/menubar.cpp | 5 +---- include/eda_base_frame.h | 6 +++++- include/tool/actions.h | 3 ++- include/tool/common_control.h | 3 ++- kicad/menubar.cpp | 7 ++----- pagelayout_editor/menubar.cpp | 5 +---- pcbnew/menubar_footprint_editor.cpp | 7 ++----- pcbnew/menubar_pcb_editor.cpp | 5 +---- pcbnew/widgets/appearance_controls.cpp | 3 +-- 15 files changed, 40 insertions(+), 47 deletions(-) diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index b6cac098fe..357be95462 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -91,7 +91,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 ) @@ -900,7 +899,7 @@ void EDA_BASE_FRAME::OnKicadAbout( wxCommandEvent& event ) } -void EDA_BASE_FRAME::OnPreferences( wxCommandEvent& event ) +void EDA_BASE_FRAME::OnPreferences() { PAGED_DIALOG dlg( this, _( "Preferences" ), true ); wxTreebook* book = dlg.GetTreebook(); diff --git a/common/tool/actions.cpp b/common/tool/actions.cpp index c3fce88d91..3d3fb3e521 100644 --- a/common/tool/actions.cpp +++ b/common/tool/actions.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -584,6 +584,11 @@ 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::configurePaths( "common.SuiteControl.configurePaths", AS_GLOBAL, 0, "", _( "Configure Paths..." ), _( "Edit path configuration environment variables" ), diff --git a/common/tool/common_control.cpp b/common/tool/common_control.cpp index ea77207dff..866ada36ec 100644 --- a/common/tool/common_control.cpp +++ b/common/tool/common_control.cpp @@ -3,6 +3,7 @@ * * Copyright (C) 2014-2016 CERN * @author Maciej Suminski + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -77,6 +78,13 @@ void COMMON_CONTROL::Reset( RESET_REASON aReason ) } +int COMMON_CONTROL::OpenPreferences( const TOOL_EVENT& aEvent ) +{ + m_frame->OnPreferences(); + return 0; +} + + int COMMON_CONTROL::ConfigurePaths( const TOOL_EVENT& aEvent ) { // If _pcbnew.kiface is running have it put up the dialog so the 3D paths can also @@ -294,6 +302,7 @@ int COMMON_CONTROL::ReportBug( const TOOL_EVENT& aEvent ) void COMMON_CONTROL::setTransitions() { + Go( &COMMON_CONTROL::OpenPreferences, ACTIONS::openPreferences.MakeEvent() ); Go( &COMMON_CONTROL::ConfigurePaths, ACTIONS::configurePaths.MakeEvent() ); Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showSymbolLibTable.MakeEvent() ); Go( &COMMON_CONTROL::ShowLibraryTable, ACTIONS::showFootprintLibTable.MakeEvent() ); diff --git a/cvpcb/menubar.cpp b/cvpcb/menubar.cpp index 8face7042b..2c3e7cde7e 100644 --- a/cvpcb/menubar.cpp +++ b/cvpcb/menubar.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -68,10 +68,7 @@ void CVPCB_MAINFRAME::ReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showFootprintLibTable ); - prefsMenu->Add( _( "Preferences..." ) + "\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 409eeaa442..5278a22c3b 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019 CERN * * This program is free software; you can redistribute it and/or @@ -261,15 +261,11 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() //-- Preferences menu ----------------------------------------------- - // ACTION_MENU* prefsMenu = new ACTION_MENU( false, selTool ); prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showSymbolLibTable ); - 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/symbol_editor/menubar_symbol_editor.cpp b/eeschema/symbol_editor/menubar_symbol_editor.cpp index 4ace1da38e..40d5008cb0 100644 --- a/eeschema/symbol_editor/menubar_symbol_editor.cpp +++ b/eeschema/symbol_editor/menubar_symbol_editor.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -160,10 +160,7 @@ void SYMBOL_EDIT_FRAME::ReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showSymbolLibTable ); - 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 447e994e85..be6d84a2b7 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -206,10 +206,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // ACTION_MENU* preferencesMenu = new ACTION_MENU( false, selTool ); - preferencesMenu->Add( _( "Preferences..." ) + "\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 4cda7c4b33..982e4d0269 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -202,7 +202,11 @@ public: virtual wxString help_name(); void OnKicadAbout( wxCommandEvent& event ); - void OnPreferences( wxCommandEvent& event ); + + /** + * Displays the preferences and settings of all opened editors paged dialog + */ + void OnPreferences(); void PrintMsg( const wxString& text ); diff --git a/include/tool/actions.h b/include/tool/actions.h index 24db61da04..e4c1f57fcb 100644 --- a/include/tool/actions.h +++ b/include/tool/actions.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2016 CERN - * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors. * @author Maciej Suminski * * This program is free software; you can redistribute it and/or @@ -172,6 +172,7 @@ public: static TOOL_ACTION changeEditMethod; // Suite + static TOOL_ACTION openPreferences; static TOOL_ACTION configurePaths; static TOOL_ACTION showSymbolLibTable; static TOOL_ACTION showFootprintLibTable; diff --git a/include/tool/common_control.h b/include/tool/common_control.h index dc4181d34c..02341b93ed 100644 --- a/include/tool/common_control.h +++ b/include/tool/common_control.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -45,6 +45,7 @@ public: /// @copydoc TOOL_BASE::Reset() void Reset( RESET_REASON aReason ) override; + int OpenPreferences( const TOOL_EVENT& aEvent ); int ConfigurePaths( const TOOL_EVENT& aEvent ); int ShowLibraryTable( const TOOL_EVENT& aEvent ); diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index 2f78f6ea52..f9b5e98fde 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2009 Wayne Stambaugh - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2019 CERN * * This program is free software; you can redistribute it and/or @@ -163,10 +163,7 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showSymbolLibTable ); prefsMenu->Add( ACTIONS::showFootprintLibTable ); - prefsMenu->Add( _( "Preferences..." ) + "\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 79cf9d736b..f589fdaee7 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -151,10 +151,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() // ACTION_MENU* preferencesMenu = new ACTION_MENU( false, selTool ); - 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/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index f9825e77b5..1742ad0054 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -4,7 +4,7 @@ * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2015 Wayne Stambaugh - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -228,10 +228,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showFootprintLibTable ); - 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/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 255f01d9bc..a562ccfc00 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -449,10 +449,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() prefsMenu->Add( ACTIONS::configurePaths ); prefsMenu->Add( ACTIONS::showFootprintLibTable ); - 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/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index a81dddfdd8..dac6eed5f6 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -2817,8 +2817,7 @@ void APPEARANCE_CONTROLS::onReadOnlySwatch() button->Bind( wxEVT_COMMAND_HYPERLINK, std::function( [&]( wxHyperlinkEvent& aEvent ) { - wxCommandEvent dummy; - m_frame->OnPreferences( dummy ); + m_frame->OnPreferences(); } ) ); infobar->RemoveAllButtons();