KiCad PCB EDA Suite
|
#include <widget_hotkey_list.h>
Public Member Functions | |
WIDGET_HOTKEY_LIST (wxWindow *aParent, HOTKEY_STORE &aHotkeyStore, bool aReadOnly) | |
Create a WIDGET_HOTKEY_LIST. | |
void | ApplyFilterString (const wxString &aFilterStr) |
Apply a filter string to the hotkey list, selecting which hotkeys to show. | |
void | ResetAllHotkeys (bool aResetToDefault) |
Set hotkeys in the control to default or original values. | |
bool | TransferDataToControl () |
Load the hotkey data from the store into the control. | |
bool | TransferDataFromControl () |
Save the hotkey data from the control. | |
Static Public Member Functions | |
static long | MapKeypressToKeycode (const wxKeyEvent &aEvent) |
Map a keypress event to the correct key code for use as a hotkey. | |
Protected Member Functions | |
void | editItem (wxTreeListItem aItem, int aEditId) |
Prompt the user for a new hotkey given a list item. | |
void | resetItem (wxTreeListItem aItem, int aResetId) |
Reset the item to either the default, the value when the dialog was opened, or none. | |
void | onActivated (wxTreeListEvent &aEvent) |
Handle activation of a row. | |
void | onContextMenu (wxTreeListEvent &aEvent) |
Handle right-click on a row. | |
void | onMenu (wxCommandEvent &aEvent) |
Handle activation of a context menu item. | |
bool | resolveKeyConflicts (TOOL_ACTION *aAction, long aKey) |
Check if we can set a hotkey, and prompt the user if there is a conflict between keys. | |
Private Member Functions | |
WIDGET_HOTKEY_CLIENT_DATA * | getHKClientData (wxTreeListItem aItem) |
Return the WIDGET_HOTKEY_CLIENT_DATA for the given item, or NULL if the item is invalid. | |
void | updateFromClientData () |
Refresh the visible text on the widget from the rows' client data objects. | |
void | updateShownItems (const wxString &aFilterStr) |
Update the items shown in the widget based on a given filter string. | |
void | changeHotkey (HOTKEY &aHotkey, long aKey, bool alternate) |
Attempt to change the given hotkey to the given key code. | |
void | updateColumnWidths () |
Recalculate column widths after model has changed. | |
Private Attributes | |
HOTKEY_STORE & | m_hk_store |
bool | m_readOnly |
std::unordered_map< long, wxString > | m_reservedHotkeys |
wxTreeListItem | m_context_menu_item |
Definition at line 41 of file widget_hotkey_list.h.
WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST | ( | wxWindow * | aParent, |
HOTKEY_STORE & | aHotkeyStore, | ||
bool | aReadOnly | ||
) |
Create a WIDGET_HOTKEY_LIST.
aParent | is the parent widget. |
aHotkeys | is the #EDA_HOTKEY_CONFIG data: a hotkey store is constructed from this. |
Definition at line 515 of file widget_hotkey_list.cpp.
References _, KeyCodeFromKeyName(), m_readOnly, m_reservedHotkeys, onActivated(), onContextMenu(), onMenu(), and pad.
void WIDGET_HOTKEY_LIST::ApplyFilterString | ( | const wxString & | aFilterStr | ) |
Apply a filter string to the hotkey list, selecting which hotkeys to show.
aFilterStr | the string to filter by. |
Definition at line 580 of file widget_hotkey_list.cpp.
References updateShownItems().
Referenced by PANEL_HOTKEYS_EDITOR::OnFilterSearch().
|
private |
Attempt to change the given hotkey to the given key code.
If the hotkey conflicts, the user is prompted to change anyway (and in doing so, unset the conflicting key), or cancel the attempt.
aHotkey | the change-able hotkey to try to change. |
aKey | the key code to change it to. |
alternate | Change the secondary hotkey. |
Definition at line 347 of file widget_hotkey_list.cpp.
References KeyNameFromKeyCode(), HOTKEY::m_Actions, HOTKEY::m_EditKeycode, HOTKEY::m_EditKeycodeAlt, and resolveKeyConflicts().
Referenced by editItem(), and resetItem().
|
protected |
Prompt the user for a new hotkey given a list item.
Definition at line 366 of file widget_hotkey_list.cpp.
References _, changeHotkey(), DisplayErrorMessage(), WIDGET_HOTKEY_CLIENT_DATA::GetChangedHotkey(), getHKClientData(), ID_EDIT_ALT, ID_EDIT_HOTKEY, m_reservedHotkeys, name, HK_PROMPT_DIALOG::PromptForKey(), and updateFromClientData().
Referenced by onActivated(), and onMenu().
|
private |
Return the WIDGET_HOTKEY_CLIENT_DATA for the given item, or NULL if the item is invalid.
Definition at line 297 of file widget_hotkey_list.cpp.
Referenced by editItem(), onContextMenu(), resetItem(), and updateFromClientData().
|
static |
Map a keypress event to the correct key code for use as a hotkey.
Definition at line 670 of file widget_hotkey_list.cpp.
References MD_ALT, MD_CTRL, and MD_SHIFT.
Referenced by HK_PROMPT_DIALOG::PromptForKey().
|
protected |
Handle activation of a row.
Definition at line 432 of file widget_hotkey_list.cpp.
References editItem(), and ID_EDIT_HOTKEY.
Referenced by WIDGET_HOTKEY_LIST().
|
protected |
Handle right-click on a row.
Definition at line 438 of file widget_hotkey_list.cpp.
References _, getHKClientData(), ID_CLEAR, ID_CLEAR_ALT, ID_DEFAULT, ID_EDIT_ALT, ID_EDIT_HOTKEY, ID_RESET, and m_context_menu_item.
Referenced by WIDGET_HOTKEY_LIST().
|
protected |
Handle activation of a context menu item.
Definition at line 463 of file widget_hotkey_list.cpp.
References editItem(), ID_CLEAR, ID_CLEAR_ALT, ID_DEFAULT, ID_EDIT_ALT, ID_EDIT_HOTKEY, ID_RESET, m_context_menu_item, and resetItem().
Referenced by WIDGET_HOTKEY_LIST().
void WIDGET_HOTKEY_LIST::ResetAllHotkeys | ( | bool | aResetToDefault | ) |
Set hotkeys in the control to default or original values.
aResetToDefault | if true, reset to the defaults inherent to the hotkeys, else reset to the value they had when the dialog was invoked. |
Definition at line 586 of file widget_hotkey_list.cpp.
References m_hk_store, HOTKEY_STORE::ResetAllHotkeysToDefault(), HOTKEY_STORE::ResetAllHotkeysToOriginal(), updateColumnWidths(), and updateFromClientData().
Referenced by PANEL_HOTKEYS_EDITOR::installButtons(), and PANEL_HOTKEYS_EDITOR::ResetPanel().
|
protected |
Reset the item to either the default, the value when the dialog was opened, or none.
Definition at line 400 of file widget_hotkey_list.cpp.
References changeHotkey(), WIDGET_HOTKEY_CLIENT_DATA::GetChangedHotkey(), getHKClientData(), ID_CLEAR, ID_CLEAR_ALT, ID_DEFAULT, ID_RESET, HOTKEY::m_Actions, and updateFromClientData().
Referenced by onMenu().
|
protected |
Check if we can set a hotkey, and prompt the user if there is a conflict between keys.
The key code should already have been checked that it's not for the same entry as it's current in, or else this method will prompt for the self-change.
The method will do conflict resolution depending on aSectionTag. g_CommonSectionTag means the key code must only be checked with the aSectionTag section and g_CommonSectionTag section.
aKey | is the key to check. |
aActionName | is the name of the action into which the key is proposed to be installed. |
Definition at line 485 of file widget_hotkey_list.cpp.
References _, HOTKEY_STORE::CheckKeyConflicts(), TOOL_ACTION::GetFriendlyName(), HOTKEY_STORE::GetSectionName(), KeyNameFromKeyCode(), HOTKEY::m_Actions, HOTKEY::m_EditKeycode, m_hk_store, and updateFromClientData().
Referenced by changeHotkey().
bool WIDGET_HOTKEY_LIST::TransferDataFromControl | ( | ) |
Save the hotkey data from the control.
Definition at line 663 of file widget_hotkey_list.cpp.
References m_hk_store, and HOTKEY_STORE::SaveAllHotkeys().
Referenced by PANEL_HOTKEYS_EDITOR::TransferDataFromWindow().
bool WIDGET_HOTKEY_LIST::TransferDataToControl | ( | ) |
Load the hotkey data from the store into the control.
Definition at line 605 of file widget_hotkey_list.cpp.
References updateColumnWidths(), and updateShownItems().
Referenced by PANEL_HOTKEYS_EDITOR::ImportHotKeys(), and PANEL_HOTKEYS_EDITOR::TransferDataToWindow().
|
private |
Recalculate column widths after model has changed.
Definition at line 614 of file widget_hotkey_list.cpp.
Referenced by ResetAllHotkeys(), and TransferDataToControl().
|
private |
Refresh the visible text on the widget from the rows' client data objects.
Definition at line 311 of file widget_hotkey_list.cpp.
References WIDGET_HOTKEY_CLIENT_DATA::GetChangedHotkey(), getHKClientData(), KeyNameFromKeyCode(), HOTKEY::m_Actions, HOTKEY::m_EditKeycode, and HOTKEY::m_EditKeycodeAlt.
Referenced by editItem(), ResetAllHotkeys(), resetItem(), resolveKeyConflicts(), and updateShownItems().
|
private |
Update the items shown in the widget based on a given filter string.
aFilterStr | the string to filter with. Empty means no filter. |
Definition at line 634 of file widget_hotkey_list.cpp.
References filter, HOTKEY_STORE::GetSections(), m_hk_store, and updateFromClientData().
Referenced by ApplyFilterString(), and TransferDataToControl().
|
private |
Definition at line 169 of file widget_hotkey_list.h.
Referenced by onContextMenu(), and onMenu().
|
private |
Definition at line 164 of file widget_hotkey_list.h.
Referenced by ResetAllHotkeys(), resolveKeyConflicts(), TransferDataFromControl(), and updateShownItems().
|
private |
Definition at line 165 of file widget_hotkey_list.h.
Referenced by WIDGET_HOTKEY_LIST().
|
private |
Definition at line 167 of file widget_hotkey_list.h.
Referenced by editItem(), and WIDGET_HOTKEY_LIST().