kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #23892
[PATCH 3/3] Action for "Defaults" button in "Hotkey Editor" dialog (lp:1395442)
---
common/dialogs/dialog_hotkeys_editor.cpp | 1 +
common/widgets/widget_hotkey_list.cpp | 20 ++++++++++++++++++++
include/widgets/widget_hotkey_list.h | 7 +++++++
3 files changed, 28 insertions(+)
diff --git a/common/dialogs/dialog_hotkeys_editor.cpp b/common/dialogs/dialog_hotkeys_editor.cpp
index 2df6496..eed8f1a 100644
--- a/common/dialogs/dialog_hotkeys_editor.cpp
+++ b/common/dialogs/dialog_hotkeys_editor.cpp
@@ -87,4 +87,5 @@ void HOTKEYS_EDITOR_DIALOG::ResetClicked( wxCommandEvent& aEvent )
void HOTKEYS_EDITOR_DIALOG::DefaultsClicked( wxCommandEvent& aEvent )
{
+ m_hotkeyListCtrl->TransferDefaultsToControl();
}
diff --git a/common/widgets/widget_hotkey_list.cpp b/common/widgets/widget_hotkey_list.cpp
index ebab4f5..d5c1517 100644
--- a/common/widgets/widget_hotkey_list.cpp
+++ b/common/widgets/widget_hotkey_list.cpp
@@ -575,6 +575,26 @@ void WIDGET_HOTKEY_LIST::InstallOnPanel( wxPanel* aPanel )
}
+bool WIDGET_HOTKEY_LIST::TransferDefaultsToControl()
+{
+ Freeze();
+
+ for( wxTreeListItem item = GetFirstItem(); item.IsOk(); item = GetNextItem( item ) )
+ {
+ WIDGET_HOTKEY_CLIENT_DATA* hkdata = GetHKClientData( item );
+ if( hkdata == NULL)
+ continue;
+
+ hkdata->GetHotkey().ResetKeyCodeToDefault();
+ }
+
+ UpdateFromClientData();
+ Thaw();
+
+ return true;
+}
+
+
bool WIDGET_HOTKEY_LIST::TransferDataToControl()
{
Freeze();
diff --git a/include/widgets/widget_hotkey_list.h b/include/widgets/widget_hotkey_list.h
index bfaf010..60e78fb 100644
--- a/include/widgets/widget_hotkey_list.h
+++ b/include/widgets/widget_hotkey_list.h
@@ -178,6 +178,13 @@ public:
void InstallOnPanel( wxPanel* aPanel );
/**
+ * Method TransferDefaultsToControl
+ * Set hotkeys in the control to default values.
+ * @return true iff the operation was successful
+ */
+ bool TransferDefaultsToControl();
+
+ /**
* Method TransferDataToControl
* Load the hotkey data into the control. It is safe to call this multiple times,
* for example to reset the control.
--
1.9.1
Follow ups
References