KiCad PCB EDA Suite
Loading...
Searching...
No Matches
WIDGET_HOTKEY_LIST Class Reference

#include <widget_hotkey_list.h>

Inheritance diagram for WIDGET_HOTKEY_LIST:

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_DATAgetHKClientData (wxTreeListItem aItem)
 Method getHKClientData Return the WIDGET_HOTKEY_CLIENT_DATA for the given item, or NULL if the item is invalid.
 
WIDGET_HOTKEY_CLIENT_DATAgetExpectedHkClientData (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_STOREm_hk_store
 
bool m_readOnly
 
std::unordered_map< long, wxString > m_reservedHotkeys
 
wxTreeListItem m_context_menu_item
 

Detailed Description

Definition at line 41 of file widget_hotkey_list.h.

Constructor & Destructor Documentation

◆ WIDGET_HOTKEY_LIST()

WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST ( wxWindow *  aParent,
HOTKEY_STORE aHotkeyStore,
bool  aReadOnly 
)

Constructor WIDGET_HOTKEY_LIST Create a WIDGET_HOTKEY_LIST.

Parameters
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.

Member Function Documentation

◆ ApplyFilterString()

void WIDGET_HOTKEY_LIST::ApplyFilterString ( const wxString &  aFilterStr)

Method ApplyFilterString Apply a filter string to the hotkey list, selecting which hotkeys to show.

Parameters
aFilterStrthe string to filter by

Definition at line 582 of file widget_hotkey_list.cpp.

References updateShownItems().

Referenced by PANEL_HOTKEYS_EDITOR::OnFilterSearch().

◆ changeHotkey()

void WIDGET_HOTKEY_LIST::changeHotkey ( HOTKEY aHotkey,
long  aKey,
bool  alternate 
)
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.

Parameters
aHotkeythe change-able hotkey to try to change
aKeythe key code to change it to
alternateChange 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().

◆ editItem()

void WIDGET_HOTKEY_LIST::editItem ( wxTreeListItem  aItem,
int  aEditId 
)
protected

◆ getExpectedHkClientData()

WIDGET_HOTKEY_CLIENT_DATA * WIDGET_HOTKEY_LIST::getExpectedHkClientData ( wxTreeListItem  aItem)
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().

◆ getHKClientData()

WIDGET_HOTKEY_CLIENT_DATA * WIDGET_HOTKEY_LIST::getHKClientData ( wxTreeListItem  aItem)
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().

◆ MapKeypressToKeycode()

long WIDGET_HOTKEY_LIST::MapKeypressToKeycode ( const wxKeyEvent &  aEvent)
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().

◆ onActivated()

void WIDGET_HOTKEY_LIST::onActivated ( wxTreeListEvent &  aEvent)
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().

◆ onContextMenu()

void WIDGET_HOTKEY_LIST::onContextMenu ( wxTreeListEvent &  aEvent)
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().

◆ onMenu()

void WIDGET_HOTKEY_LIST::onMenu ( wxCommandEvent &  aEvent)
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().

◆ ResetAllHotkeys()

void WIDGET_HOTKEY_LIST::ResetAllHotkeys ( bool  aResetToDefault)

Set hotkeys in the control to default or original values.

Parameters
aResetToDefaultif 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().

◆ resetItem()

void WIDGET_HOTKEY_LIST::resetItem ( wxTreeListItem  aItem,
int  aResetId 
)
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().

◆ resolveKeyConflicts()

bool WIDGET_HOTKEY_LIST::resolveKeyConflicts ( TOOL_ACTION aAction,
long  aKey 
)
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.

Parameters
aKey- key to check
aActionName- name of the action into which the key is proposed to be installed
Returns
true iff the user accepted the overwrite or no conflict existed

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().

◆ TransferDataFromControl()

bool WIDGET_HOTKEY_LIST::TransferDataFromControl ( )

Method TransferDataFromControl Save the hotkey data from the control.

Returns
true iff the operation was successful

Definition at line 665 of file widget_hotkey_list.cpp.

References m_hk_store, and HOTKEY_STORE::SaveAllHotkeys().

Referenced by PANEL_HOTKEYS_EDITOR::TransferDataFromWindow().

◆ TransferDataToControl()

bool WIDGET_HOTKEY_LIST::TransferDataToControl ( )

Method TransferDataToControl Load the hotkey data from the store into the control.

Returns
true iff the operation was successful

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().

◆ updateColumnWidths()

void WIDGET_HOTKEY_LIST::updateColumnWidths ( )
private

Recalculates column widths after model has changed.

Definition at line 616 of file widget_hotkey_list.cpp.

Referenced by ResetAllHotkeys(), and TransferDataToControl().

◆ updateFromClientData()

void WIDGET_HOTKEY_LIST::updateFromClientData ( )
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().

◆ updateShownItems()

void WIDGET_HOTKEY_LIST::updateShownItems ( const wxString &  aFilterStr)
private

Method updateShownItems.

Update the items shown in the widget based on a given filter string.

Parameters
aFilterStrthe 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().

Member Data Documentation

◆ m_context_menu_item

wxTreeListItem WIDGET_HOTKEY_LIST::m_context_menu_item
private

Definition at line 189 of file widget_hotkey_list.h.

Referenced by onContextMenu(), and onMenu().

◆ m_hk_store

HOTKEY_STORE& WIDGET_HOTKEY_LIST::m_hk_store
private

◆ m_readOnly

bool WIDGET_HOTKEY_LIST::m_readOnly
private

Definition at line 185 of file widget_hotkey_list.h.

Referenced by WIDGET_HOTKEY_LIST().

◆ m_reservedHotkeys

std::unordered_map<long, wxString> WIDGET_HOTKEY_LIST::m_reservedHotkeys
private

Definition at line 187 of file widget_hotkey_list.h.

Referenced by editItem(), and WIDGET_HOTKEY_LIST().


The documentation for this class was generated from the following files: