Clean strings before displaying in hotkeys list.

Also make sure the description column is wide enough.

Fixes https://gitlab.com/kicad/code/kicad/issues/11994
This commit is contained in:
Jeff Young 2022-07-26 23:38:40 +01:00
parent 2c30a04efc
commit d9d579c895
1 changed files with 18 additions and 6 deletions

View File

@ -296,10 +296,15 @@ void WIDGET_HOTKEY_LIST::updateFromClientData()
if( label.IsEmpty() )
label = changed_hk.m_Actions[ 0 ]->GetName();
label.Replace( wxT( "..." ), wxEmptyString );
// mark unsaved changes
if( changed_hk.m_EditKeycode != changed_hk.m_Actions[ 0 ]->GetHotKey() )
label += " *";
description.Replace( wxS( "\n" ), wxS( " " ) );
description.Replace( wxS( "\r" ), wxS( " " ) );
SetItemText( i, 0, label );
SetItemText( i, 1, key_text);
SetItemText( i, 2, description );
@ -477,14 +482,15 @@ WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkey
wxString longKey = wxT( "Ctrl+Alt+Shift+X" );
int pad = 20;
dv->GetColumn( 0 )->SetMinWidth( dv->GetMainWindow()->GetTextExtent( command_header ).x + pad );
dv->GetColumn( 1 )->SetMinWidth( dv->GetMainWindow()->GetTextExtent( longKey ).x + pad );
dv->GetColumn( 0 )->SetMinWidth( aParent->GetTextExtent( command_header ).x * 2 + pad );
dv->GetColumn( 1 )->SetMinWidth( aParent->GetTextExtent( longKey ).x + pad );
dv->GetColumn( 2 )->SetMinWidth( aParent->GetTextExtent( command_header ).x * 5 + pad );
CallAfter( [&]()
{
GetDataView()->Update();
} );
#endif
#endif
std::vector<wxString> reserved_keys =
{
@ -492,16 +498,14 @@ WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkey
"Ctrl+Shift+Tab"
};
for( auto& key : reserved_keys )
for( const wxString& key : reserved_keys )
{
long code = KeyCodeFromKeyName( key );
if( code )
m_reservedHotkeys[code] = key;
else
{
wxLogWarning( "Unknown reserved keycode %s\n", key );
}
}
GetDataView()->SetIndent( 10 );
@ -564,6 +568,14 @@ void WIDGET_HOTKEY_LIST::updateColumnWidths()
col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
col->SetWidth( col->GetWidth() );
#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 1, 0 )
col->SetResizeable( true );
#endif
col = GetDataView()->GetColumn( 2 );
col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
col->SetWidth( col->GetWidth() );
#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 1, 0 )
col->SetResizeable( true );
#endif