From fe53ec8c23ba972c3c0c0507cefd7a38125cad87 Mon Sep 17 00:00:00 2001 From: Chris Pavlina Date: Wed, 30 Mar 2016 14:51:47 -0400 Subject: [PATCH] hotkeys: add defaults command to right-click menu The new (eeschema, so far) hotkeys editor uses the right-click menu for the reset command, so the reset-to-default function that was added in 6652 (git:0cd7476) was not accessible from eeschema. --- common/widgets/widget_hotkey_list.cpp | 21 +++++++++++++++++++++ include/widgets/widget_hotkey_list.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp index d5c1517ed6..001fbb3aa8 100644 --- a/common/widgets/widget_hotkey_list.cpp +++ b/common/widgets/widget_hotkey_list.cpp @@ -52,7 +52,9 @@ enum ID_WHKL_MENU_IDS { ID_EDIT = 2001, ID_RESET, + ID_DEFAULT, ID_RESET_ALL, + ID_DEFAULT_ALL, }; @@ -359,6 +361,15 @@ void WIDGET_HOTKEY_LIST::ResetItem( wxTreeListItem aItem ) } +void WIDGET_HOTKEY_LIST::ResetItemToDefault( wxTreeListItem aItem ) +{ + WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( aItem ); + EDA_HOTKEY* hk = &hkdata->GetHotkey(); + hk->ResetKeyCodeToDefault(); + UpdateFromClientData(); +} + + void WIDGET_HOTKEY_LIST::OnActivated( wxTreeListEvent& aEvent ) { EditItem( aEvent.GetItem() ); @@ -374,8 +385,10 @@ void WIDGET_HOTKEY_LIST::OnContextMenu( wxTreeListEvent& aEvent ) menu.Append( ID_EDIT, _( "Edit..." ) ); menu.Append( ID_RESET, _( "Reset" ) ); + menu.Append( ID_DEFAULT, _( "Default" ) ); menu.Append( wxID_SEPARATOR ); menu.Append( ID_RESET_ALL, _( "Reset all" ) ); + menu.Append( ID_DEFAULT_ALL, _( "Reset all to default" ) ); PopupMenu( &menu ); } @@ -393,10 +406,18 @@ void WIDGET_HOTKEY_LIST::OnMenu( wxCommandEvent& aEvent ) ResetItem( m_context_menu_item ); break; + case ID_DEFAULT: + ResetItemToDefault( m_context_menu_item ); + break; + case ID_RESET_ALL: TransferDataToControl(); break; + case ID_DEFAULT_ALL: + TransferDefaultsToControl(); + break; + default: wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) ); } diff --git a/include/widgets/widget_hotkey_list.h b/include/widgets/widget_hotkey_list.h index 60e78fb77f..d34723fdc1 100644 --- a/include/widgets/widget_hotkey_list.h +++ b/include/widgets/widget_hotkey_list.h @@ -97,6 +97,12 @@ protected: */ void ResetItem( wxTreeListItem aItem ); + /** + * Method ResetItemToDefault + * Reset the item to the default value. + */ + void ResetItemToDefault( wxTreeListItem aItem ); + /** * Method OnActivated * Handle activation of a row.