Ensure "Open Recent" and "Clear files" menu titles are updated after language change.

This commit is contained in:
jean-pierre charras 2022-04-11 09:11:26 +02:00
parent 403992a6f4
commit ac8e2d0768
7 changed files with 55 additions and 13 deletions

View File

@ -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 )

View File

@ -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 );

View File

@ -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 ) );

View File

@ -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.
*/

View File

@ -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 );

View File

@ -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 );

View File

@ -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 );