From 42c6af4bd81a25c313e7aba65209c8d11ff3dffa Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sat, 27 Mar 2021 19:16:58 +0000 Subject: [PATCH] Cleanup ACTION_MENU creation in some places The ACTION_MENU constructor now takes the tool as an argument, so the call to SetTool() immediately following it can be removed and the tool just passed into the constructor. --- cvpcb/cvpcb_mainframe.cpp | 6 ++---- eeschema/menubar.cpp | 9 +++------ .../symbol_editor/menubar_symbol_editor.cpp | 3 +-- eeschema/tools/sch_line_wire_bus_tool.cpp | 3 +-- gerbview/menubar.cpp | 12 ++++-------- pagelayout_editor/menubar.cpp | 3 +-- pcbnew/menubar_footprint_editor.cpp | 3 +-- pcbnew/menubar_pcb_editor.cpp | 18 ++++++------------ pcbnew/tools/placement_tool.cpp | 3 +-- 9 files changed, 20 insertions(+), 40 deletions(-) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 3006e297b8..dd7dca17d0 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -247,8 +247,7 @@ void CVPCB_MAINFRAME::setupTools() // to be able to tell the difference between a menu click and a hotkey activation. // Create the context menu for the component list box - m_componentContextMenu = new ACTION_MENU( false ); - m_componentContextMenu->SetTool( tool ); + m_componentContextMenu = new ACTION_MENU( false, tool ); m_componentContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer ); m_componentContextMenu->AppendSeparator(); m_componentContextMenu->Add( ACTIONS::cut ); @@ -258,8 +257,7 @@ void CVPCB_MAINFRAME::setupTools() m_componentContextMenu->Add( CVPCB_ACTIONS::deleteAssoc ); // Create the context menu for the footprint list box - m_footprintContextMenu = new ACTION_MENU( false ); - m_footprintContextMenu->SetTool( tool ); + m_footprintContextMenu = new ACTION_MENU( false, tool ); m_footprintContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer ); } diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 8c47be04f0..409eeaa442 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -60,8 +60,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() // (the file history will be updated when adding/removing files in history) if( !openRecentMenu ) { - openRecentMenu = new ACTION_MENU( false ); - openRecentMenu->SetTool( selTool ); + openRecentMenu = new ACTION_MENU( false, selTool ); openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetIcon( BITMAPS::recent ); @@ -94,8 +93,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() fileMenu->AppendSeparator(); // Import submenu - ACTION_MENU* submenuImport = new ACTION_MENU( false ); - submenuImport->SetTool( selTool ); + ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool ); submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetIcon( BITMAPS::import ); submenuImport->Add( _( "Non-KiCad Schematic..." ), @@ -108,8 +106,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() // Export submenu - ACTION_MENU* submenuExport = new ACTION_MENU( false ); - submenuExport->SetTool( selTool ); + ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool ); submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetIcon( BITMAPS::export_file ); submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) ); diff --git a/eeschema/symbol_editor/menubar_symbol_editor.cpp b/eeschema/symbol_editor/menubar_symbol_editor.cpp index eecab692a2..4ace1da38e 100644 --- a/eeschema/symbol_editor/menubar_symbol_editor.cpp +++ b/eeschema/symbol_editor/menubar_symbol_editor.cpp @@ -65,8 +65,7 @@ void SYMBOL_EDIT_FRAME::ReCreateMenuBar() fileMenu->Add( EE_ACTIONS::importSymbol ); // Export submenu - ACTION_MENU* submenuExport = new ACTION_MENU( false ); - submenuExport->SetTool( selTool ); + ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool ); submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetIcon( BITMAPS::export_file ); submenuExport->Add( EE_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) ); diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index d38fef70f3..a72050fc70 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -141,8 +141,7 @@ private: if( member->Type() == CONNECTION_TYPE::BUS ) { - ACTION_MENU* submenu = new ACTION_MENU( true ); - submenu->SetTool( m_tool ); + ACTION_MENU* submenu = new ACTION_MENU( true, m_tool ); AppendSubMenu( submenu, SCH_CONNECTION::PrintBusForUI( name ), name ); for( const std::shared_ptr& sub_member : member->Members() ) diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index 1a086e9231..447e994e85 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -62,8 +62,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // will automatically refresh the menu. if( !openRecentGbrMenu ) { - openRecentGbrMenu = new ACTION_MENU( false ); - openRecentGbrMenu->SetTool( selTool ); + openRecentGbrMenu = new ACTION_MENU( false, selTool ); openRecentGbrMenu->SetTitle( _( "Open Recent Gerber File" ) ); openRecentGbrMenu->SetIcon( BITMAPS::recent ); @@ -81,8 +80,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // will automatically refresh the menu. if( !openRecentDrlMenu ) { - openRecentDrlMenu = new ACTION_MENU( false ); - openRecentDrlMenu->SetTool( selTool ); + openRecentDrlMenu = new ACTION_MENU( false, selTool ); openRecentDrlMenu->SetTitle( _( "Open Recent Drill File" ) ); openRecentDrlMenu->SetIcon( BITMAPS::recent ); @@ -100,8 +98,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // will automatically refresh the menu. if( !openRecentJobMenu ) { - openRecentJobMenu = new ACTION_MENU( false ); - openRecentJobMenu->SetTool( selTool ); + openRecentJobMenu = new ACTION_MENU( false, selTool ); openRecentJobMenu->SetTitle( _( "Open Recent Job File" ) ); openRecentJobMenu->SetIcon( BITMAPS::recent ); @@ -119,8 +116,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar() // will automatically refresh the menu. if( !openRecentZipMenu ) { - openRecentZipMenu = new ACTION_MENU( false ); - openRecentZipMenu->SetTool( selTool ); + openRecentZipMenu = new ACTION_MENU( false, selTool ); openRecentZipMenu->SetTitle( _( "Open Recent Zip File" ) ); openRecentZipMenu->SetIcon( BITMAPS::recent ); diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index 2716d675a6..79cf9d736b 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -53,8 +53,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() // will automatically refresh the menu. if( !openRecentMenu ) { - openRecentMenu = new ACTION_MENU( false ); - openRecentMenu->SetTool( selTool ); + openRecentMenu = new ACTION_MENU( false, selTool ); openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetIcon( BITMAPS::recent ); diff --git a/pcbnew/menubar_footprint_editor.cpp b/pcbnew/menubar_footprint_editor.cpp index e53cf7d12d..cc1ff72c29 100644 --- a/pcbnew/menubar_footprint_editor.cpp +++ b/pcbnew/menubar_footprint_editor.cpp @@ -64,8 +64,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar() fileMenu->AppendSeparator(); - ACTION_MENU* submenuImport = new ACTION_MENU( false ); - submenuImport->SetTool( selTool ); + ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool ); submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetIcon( BITMAPS::import ); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index 8ecaf36567..785a935026 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -61,8 +61,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() // will automatically refresh the menu. if( !openRecentMenu ) { - openRecentMenu = new ACTION_MENU( false ); - openRecentMenu->SetTool( selTool ); + openRecentMenu = new ACTION_MENU( false, selTool ); openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetIcon( BITMAPS::recent ); @@ -102,8 +101,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() BITMAPS::rescue ); // Import submenu - ACTION_MENU* submenuImport = new ACTION_MENU( false ); - submenuImport->SetTool( selTool ); + ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool ); submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetIcon( BITMAPS::import ); @@ -122,8 +120,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() fileMenu->Add( submenuImport ); // Export submenu - ACTION_MENU* submenuExport = new ACTION_MENU( false ); - submenuExport->SetTool( selTool ); + ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool ); submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetIcon( BITMAPS::export_file ); @@ -158,8 +155,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() fileMenu->Add( submenuExport ); // Fabrication Outputs submenu - ACTION_MENU* submenuFabOutputs = new ACTION_MENU( false ); - submenuFabOutputs->SetTool( selTool ); + ACTION_MENU* submenuFabOutputs = new ACTION_MENU( false, selTool ); submenuFabOutputs->SetTitle( _( "Fabrication Outputs" ) ); submenuFabOutputs->SetIcon( BITMAPS::fabrication ); @@ -321,9 +317,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() placeMenu->AppendSeparator(); - ACTION_MENU* autoplaceSubmenu = new ACTION_MENU( false ); + ACTION_MENU* autoplaceSubmenu = new ACTION_MENU( false, selTool ); autoplaceSubmenu->SetTitle( _( "Auto-Place Footprints" ) ); - autoplaceSubmenu->SetTool( selTool ); autoplaceSubmenu->SetIcon( BITMAPS::mode_module ); autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceOffboardComponents ); @@ -401,8 +396,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() #endif #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) - ACTION_MENU* submenuActionPlugins = new ACTION_MENU( false ); - submenuActionPlugins->SetTool( selTool ); + ACTION_MENU* submenuActionPlugins = new ACTION_MENU( false, selTool ); submenuActionPlugins->SetTitle( _( "External Plugins" ) ); submenuActionPlugins->SetIcon( BITMAPS::puzzle_piece ); diff --git a/pcbnew/tools/placement_tool.cpp b/pcbnew/tools/placement_tool.cpp index 764284b51f..63a3de7f97 100644 --- a/pcbnew/tools/placement_tool.cpp +++ b/pcbnew/tools/placement_tool.cpp @@ -57,8 +57,7 @@ bool ALIGN_DISTRIBUTE_TOOL::Init() m_frame = getEditFrame(); // Create a context menu and make it available through selection tool - m_placementMenu = new ACTION_MENU( true ); - m_placementMenu->SetTool( this ); + m_placementMenu = new ACTION_MENU( true, this ); m_placementMenu->SetIcon( BITMAPS::align_items ); m_placementMenu->SetTitle( _( "Align/Distribute" ) );