From d9d579c89522728c7b072251d1fe5c5ede837b22 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 26 Jul 2022 23:38:40 +0100 Subject: [PATCH] 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 --- common/widgets/widget_hotkey_list.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index 030f72e862..c956498482 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -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 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