|
KiCad PCB EDA Suite
|
#include <widget_hotkey_list.h>
Public Member Functions | |
| WIDGET_HOTKEY_LIST (wxWindow *aParent, HOTKEY_STORE &aHotkeyStore, bool readOnly) | |
| 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. | |
| bool | IsReservedHotkey (long aKey, wxString *aKeyName=nullptr) const |
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. | |
| void | onCharHook (wxKeyEvent &aEvent) |
| Handle key events to filter out dead keys that can crash on macOS. | |
| 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 |
| std::unordered_map< long, wxString > | m_reservedHotkeys |
| wxTreeListItem | m_context_menu_item |
Definition at line 37 of file widget_hotkey_list.h.
| WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST | ( | wxWindow * | aParent, |
| HOTKEY_STORE & | aHotkeyStore, | ||
| bool | readOnly ) |
Create a WIDGET_HOTKEY_LIST.
| aParent | is the parent widget. |
| aHotkeyStore | is the HOTKEY_STORE with the hot key information. |
| readOnly | makes the list read only if true. |
Definition at line 535 of file widget_hotkey_list.cpp.
References _, KeyCodeFromKeyName(), m_hk_store, m_reservedHotkeys, onActivated(), onCharHook(), 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 603 of file widget_hotkey_list.cpp.
References updateShownItems().
|
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 340 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 376 of file widget_hotkey_list.cpp.
References _, changeHotkey(), DisplayErrorMessage(), WIDGET_HOTKEY_CLIENT_DATA::GetChangedHotkey(), getHKClientData(), ID_EDIT_ALT, ID_EDIT_HOTKEY, IsReservedHotkey(), 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 290 of file widget_hotkey_list.cpp.
Referenced by editItem(), onContextMenu(), resetItem(), and updateFromClientData().
| bool WIDGET_HOTKEY_LIST::IsReservedHotkey | ( | long | aKey, |
| wxString * | aKeyName = nullptr ) const |
Definition at line 362 of file widget_hotkey_list.cpp.
References m_reservedHotkeys.
Referenced by editItem().
|
static |
Map a keypress event to the correct key code for use as a hotkey.
Definition at line 691 of file widget_hotkey_list.cpp.
References MD_ALT, MD_ALTGR, MD_CTRL, MD_META, MD_SHIFT, and MD_SUPER.
Referenced by PCB_ONE_LAYER_SELECTOR::onCharHook(), and HK_PROMPT_DIALOG::PromptForKey().
|
protected |
Handle activation of a row.
Definition at line 442 of file widget_hotkey_list.cpp.
References editItem(), and ID_EDIT_HOTKEY.
Referenced by WIDGET_HOTKEY_LIST().
|
protected |
Handle key events to filter out dead keys that can crash on macOS.
Definition at line 495 of file widget_hotkey_list.cpp.
Referenced by WIDGET_HOTKEY_LIST().
|
protected |
Handle right-click on a row.
Definition at line 448 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 473 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 609 of file widget_hotkey_list.cpp.
References m_hk_store, updateColumnWidths(), and updateFromClientData().
|
protected |
Reset the item to either the default, the value when the dialog was opened, or none.
Definition at line 410 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.
| aAction | is the tool action into which the key is proposed to be installed. |
| aKey | is the key to check. |
Definition at line 513 of file widget_hotkey_list.cpp.
References _, TOOL_ACTION::GetFriendlyName(), HOTKEY_STORE::GetSectionName(), KeyNameFromKeyCode(), KICAD_MESSAGE_DIALOG, HOTKEY::m_Actions, and m_hk_store.
Referenced by changeHotkey().
| bool WIDGET_HOTKEY_LIST::TransferDataFromControl | ( | ) |
Save the hotkey data from the control.
Definition at line 684 of file widget_hotkey_list.cpp.
References m_hk_store.
| bool WIDGET_HOTKEY_LIST::TransferDataToControl | ( | ) |
Load the hotkey data from the store into the control.
Definition at line 626 of file widget_hotkey_list.cpp.
References updateColumnWidths(), and updateShownItems().
|
private |
Recalculate column widths after model has changed.
Definition at line 635 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 304 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(), 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 655 of file widget_hotkey_list.cpp.
References filter, m_hk_store, and updateFromClientData().
Referenced by ApplyFilterString(), and TransferDataToControl().
|
private |
Definition at line 172 of file widget_hotkey_list.h.
Referenced by onContextMenu(), and onMenu().
|
private |
Definition at line 168 of file widget_hotkey_list.h.
Referenced by ResetAllHotkeys(), resolveKeyConflicts(), TransferDataFromControl(), updateShownItems(), and WIDGET_HOTKEY_LIST().
|
private |
Definition at line 170 of file widget_hotkey_list.h.
Referenced by IsReservedHotkey(), and WIDGET_HOTKEY_LIST().