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.
This commit is contained in:
Ian McInerney 2021-03-27 19:16:58 +00:00
parent 9535153f9e
commit 42c6af4bd8
9 changed files with 20 additions and 40 deletions

View File

@ -247,8 +247,7 @@ void CVPCB_MAINFRAME::setupTools()
// to be able to tell the difference between a menu click and a hotkey activation. // to be able to tell the difference between a menu click and a hotkey activation.
// Create the context menu for the component list box // Create the context menu for the component list box
m_componentContextMenu = new ACTION_MENU( false ); m_componentContextMenu = new ACTION_MENU( false, tool );
m_componentContextMenu->SetTool( tool );
m_componentContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer ); m_componentContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
m_componentContextMenu->AppendSeparator(); m_componentContextMenu->AppendSeparator();
m_componentContextMenu->Add( ACTIONS::cut ); m_componentContextMenu->Add( ACTIONS::cut );
@ -258,8 +257,7 @@ void CVPCB_MAINFRAME::setupTools()
m_componentContextMenu->Add( CVPCB_ACTIONS::deleteAssoc ); m_componentContextMenu->Add( CVPCB_ACTIONS::deleteAssoc );
// Create the context menu for the footprint list box // Create the context menu for the footprint list box
m_footprintContextMenu = new ACTION_MENU( false ); m_footprintContextMenu = new ACTION_MENU( false, tool );
m_footprintContextMenu->SetTool( tool );
m_footprintContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer ); m_footprintContextMenu->Add( CVPCB_ACTIONS::showFootprintViewer );
} }

View File

@ -60,8 +60,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// (the file history will be updated when adding/removing files in history) // (the file history will be updated when adding/removing files in history)
if( !openRecentMenu ) if( !openRecentMenu )
{ {
openRecentMenu = new ACTION_MENU( false ); openRecentMenu = new ACTION_MENU( false, selTool );
openRecentMenu->SetTool( selTool );
openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetTitle( _( "Open Recent" ) );
openRecentMenu->SetIcon( BITMAPS::recent ); openRecentMenu->SetIcon( BITMAPS::recent );
@ -94,8 +93,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
// Import submenu // Import submenu
ACTION_MENU* submenuImport = new ACTION_MENU( false ); ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
submenuImport->SetTool( selTool );
submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetTitle( _( "Import" ) );
submenuImport->SetIcon( BITMAPS::import ); submenuImport->SetIcon( BITMAPS::import );
submenuImport->Add( _( "Non-KiCad Schematic..." ), submenuImport->Add( _( "Non-KiCad Schematic..." ),
@ -108,8 +106,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar()
// Export submenu // Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU( false ); ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
submenuExport->SetTool( selTool );
submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( BITMAPS::export_file ); submenuExport->SetIcon( BITMAPS::export_file );
submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) ); submenuExport->Add( EE_ACTIONS::drawSheetOnClipboard, ACTION_MENU::NORMAL, _( "Drawing to Clipboard" ) );

View File

@ -65,8 +65,7 @@ void SYMBOL_EDIT_FRAME::ReCreateMenuBar()
fileMenu->Add( EE_ACTIONS::importSymbol ); fileMenu->Add( EE_ACTIONS::importSymbol );
// Export submenu // Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU( false ); ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
submenuExport->SetTool( selTool );
submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( BITMAPS::export_file ); submenuExport->SetIcon( BITMAPS::export_file );
submenuExport->Add( EE_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) ); submenuExport->Add( EE_ACTIONS::exportSymbol, ACTION_MENU::NORMAL, _( "Symbol..." ) );

View File

@ -141,8 +141,7 @@ private:
if( member->Type() == CONNECTION_TYPE::BUS ) if( member->Type() == CONNECTION_TYPE::BUS )
{ {
ACTION_MENU* submenu = new ACTION_MENU( true ); ACTION_MENU* submenu = new ACTION_MENU( true, m_tool );
submenu->SetTool( m_tool );
AppendSubMenu( submenu, SCH_CONNECTION::PrintBusForUI( name ), name ); AppendSubMenu( submenu, SCH_CONNECTION::PrintBusForUI( name ), name );
for( const std::shared_ptr<SCH_CONNECTION>& sub_member : member->Members() ) for( const std::shared_ptr<SCH_CONNECTION>& sub_member : member->Members() )

View File

@ -62,8 +62,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
// will automatically refresh the menu. // will automatically refresh the menu.
if( !openRecentGbrMenu ) if( !openRecentGbrMenu )
{ {
openRecentGbrMenu = new ACTION_MENU( false ); openRecentGbrMenu = new ACTION_MENU( false, selTool );
openRecentGbrMenu->SetTool( selTool );
openRecentGbrMenu->SetTitle( _( "Open Recent Gerber File" ) ); openRecentGbrMenu->SetTitle( _( "Open Recent Gerber File" ) );
openRecentGbrMenu->SetIcon( BITMAPS::recent ); openRecentGbrMenu->SetIcon( BITMAPS::recent );
@ -81,8 +80,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
// will automatically refresh the menu. // will automatically refresh the menu.
if( !openRecentDrlMenu ) if( !openRecentDrlMenu )
{ {
openRecentDrlMenu = new ACTION_MENU( false ); openRecentDrlMenu = new ACTION_MENU( false, selTool );
openRecentDrlMenu->SetTool( selTool );
openRecentDrlMenu->SetTitle( _( "Open Recent Drill File" ) ); openRecentDrlMenu->SetTitle( _( "Open Recent Drill File" ) );
openRecentDrlMenu->SetIcon( BITMAPS::recent ); openRecentDrlMenu->SetIcon( BITMAPS::recent );
@ -100,8 +98,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
// will automatically refresh the menu. // will automatically refresh the menu.
if( !openRecentJobMenu ) if( !openRecentJobMenu )
{ {
openRecentJobMenu = new ACTION_MENU( false ); openRecentJobMenu = new ACTION_MENU( false, selTool );
openRecentJobMenu->SetTool( selTool );
openRecentJobMenu->SetTitle( _( "Open Recent Job File" ) ); openRecentJobMenu->SetTitle( _( "Open Recent Job File" ) );
openRecentJobMenu->SetIcon( BITMAPS::recent ); openRecentJobMenu->SetIcon( BITMAPS::recent );
@ -119,8 +116,7 @@ void GERBVIEW_FRAME::ReCreateMenuBar()
// will automatically refresh the menu. // will automatically refresh the menu.
if( !openRecentZipMenu ) if( !openRecentZipMenu )
{ {
openRecentZipMenu = new ACTION_MENU( false ); openRecentZipMenu = new ACTION_MENU( false, selTool );
openRecentZipMenu->SetTool( selTool );
openRecentZipMenu->SetTitle( _( "Open Recent Zip File" ) ); openRecentZipMenu->SetTitle( _( "Open Recent Zip File" ) );
openRecentZipMenu->SetIcon( BITMAPS::recent ); openRecentZipMenu->SetIcon( BITMAPS::recent );

View File

@ -53,8 +53,7 @@ void PL_EDITOR_FRAME::ReCreateMenuBar()
// will automatically refresh the menu. // will automatically refresh the menu.
if( !openRecentMenu ) if( !openRecentMenu )
{ {
openRecentMenu = new ACTION_MENU( false ); openRecentMenu = new ACTION_MENU( false, selTool );
openRecentMenu->SetTool( selTool );
openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetTitle( _( "Open Recent" ) );
openRecentMenu->SetIcon( BITMAPS::recent ); openRecentMenu->SetIcon( BITMAPS::recent );

View File

@ -64,8 +64,7 @@ void FOOTPRINT_EDIT_FRAME::ReCreateMenuBar()
fileMenu->AppendSeparator(); fileMenu->AppendSeparator();
ACTION_MENU* submenuImport = new ACTION_MENU( false ); ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
submenuImport->SetTool( selTool );
submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetTitle( _( "Import" ) );
submenuImport->SetIcon( BITMAPS::import ); submenuImport->SetIcon( BITMAPS::import );

View File

@ -61,8 +61,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
// will automatically refresh the menu. // will automatically refresh the menu.
if( !openRecentMenu ) if( !openRecentMenu )
{ {
openRecentMenu = new ACTION_MENU( false ); openRecentMenu = new ACTION_MENU( false, selTool );
openRecentMenu->SetTool( selTool );
openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetTitle( _( "Open Recent" ) );
openRecentMenu->SetIcon( BITMAPS::recent ); openRecentMenu->SetIcon( BITMAPS::recent );
@ -102,8 +101,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
BITMAPS::rescue ); BITMAPS::rescue );
// Import submenu // Import submenu
ACTION_MENU* submenuImport = new ACTION_MENU( false ); ACTION_MENU* submenuImport = new ACTION_MENU( false, selTool );
submenuImport->SetTool( selTool );
submenuImport->SetTitle( _( "Import" ) ); submenuImport->SetTitle( _( "Import" ) );
submenuImport->SetIcon( BITMAPS::import ); submenuImport->SetIcon( BITMAPS::import );
@ -122,8 +120,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
fileMenu->Add( submenuImport ); fileMenu->Add( submenuImport );
// Export submenu // Export submenu
ACTION_MENU* submenuExport = new ACTION_MENU( false ); ACTION_MENU* submenuExport = new ACTION_MENU( false, selTool );
submenuExport->SetTool( selTool );
submenuExport->SetTitle( _( "Export" ) ); submenuExport->SetTitle( _( "Export" ) );
submenuExport->SetIcon( BITMAPS::export_file ); submenuExport->SetIcon( BITMAPS::export_file );
@ -158,8 +155,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
fileMenu->Add( submenuExport ); fileMenu->Add( submenuExport );
// Fabrication Outputs submenu // Fabrication Outputs submenu
ACTION_MENU* submenuFabOutputs = new ACTION_MENU( false ); ACTION_MENU* submenuFabOutputs = new ACTION_MENU( false, selTool );
submenuFabOutputs->SetTool( selTool );
submenuFabOutputs->SetTitle( _( "Fabrication Outputs" ) ); submenuFabOutputs->SetTitle( _( "Fabrication Outputs" ) );
submenuFabOutputs->SetIcon( BITMAPS::fabrication ); submenuFabOutputs->SetIcon( BITMAPS::fabrication );
@ -321,9 +317,8 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
placeMenu->AppendSeparator(); placeMenu->AppendSeparator();
ACTION_MENU* autoplaceSubmenu = new ACTION_MENU( false ); ACTION_MENU* autoplaceSubmenu = new ACTION_MENU( false, selTool );
autoplaceSubmenu->SetTitle( _( "Auto-Place Footprints" ) ); autoplaceSubmenu->SetTitle( _( "Auto-Place Footprints" ) );
autoplaceSubmenu->SetTool( selTool );
autoplaceSubmenu->SetIcon( BITMAPS::mode_module ); autoplaceSubmenu->SetIcon( BITMAPS::mode_module );
autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceOffboardComponents ); autoplaceSubmenu->Add( PCB_ACTIONS::autoplaceOffboardComponents );
@ -401,8 +396,7 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
#endif #endif
#if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU) #if defined(KICAD_SCRIPTING) && defined(KICAD_SCRIPTING_ACTION_MENU)
ACTION_MENU* submenuActionPlugins = new ACTION_MENU( false ); ACTION_MENU* submenuActionPlugins = new ACTION_MENU( false, selTool );
submenuActionPlugins->SetTool( selTool );
submenuActionPlugins->SetTitle( _( "External Plugins" ) ); submenuActionPlugins->SetTitle( _( "External Plugins" ) );
submenuActionPlugins->SetIcon( BITMAPS::puzzle_piece ); submenuActionPlugins->SetIcon( BITMAPS::puzzle_piece );

View File

@ -57,8 +57,7 @@ bool ALIGN_DISTRIBUTE_TOOL::Init()
m_frame = getEditFrame<PCB_BASE_FRAME>(); m_frame = getEditFrame<PCB_BASE_FRAME>();
// Create a context menu and make it available through selection tool // Create a context menu and make it available through selection tool
m_placementMenu = new ACTION_MENU( true ); m_placementMenu = new ACTION_MENU( true, this );
m_placementMenu->SetTool( this );
m_placementMenu->SetIcon( BITMAPS::align_items ); m_placementMenu->SetIcon( BITMAPS::align_items );
m_placementMenu->SetTitle( _( "Align/Distribute" ) ); m_placementMenu->SetTitle( _( "Align/Distribute" ) );