diff --git a/common/filehistory.cpp b/common/filehistory.cpp index 09f6cb9349..532160d0b3 100644 --- a/common/filehistory.cpp +++ b/common/filehistory.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 Ian McInerney <Ian.S.McInerney@ieee.org> - * Copyright (C) 2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2022 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 @@ -165,6 +165,18 @@ void FILE_HISTORY::doAddClearItem( wxMenu* aMenu ) } +void FILE_HISTORY::UpdateClearText( wxMenu* aMenu, wxString aClearText ) +{ + size_t itemPos; + wxMenuItem* clearItem = aMenu->FindChildItem( m_clearId, &itemPos ); + + if( clearItem && itemPos > 1 ) // clearItem is the last menu, after a separator + { + clearItem->SetItemLabel( aClearText ); + } +} + + void FILE_HISTORY::ClearFileHistory() { while( GetCount() > 0 ) diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index a9118c146a..84e44a421d 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -62,13 +62,15 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() if( !openRecentMenu ) { openRecentMenu = new ACTION_MENU( false, selTool ); - openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetIcon( BITMAPS::recent ); fileHistory.UseMenu( openRecentMenu ); fileHistory.AddFilesToMenu( openRecentMenu ); } + // Ensure the title is up to date after changing language + openRecentMenu->SetTitle( _( "Open Recent" ) ); + fileMenu->Add( ACTIONS::doNew ); fileMenu->Add( ACTIONS::open ); diff --git a/gerbview/menubar.cpp b/gerbview/menubar.cpp index a6e08451b9..7af26ef4a9 100644 --- a/gerbview/menubar.cpp +++ b/gerbview/menubar.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2009 Wayne Stambaugh <stambaughw@gmail.com> - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2022 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 @@ -64,14 +64,17 @@ void GERBVIEW_FRAME::ReCreateMenuBar() if( !openRecentGbrMenu ) { openRecentGbrMenu = new ACTION_MENU( false, selTool ); - openRecentGbrMenu->SetTitle( _( "Open Recent Gerber File" ) ); openRecentGbrMenu->SetIcon( BITMAPS::recent ); - recentGbrFiles.UseMenu( openRecentGbrMenu ); recentGbrFiles.SetClearText( _( "Clear Recent Gerber Files" ) ); + recentGbrFiles.UseMenu( openRecentGbrMenu ); recentGbrFiles.AddFilesToMenu(); } + // Ensure the title is up to date after changing language + openRecentGbrMenu->SetTitle( _( "Open Recent Gerber File" ) ); + recentGbrFiles.UpdateClearText( openRecentGbrMenu, _( "Clear Recent Gerber Files" ) ); + fileMenu->Add( GERBVIEW_ACTIONS::openAutodetected ); fileMenu->Add( GERBVIEW_ACTIONS::openGerber ); wxMenuItem* gbrItem = fileMenu->Add( openRecentGbrMenu->Clone() ); @@ -91,6 +94,10 @@ void GERBVIEW_FRAME::ReCreateMenuBar() m_drillFileHistory.AddFilesToMenu(); } + // Ensure the title is up to date after changing language + openRecentGbrMenu->SetTitle( _( "Open Recent Gerber File" ) ); + m_drillFileHistory.UpdateClearText( openRecentDrlMenu, _( "Clear Recent Drill Files" ) ); + fileMenu->Add( GERBVIEW_ACTIONS::openDrillFile ); wxMenuItem* drillItem = fileMenu->Add( openRecentDrlMenu->Clone() ); RegisterUIUpdateHandler( drillItem->GetId(), FileHistoryCond( m_drillFileHistory ) ); @@ -101,14 +108,17 @@ void GERBVIEW_FRAME::ReCreateMenuBar() if( !openRecentJobMenu ) { openRecentJobMenu = new ACTION_MENU( false, selTool ); - openRecentJobMenu->SetTitle( _( "Open Recent Job File" ) ); openRecentJobMenu->SetIcon( BITMAPS::recent ); - m_jobFileHistory.UseMenu( openRecentJobMenu ); m_jobFileHistory.SetClearText( _( "Clear Recent Job Files" ) ); + m_jobFileHistory.UseMenu( openRecentJobMenu ); m_jobFileHistory.AddFilesToMenu(); } + // Ensure the title is up to date after changing language + openRecentJobMenu->SetTitle( _( "Open Recent Job File" ) ); + m_jobFileHistory.UpdateClearText( openRecentJobMenu, _( "Clear Recent Job Files" ) ); + fileMenu->Add( GERBVIEW_ACTIONS::openJobFile ); wxMenuItem* jobItem = fileMenu->Add( openRecentJobMenu->Clone() ); RegisterUIUpdateHandler( jobItem->GetId(), FileHistoryCond( m_jobFileHistory ) ); @@ -119,7 +129,6 @@ void GERBVIEW_FRAME::ReCreateMenuBar() if( !openRecentZipMenu ) { openRecentZipMenu = new ACTION_MENU( false, selTool ); - openRecentZipMenu->SetTitle( _( "Open Recent Zip File" ) ); openRecentZipMenu->SetIcon( BITMAPS::recent ); m_zipFileHistory.UseMenu( openRecentZipMenu ); @@ -127,6 +136,10 @@ void GERBVIEW_FRAME::ReCreateMenuBar() m_zipFileHistory.AddFilesToMenu(); } + // Ensure the title is up to date after changing language + openRecentZipMenu->SetTitle( _( "Open Recent Zip File" ) ); + m_zipFileHistory.UpdateClearText( openRecentZipMenu, _( "Clear Recent Zip Files" ) ); + fileMenu->Add( GERBVIEW_ACTIONS::openZipFile ); wxMenuItem* zipItem = fileMenu->Add( openRecentZipMenu->Clone() ); RegisterUIUpdateHandler( zipItem->GetId(), FileHistoryCond( m_zipFileHistory ) ); diff --git a/include/filehistory.h b/include/filehistory.h index 6c95b3b0c8..6ed4657c22 100644 --- a/include/filehistory.h +++ b/include/filehistory.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 Ian McInerney <Ian.S.McInerney@ieee.org> - * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2022 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 @@ -104,7 +104,7 @@ public: /** * Add the files to the specified menu * - * @aMenu is the menu to operate on. + * @param aMenu is the menu to operate on. */ void AddFilesToMenu( wxMenu* aMenu ) override; @@ -125,6 +125,15 @@ public: m_clearText = aClearText; } + /** + * Update the text displayed on the menu item that clears the entire menu. + * useful after language change. + * + * @param aMenu is the menu to operate on. + * @param aClearText is the new text to use for the menu item + */ + void UpdateClearText( wxMenu* aMenu, wxString aClearText ); + /** * Clear all entries from the file history. */ diff --git a/kicad/menubar.cpp b/kicad/menubar.cpp index cb20905dbe..a74615170f 100644 --- a/kicad/menubar.cpp +++ b/kicad/menubar.cpp @@ -62,13 +62,15 @@ void KICAD_MANAGER_FRAME::ReCreateMenuBar() if( !openRecentMenu ) { openRecentMenu = new ACTION_MENU( false, controlTool ); - openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetIcon( BITMAPS::recent ); fileHistory.UseMenu( openRecentMenu ); fileHistory.AddFilesToMenu(); } + // Ensure the title is up to date after changing language + openRecentMenu->SetTitle( _( "Open Recent" ) ); + fileMenu->Add( KICAD_MANAGER_ACTIONS::newProject ); fileMenu->Add( KICAD_MANAGER_ACTIONS::newFromTemplate ); diff --git a/pagelayout_editor/menubar.cpp b/pagelayout_editor/menubar.cpp index 80b7f5239d..8f3728fa54 100644 --- a/pagelayout_editor/menubar.cpp +++ b/pagelayout_editor/menubar.cpp @@ -54,13 +54,15 @@ void PL_EDITOR_FRAME::ReCreateMenuBar() if( !openRecentMenu ) { openRecentMenu = new ACTION_MENU( false, selTool ); - openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetIcon( BITMAPS::recent ); recentFiles.UseMenu( openRecentMenu ); recentFiles.AddFilesToMenu(); } + // Ensure the title is up to date after changing language + openRecentMenu->SetTitle( _( "Open Recent" ) ); + //-- File menu ------------------------------------------------------- // ACTION_MENU* fileMenu = new ACTION_MENU( false, selTool ); diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index bc2cb2f3d4..5653cff183 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -64,13 +64,15 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() if( !openRecentMenu ) { openRecentMenu = new ACTION_MENU( false, selTool ); - openRecentMenu->SetTitle( _( "Open Recent" ) ); openRecentMenu->SetIcon( BITMAPS::recent ); fileHistory.UseMenu( openRecentMenu ); fileHistory.AddFilesToMenu(); } + // Ensure the title is up to date after changing language + openRecentMenu->SetTitle( _( "Open Recent" ) ); + fileMenu->Add( ACTIONS::doNew ); fileMenu->Add( ACTIONS::open );