![]() |
KiCad PCB EDA Suite
|
#include <kiface_i.h>
#include <hotkeys_basic.h>
#include <id.h>
#include <kicad_string.h>
#include <eda_base_frame.h>
#include <eda_draw_frame.h>
#include <settings/settings_manager.h>
#include <tool/tool_manager.h>
#include "dialogs/dialog_hotkey_list.h"
#include <wx/apptrait.h>
#include <wx/stdpaths.h>
#include <wx/tokenzr.h>
#include <wx/txtstrm.h>
#include <wx/wfstream.h>
#include <tool/tool_action.h>
Go to the source code of this file.
Classes | |
struct | hotkey_name_descr |
Macros | |
#define | KEY_NON_FOUND -1 |
#define | MODIFIER_CTRL wxT( "Ctrl+" ) |
#define | MODIFIER_CMD_MAC wxT( "Cmd+" ) |
#define | MODIFIER_CTRL_BASE wxT( "Ctrl+" ) |
#define | MODIFIER_ALT wxT( "Alt+" ) |
#define | MODIFIER_SHIFT wxT( "Shift+" ) |
Functions | |
wxString | KeyNameFromKeyCode (int aKeycode, bool *aIsFound) |
Return the key name from the key code. More... | |
wxString | AddHotkeyName (const wxString &aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle) |
int | KeyCodeFromKeyName (const wxString &keyname) |
Return the key code from its user-friendly key name (ie: "Ctrl+M"). More... | |
void | DisplayHotkeyList (EDA_BASE_FRAME *aParent, TOOL_MANAGER *aToolManager) |
Display the current hotkey list. More... | |
void | ReadHotKeyConfig (const wxString &aFileName, std::map< std::string, int > &aHotKeys) |
Reads a hotkey config file into a map. More... | |
int | WriteHotKeyConfig (const std::map< std::string, TOOL_ACTION * > &aActionMap) |
Update the hotkeys config file with the hotkeys from the given actions map. More... | |
int | ReadLegacyHotkeyConfig (const wxString &aAppname, std::map< std::string, int > &aMap) |
Read configuration data and fill the current hotkey list with hotkeys. More... | |
int | ReadLegacyHotkeyConfigFile (const wxString &aFilename, std::map< std::string, int > &aMap) |
Read hotkey configuration for a given app. More... | |
Variables | |
static struct hotkey_name_descr | hotkeyNameList [] |
#define KEY_NON_FOUND -1 |
Definition at line 61 of file hotkeys_basic.cpp.
#define MODIFIER_ALT wxT( "Alt+" ) |
Definition at line 139 of file hotkeys_basic.cpp.
#define MODIFIER_CMD_MAC wxT( "Cmd+" ) |
Definition at line 137 of file hotkeys_basic.cpp.
#define MODIFIER_CTRL wxT( "Ctrl+" ) |
Definition at line 135 of file hotkeys_basic.cpp.
#define MODIFIER_CTRL_BASE wxT( "Ctrl+" ) |
Definition at line 138 of file hotkeys_basic.cpp.
#define MODIFIER_SHIFT wxT( "Shift+" ) |
Definition at line 140 of file hotkeys_basic.cpp.
wxString AddHotkeyName | ( | const wxString & | aText, |
int | aHotKey, | ||
HOTKEY_ACTION_TYPE | aStyle | ||
) |
aText | the base text on which to append the hotkey. |
aHotKey | the hotkey keycode. |
aStyle | IS_HOTKEY to add <tab><keyname> (shortcuts in menus, same as hotkeys). IS_COMMENT to add <spaces><(keyname)> mainly in tool tips. |
Definition at line 208 of file hotkeys_basic.cpp.
References IS_COMMENT, IS_HOTKEY, KeyNameFromKeyCode(), MODIFIER_CMD_MAC, and MODIFIER_CTRL_BASE.
Referenced by TOOL_ACTION::GetMenuItem(), and PCB_LAYER_BOX_SELECTOR::Resync().
void DisplayHotkeyList | ( | EDA_BASE_FRAME * | aFrame, |
TOOL_MANAGER * | aToolMgr | ||
) |
Display the current hotkey list.
aFrame | current active frame. |
aToolMgr | the tool manager holding the registered actions from which the hotkeys will be harvested. |
Definition at line 315 of file hotkeys_basic.cpp.
Referenced by COMMON_CONTROL::ListHotKeys().
int KeyCodeFromKeyName | ( | const wxString & | keyname | ) |
Return the key code from its user-friendly key name (ie: "Ctrl+M").
Definition at line 249 of file hotkeys_basic.cpp.
References hotkeyNameList, KEY_NON_FOUND, hotkey_name_descr::m_KeyCode, hotkey_name_descr::m_Name, MD_ALT, MD_CTRL, MD_SHIFT, MODIFIER_ALT, MODIFIER_CMD_MAC, MODIFIER_CTRL_BASE, and MODIFIER_SHIFT.
Referenced by ReadHotKeyConfig(), and ReadLegacyHotkeyConfigFile().
wxString KeyNameFromKeyCode | ( | int | aKeycode, |
bool * | aIsFound | ||
) |
Return the key name from the key code.
Return the user friendly key name (ie: "Ctrl+M") from the key code.
Only some wxWidgets key values are handled for function key ( see hotkeyNameList[] )
aKeycode | key code (ASCII value, or wxWidgets value for function keys). |
aIsFound | a pointer to a bool to return true if found, or false. an be nullptr default). |
Definition at line 152 of file hotkeys_basic.cpp.
References hotkeyNameList, KEY_NON_FOUND, hotkey_name_descr::m_KeyCode, hotkey_name_descr::m_Name, MD_ALT, MD_CTRL, MD_SHIFT, MODIFIER_ALT, MODIFIER_CTRL, and MODIFIER_SHIFT.
Referenced by AddHotkeyName(), WIDGET_HOTKEY_LIST::changeHotkey(), PANEL_HOTKEYS_EDITOR::dumpHotkeys(), PAD_TOOL::EditPad(), HOTKEY_FILTER::FilterMatches(), TOOL_ACTION::GetDescription(), WIDGET_HOTKEY_LIST::resolveKeyConflicts(), ACTION_MANAGER::RunHotKey(), DIALOG_GRID_SETTINGS::TransferDataToWindow(), WIDGET_HOTKEY_LIST::updateFromClientData(), and WriteHotKeyConfig().
void ReadHotKeyConfig | ( | const wxString & | aFileName, |
std::map< std::string, int > & | aHotKeys | ||
) |
Reads a hotkey config file into a map.
If aFileName is empty it will read in the default hotkeys file.
Definition at line 322 of file hotkeys_basic.cpp.
References DEFAULT_HOTKEY_FILENAME_EXT, SETTINGS_MANAGER::GetUserSettingsPath(), and KeyCodeFromKeyName().
Referenced by PANEL_HOTKEYS_EDITOR::ImportHotKeys(), ACTION_MANAGER::UpdateHotKeys(), and WriteHotKeyConfig().
int ReadLegacyHotkeyConfig | ( | const wxString & | aAppname, |
std::map< std::string, int > & | aMap | ||
) |
Read configuration data and fill the current hotkey list with hotkeys.
aAppname | the value of the app's m_FrameName. |
aMap | The list of keycodes mapped by legacy property names. |
Definition at line 390 of file hotkeys_basic.cpp.
References EESCHEMA_HOTKEY_NAME, FOOTPRINT_EDIT_FRAME_NAME, LIB_EDIT_FRAME_NAME, PCB_EDIT_FRAME_NAME, PCBNEW_HOTKEY_NAME, ReadLegacyHotkeyConfigFile(), and SCH_EDIT_FRAME_NAME.
Referenced by ACTION_MANAGER::UpdateHotKeys().
int ReadLegacyHotkeyConfigFile | ( | const wxString & | aFilename, |
std::map< std::string, int > & | aMap | ||
) |
Read hotkey configuration for a given app.
aFilename | the filename to save the hotkeys as. |
aMap | The list of keycodes mapped by legacy property names. |
Definition at line 407 of file hotkeys_basic.cpp.
References DEFAULT_HOTKEY_FILENAME_EXT, SETTINGS_MANAGER::GetUserSettingsPath(), and KeyCodeFromKeyName().
Referenced by ReadLegacyHotkeyConfig().
int WriteHotKeyConfig | ( | const std::map< std::string, TOOL_ACTION * > & | aActionMap | ) |
Update the hotkeys config file with the hotkeys from the given actions map.
Definition at line 360 of file hotkeys_basic.cpp.
References DEFAULT_HOTKEY_FILENAME_EXT, Format(), SETTINGS_MANAGER::GetUserSettingsPath(), hotkeys, KeyNameFromKeyCode(), and ReadHotKeyConfig().
Referenced by PANEL_HOTKEYS_EDITOR::TransferDataFromWindow().
|
static |
Definition at line 62 of file hotkeys_basic.cpp.
Referenced by KeyCodeFromKeyName(), and KeyNameFromKeyCode().