KiCad PCB EDA Suite
|
#include <widget_hotkey_list.h>
Public Member Functions | |
WIDGET_HOTKEY_LIST (wxWindow *aParent, HOTKEY_STORE &aHotkeyStore, bool aReadOnly) | |
Constructor WIDGET_HOTKEY_LIST Create a WIDGET_HOTKEY_LIST. | |
void | ApplyFilterString (const wxString &aFilterStr) |
Method ApplyFilterString 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 () |
Method TransferDataToControl Load the hotkey data from the store into the control. | |
bool | TransferDataFromControl () |
Method TransferDataFromControl Save the hotkey data from the control. | |
Static Public Member Functions | |
static long | MapKeypressToKeycode (const wxKeyEvent &aEvent) |
Static method MapKeypressToKeycode Map a keypress event to the correct key code for use as a hotkey. | |
Protected Member Functions | |
void | editItem (wxTreeListItem aItem, int aEditId) |
Method editItem Prompt the user for a new hotkey given a list item. | |
void | resetItem (wxTreeListItem aItem, int aResetId) |
Method resetItem Reset the item to either the default, the value when the dialog was opened, or none. | |
void | onActivated (wxTreeListEvent &aEvent) |
Method onActivated Handle activation of a row. | |
void | onContextMenu (wxTreeListEvent &aEvent) |
Method onContextMenu Handle right-click on a row. | |
void | onMenu (wxCommandEvent &aEvent) |
Method onMenu Handle activation of a context menu item. | |
bool | resolveKeyConflicts (TOOL_ACTION *aAction, long aKey) |
Method resolveKeyConflicts 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) |
Method getHKClientData Return the WIDGET_HOTKEY_CLIENT_DATA for the given item, or NULL if the item is invalid. | |
WIDGET_HOTKEY_CLIENT_DATA * | getExpectedHkClientData (wxTreeListItem aItem) |
Get the WIDGET_HOTKEY_CLIENT_DATA form an item and assert if it isn't found. | |
void | updateFromClientData () |
Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects. | |
void | updateShownItems (const wxString &aFilterStr) |
Method updateShownItems. | |
void | changeHotkey (HOTKEY &aHotkey, long aKey, bool alternate) |
Attempt to change the given hotkey to the given key code. | |
void | updateColumnWidths () |
Recalculates 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 | ||
) |
Constructor WIDGET_HOTKEY_LIST Create a WIDGET_HOTKEY_LIST.
aParent | - parent widget |
aHotkeys | - EDA_HOTKEY_CONFIG data - a hotkey store is constructed from this. |
Definition at line 517 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 | ) |
Method ApplyFilterString Apply a filter string to the hotkey list, selecting which hotkeys to show.
aFilterStr | the string to filter by |
Definition at line 582 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 353 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 |
Method editItem Prompt the user for a new hotkey given a list item.
Definition at line 372 of file widget_hotkey_list.cpp.
References _, changeHotkey(), DisplayErrorMessage(), WIDGET_HOTKEY_CLIENT_DATA::GetChangedHotkey(), getExpectedHkClientData(), ID_EDIT_ALT, ID_EDIT_HOTKEY, m_reservedHotkeys, name, HK_PROMPT_DIALOG::PromptForKey(), and updateFromClientData().
Referenced by onActivated(), and onMenu().
|
private |
Get the WIDGET_HOTKEY_CLIENT_DATA form an item and assert if it isn't found.
This is for use when the data not being present indicates an error.
Definition at line 305 of file widget_hotkey_list.cpp.
References getHKClientData().
Referenced by editItem(), and resetItem().
|
private |
Method getHKClientData Return the WIDGET_HOTKEY_CLIENT_DATA for the given item, or NULL if the item is invalid.
Definition at line 291 of file widget_hotkey_list.cpp.
Referenced by getExpectedHkClientData(), onContextMenu(), and updateFromClientData().
|
static |
Static method MapKeypressToKeycode Map a keypress event to the correct key code for use as a hotkey.
Definition at line 672 of file widget_hotkey_list.cpp.
References MD_ALT, MD_CTRL, and MD_SHIFT.
Referenced by HK_PROMPT_DIALOG::PromptForKey().
|
protected |
Method onActivated Handle activation of a row.
Definition at line 434 of file widget_hotkey_list.cpp.
References editItem(), and ID_EDIT_HOTKEY.
Referenced by WIDGET_HOTKEY_LIST().
|
protected |
Method onContextMenu Handle right-click on a row.
Definition at line 440 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 |
Method onMenu Handle activation of a context menu item.
Definition at line 465 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 588 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 |
Method resetItem Reset the item to either the default, the value when the dialog was opened, or none.
Definition at line 406 of file widget_hotkey_list.cpp.
References changeHotkey(), WIDGET_HOTKEY_CLIENT_DATA::GetChangedHotkey(), getExpectedHkClientData(), ID_CLEAR, ID_CLEAR_ALT, ID_DEFAULT, ID_RESET, HOTKEY::m_Actions, and updateFromClientData().
Referenced by onMenu().
|
protected |
Method resolveKeyConflicts 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 | - key to check |
aActionName | - name of the action into which the key is proposed to be installed |
Definition at line 487 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 | ( | ) |
Method TransferDataFromControl Save the hotkey data from the control.
Definition at line 665 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 | ( | ) |
Method TransferDataToControl Load the hotkey data from the store into the control.
Definition at line 607 of file widget_hotkey_list.cpp.
References updateColumnWidths(), and updateShownItems().
Referenced by PANEL_HOTKEYS_EDITOR::ImportHotKeys(), and PANEL_HOTKEYS_EDITOR::TransferDataToWindow().
|
private |
Recalculates column widths after model has changed.
Definition at line 616 of file widget_hotkey_list.cpp.
Referenced by ResetAllHotkeys(), and TransferDataToControl().
|
private |
Method updateFromClientData Refresh the visible text on the widget from the rows' client data objects.
Definition at line 317 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 |
Method updateShownItems.
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 636 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 189 of file widget_hotkey_list.h.
Referenced by onContextMenu(), and onMenu().
|
private |
Definition at line 184 of file widget_hotkey_list.h.
Referenced by ResetAllHotkeys(), resolveKeyConflicts(), TransferDataFromControl(), and updateShownItems().
|
private |
Definition at line 185 of file widget_hotkey_list.h.
Referenced by WIDGET_HOTKEY_LIST().
|
private |
Definition at line 187 of file widget_hotkey_list.h.
Referenced by editItem(), and WIDGET_HOTKEY_LIST().