7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 10:20:11 +00:00

Make sure standard OK/Cancel buttons respond to current language.

Fixes https://gitlab.com/kicad/code/kicad/issues/9635
This commit is contained in:
Jeff Young 2021-11-16 19:39:58 +00:00
parent 84a9732497
commit c3552a940a
102 changed files with 257 additions and 283 deletions
common
cvpcb/dialogs
eeschema/dialogs
include
kicad/pcm/dialogs
pcb_calculator/dialogs
pcbnew

View File

@ -637,3 +637,69 @@ void DIALOG_SHIM::OnGridEditorHidden( wxGridEvent& event )
SetEscapeId( wxID_ANY );
event.Skip();
}
static void recursiveDescent( wxSizer* aSizer, std::map<int, wxString>& aLabels )
{
wxStdDialogButtonSizer* sdbSizer = dynamic_cast<wxStdDialogButtonSizer*>( aSizer );
auto setupButton =
[&]( wxButton* aButton )
{
if( aLabels.count( aButton->GetId() ) > 0 )
{
aButton->SetLabel( aLabels[ aButton->GetId() ] );
}
else
{
// wxWidgets has an uneven track record when the language is changed on
// the fly so we set them even when they don't appear in the label map
switch( aButton->GetId() )
{
case wxID_OK: aButton->SetLabel( _( "&OK" ) ); break;
case wxID_CANCEL: aButton->SetLabel( _( "&Cancel" ) ); break;
case wxID_YES: aButton->SetLabel( _( "&Yes" ) ); break;
case wxID_NO: aButton->SetLabel( _( "&No" ) ); break;
case wxID_APPLY: aButton->SetLabel( _( "&Apply" ) ); break;
case wxID_SAVE: aButton->SetLabel( _( "&Save" ) ); break;
case wxID_HELP: aButton->SetLabel( _( "&Help" ) ); break;
case wxID_CONTEXT_HELP: aButton->SetLabel( _( "&Help" ) ); break;
}
}
};
if( sdbSizer )
{
if( sdbSizer->GetAffirmativeButton() )
setupButton( sdbSizer->GetAffirmativeButton() );
if( sdbSizer->GetApplyButton() )
setupButton( sdbSizer->GetApplyButton() );
if( sdbSizer->GetNegativeButton() )
setupButton( sdbSizer->GetNegativeButton() );
if( sdbSizer->GetCancelButton() )
setupButton( sdbSizer->GetCancelButton() );
if( sdbSizer->GetHelpButton() )
setupButton( sdbSizer->GetHelpButton() );
sdbSizer->Layout();
if( sdbSizer->GetAffirmativeButton() )
sdbSizer->GetAffirmativeButton()->SetDefault();
}
for( wxSizerItem* item : aSizer->GetChildren() )
{
if( item->GetSizer() )
recursiveDescent( item->GetSizer(), aLabels );
}
}
void DIALOG_SHIM::SetupStandardButtons( std::map<int, wxString> aLabels )
{
recursiveDescent( GetSizer(), aLabels );
}

View File

@ -93,7 +93,7 @@ DIALOG_COLOR_PICKER::DIALOG_COLOR_PICKER( wxWindow* aParent, const COLOR4D& aCur
if( aDefaultColor == COLOR4D::UNSPECIFIED )
m_resetToDefault->SetLabel( _( "Clear Color" ) );
m_sdbSizerOK->SetDefault();
SetupStandardButtons();
}

View File

@ -107,7 +107,7 @@ DIALOG_CONFIGURE_PATHS::DIALOG_CONFIGURE_PATHS( wxWindow* aParent, FILENAME_RESO
m_sb3DSearchPaths->Show( false );
SetInitialFocus( m_EnvVars );
m_sdbSizerOK->SetDefault();
SetupStandardButtons();
// wxFormBuilder doesn't include this event...
m_EnvVars->Connect( wxEVT_GRID_CELL_CHANGING,

View File

@ -55,7 +55,7 @@ void DIALOG_EDIT_LIBRARY_TABLES::InstallPanel( wxPanel* aPanel )
mainSizer->Add( sdbSizer, 0, wxALL|wxEXPAND, 5 );
sdbSizerOK->SetDefault();
SetupStandardButtons();
finishDialogSettings();

View File

@ -71,10 +71,7 @@ DIALOG_GLOBAL_LIB_TABLE_CONFIG::DIALOG_GLOBAL_LIB_TABLE_CONFIG( wxWindow* aParen
wxUpdateUIEventHandler( DIALOG_GLOBAL_LIB_TABLE_CONFIG::onUpdateFilePicker ),
nullptr, this );
wxButton* okButton = (wxButton *) FindWindowById( wxID_OK );
if( okButton )
okButton->SetDefault();
SetupStandardButtons();
finishDialogSettings();
}

View File

@ -59,7 +59,7 @@ DIALOG_GRID_SETTINGS::DIALOG_GRID_SETTINGS( EDA_DRAW_FRAME* aParent ):
m_book->SetSelection( 0 );
}
m_sdbSizerOK->SetDefault(); // set OK button as default response to 'Enter' key
SetupStandardButtons();
SetInitialFocus( m_GridOriginXCtrl );
Layout();

View File

@ -39,8 +39,9 @@ DIALOG_IMAGE_EDITOR::DIALOG_IMAGE_EDITOR( wxWindow* aParent, BITMAP_BASE* aItem
msg.Printf( wxT( "%f" ), m_workingImage->GetScale() );
m_textCtrlScale->SetValue( msg );
SetupStandardButtons();
finishDialogSettings();
m_sdbSizerOK->SetDefault();
}

View File

@ -32,11 +32,11 @@ DIALOG_LOCKED_ITEMS_QUERY::DIALOG_LOCKED_ITEMS_QUERY( wxWindow* aParent, int aLo
m_messageLine1->SetLabel( wxString::Format( m_messageLine1->GetLabel(), aLockedItemCount ) );
m_sdbSizerOK->SetLabel( _( "Skip Locked Items" ) );
SetupStandardButtons( { { wxID_OK, _( "Skip Locked Items" ) } } );
m_sdbSizerOK->SetToolTip( _( "Remove locked items from the selection and only apply the "
"operation to the unlocked items (if any)." ) );
m_sdbSizerOK->SetDefault();
m_sdbSizerOK->SetFocus();
SetInitialFocus( m_sdbSizerOK );
Layout();

View File

@ -35,7 +35,8 @@ DIALOG_MIGRATE_SETTINGS::DIALOG_MIGRATE_SETTINGS( SETTINGS_MANAGER* aManager ) :
// Disabled for now. See https://gitlab.com/kicad/code/kicad/-/issues/9826
m_cbCopyLibraryTables->Hide();
m_standardButtonsOK->SetDefault();
SetupStandardButtons();
GetSizer()->SetSizeHints( this );
Centre();
}

View File

@ -111,6 +111,8 @@ DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* aParent, double aI
m_staticTextTitleBlock->SetLabel( _( "Title Block" ) );
}
SetupStandardButtons();
Centre();
}
@ -197,8 +199,6 @@ bool DIALOG_PAGES_SETTINGS::TransferDataToWindow()
GetSizer()->SetSizeHints( this );
// Make the OK button the default.
m_sdbSizerOK->SetDefault();
m_initialized = true;
return true;

View File

@ -42,14 +42,9 @@ DIALOG_PRINT_GENERIC::DIALOG_PRINT_GENERIC( EDA_DRAW_FRAME* aParent, PRINTOUT_SE
m_scaleValidator.SetRange( 0.0, MAX_SCALE );
m_scaleCustomText->SetValidator( m_scaleValidator );
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
// that requires us to correct the button labels here.
m_sdbSizer1OK->SetLabel( _( "Print" ) );
m_sdbSizer1Apply->SetLabel( _( "Print Preview" ) );
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
m_sdbSizer1->Layout();
m_sdbSizer1OK->SetDefault();
SetupStandardButtons( { { wxID_OK, _( "Print" ) },
{ wxID_APPLY, _( "Print Preview" ) },
{ wxID_CANCEL, _( "Close" ) } } );
#if defined(__WXMAC__) or defined(__WXGTK__)
// Preview does not work well on GTK or Mac,

View File

@ -33,8 +33,9 @@ WX_TEXT_ENTRY_DIALOG::WX_TEXT_ENTRY_DIALOG( wxWindow* aParent,
m_label->SetLabel( aFieldLabel );
m_textCtrl->SetValue( aDefaultValue );
SetupStandardButtons();
SetInitialFocus( m_textCtrl );
m_sdbSizer1OK->SetDefault();
}

View File

@ -34,7 +34,8 @@ WX_UNIT_ENTRY_DIALOG::WX_UNIT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxStr
{
m_label->SetLabel( aLabel );
m_unit_binder.SetValue( aDefaultValue );
m_sdbSizer1OK->SetDefault();
SetupStandardButtons();
}

View File

@ -54,7 +54,7 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( wxWindow* aParent, const wxString& aTitle,
// columns, different column names, and column widths.
m_hash_key = TO_UTF8( aTitle );
m_sdbSizerOK->SetDefault();
SetupStandardButtons();
// this line fixes an issue on Linux Ubuntu using Unity (dialog not shown),
// and works fine on all systems

View File

@ -42,7 +42,7 @@ HTML_MESSAGE_BOX::HTML_MESSAGE_BOX( wxWindow* aParent, const wxString& aTitle,
Center();
m_sdbSizer1OK->SetDefault();
SetupStandardButtons();
reload();

View File

@ -91,7 +91,7 @@ PAGED_DIALOG::PAGED_DIALOG( wxWindow* aParent, const wxString& aTitle, bool aSho
m_buttonsSizer->Add( sdbSizer, 1, 0, 5 );
mainSizer->Add( m_buttonsSizer, 0, wxALL|wxEXPAND, 5 );
sdbSizerOK->SetDefault();
SetupStandardButtons();
// We normally save the dialog size and position based on its class-name. This class
// substitutes the title so that each distinctly-titled dialog can have its own saved

View File

@ -25,8 +25,8 @@
#include <wx/dcclient.h>
#include <wx/settings.h>
WX_PANEL::WX_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style, const wxString& name ) :
WX_PANEL::WX_PANEL( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
wxPanel( parent, id, pos, size, style, name ),
m_leftBorder( false ),
m_rightBorder( false ),

View File

@ -52,6 +52,8 @@ DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* aParent ) :
Init( );
SetupStandardButtons();
GetSizer()->SetSizeHints( this );
Center();
}
@ -59,7 +61,6 @@ DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES( CVPCB_MAINFRAME* aParent ) :
void DIALOG_CONFIG_EQUFILES::Init()
{
m_sdbSizerOK->SetDefault();
m_ListChanged = false;
PROJECT_FILE& project = Prj().GetProjectFile();
@ -90,7 +91,6 @@ void DIALOG_CONFIG_EQUFILES::Init()
}
m_gridEnvVars->AutoSizeColumns();
}

View File

@ -87,13 +87,8 @@ DIALOG_ANNOTATE::DIALOG_ANNOTATE( SCH_EDIT_FRAME* parent, const wxString& messag
m_MessageWindow->SetLabel( _( "Annotation Messages:" ) );
m_MessageWindow->SetFileName( Prj().GetProjectPath() + wxT( "report.txt" ) );
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
// that requires us to correct the button labels here.
m_sdbSizer1OK->SetLabel( _( "Annotate" ) );
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
m_sdbSizer1->Layout();
m_sdbSizer1OK->SetDefault();
SetupStandardButtons( { { wxID_OK, _( "Annotate" ) },
{ wxID_CANCEL, _( "Close" ) } } );
InitValues();
Layout();
@ -215,6 +210,7 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event )
m_Parent->GetCanvas()->Refresh();
m_btnClear->Enable();
m_sdbSizer1Cancel->SetDefault();
// Don't close dialog if there are things the user needs to address

View File

@ -130,12 +130,10 @@ DIALOG_BOM::DIALOG_BOM( SCH_EDIT_FRAME* parent ) :
m_checkBoxShowConsole->Show( false );
#endif
m_sdbSizerOK->SetLabel( _( "Generate" ) );
m_sdbSizerCancel->SetLabel( _( "Close" ) );
m_sdbSizer->Layout();
SetupStandardButtons( { { wxID_OK, _( "Generate" ) },
{ wxID_CANCEL, _( "Close" ) } } );
SetInitialFocus( m_lbGenerators );
m_sdbSizerOK->SetDefault();
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();

View File

@ -180,8 +180,9 @@ DIALOG_BUS_MANAGER::DIALOG_BUS_MANAGER( SCH_EDIT_FRAME* aParent )
m_bus_edit->SetHint( _( "Bus Alias Name" ) );
m_signal_edit->SetHint( _( "Net or Bus Name" ) );
SetupStandardButtons();
finishDialogSettings();
okButton->SetDefault();
}

View File

@ -151,16 +151,10 @@ DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_SYMBO
// because the update and change versions of this dialog have different controls.
m_hash_key = TO_UTF8( GetTitle() );
// Ensure m_closeButton (with id = wxID_CANCEL) has the right label
// (to fix automatic renaming of button label )
m_sdbSizerCancel->SetLabel( _( "Close" ) );
wxString okLabel = m_mode == MODE::CHANGE ? _( "Change" ) : _( "Update" );
if( m_mode == MODE::CHANGE )
m_sdbSizerOK->SetLabel( _( "Change" ) );
else
m_sdbSizerOK->SetLabel( _( "Update" ) );
m_sdbSizerOK->SetDefault();
SetupStandardButtons( { { wxID_OK, okLabel },
{ wxID_CANCEL, _( "Close" ) } } );
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();

View File

@ -197,7 +197,7 @@ DIALOG_CHOOSE_SYMBOL::DIALOG_CHOOSE_SYMBOL( SCH_BASE_FRAME* aParent, const wxStr
}
SetInitialFocus( m_tree->GetFocusTarget() );
okButton->SetDefault();
SetupStandardButtons();
Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_SYMBOL::OnInitDialog, this );
Bind( wxEVT_TIMER, &DIALOG_CHOOSE_SYMBOL::OnCloseTimer, this, m_dbl_click_timer->GetId() );

View File

@ -73,13 +73,8 @@ DIALOG_ERC::DIALOG_ERC( SCH_EDIT_FRAME* parent ) :
syncCheckboxes();
updateDisplayedCounts();
// We use a sdbSizer to get platform-dependent ordering of the action buttons, but
// that requires us to correct the button labels here.
m_sdbSizer1OK->SetLabel( _( "Run ERC" ) );
m_sdbSizer1Cancel->SetLabel( _( "Close" ) );
m_sdbSizer1->Layout();
m_sdbSizer1OK->SetDefault();
SetupStandardButtons( { { wxID_OK, _( "Run ERC" ) },
{ wxID_CANCEL, _( "Close" ) } } );
m_errorsBadge->SetMaximumNumber( 999 );
m_warningsBadge->SetMaximumNumber( 999 );

View File

@ -183,8 +183,6 @@ void DIALOG_FIELD_PROPERTIES::init()
m_TextCtrl->Enable( true );
}
m_sdbSizerButtonsOK->SetDefault();
GetSizer()->SetSizeHints( this );
// Adjust the height of the scintilla text editor after the first layout
@ -200,6 +198,8 @@ void DIALOG_FIELD_PROPERTIES::init()
m_StyledTextCtrl->SetUseHorizontalScrollBar( false );
}
SetupStandardButtons();
// Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings();
}

Some files were not shown because too many files have changed in this diff Show More