34#include <wx/filedlg.h>
36#include <wx/srchctrl.h>
37#include <wx/txtstrm.h>
38#include <wx/wfstream.h>
51 wxSearchCtrl* search_widget =
new wxSearchCtrl( aParent, wxID_ANY );
53 search_widget->ShowSearchButton(
false );
54 search_widget->ShowCancelButton(
true );
56 search_widget->SetDescriptiveText( aDescriptiveText );
61 search_widget->SetMinSize( wxSize( -1, aParent->GetTextExtent( wxT(
"qb" ) ).y + 10 ) );
72 m_readOnly( aReadOnly ),
75 wxBoxSizer* mainSizer =
new wxBoxSizer( wxVERTICAL );
76 wxBoxSizer* bMargins =
new wxBoxSizer( wxVERTICAL );
79 bMargins->Add( filterSearch, 0, wxEXPAND, 0 );
87 mainSizer->Add( bMargins, 1, wxEXPAND, 0 );
91 filterSearch->SetMinSize( wxSize( filterSearch->GetSize().x,
92 int( filterSearch->GetSize().y * 1.6 ) ) );
95 SetSizer( mainSizer );
114 _(
"Undo All Changes" ),
115 _(
"Undo all changes made so far in this dialog" ),
116 [
this]( wxCommandEvent& )
123 _(
"Import Hotkeys..." ),
124 _(
"Import hotkey definitions from an external file, replacing the current values" ),
125 [
this]( wxCommandEvent& )
135 l_btn_defs.push_back( {
136 wxID_ANY, wxT(
"Dump Hotkeys" ), wxEmptyString,
137 [
this]( wxCommandEvent& )
147 auto btnPanel = std::make_unique<BUTTON_ROW_PANEL>(
this, l_btn_defs, r_btn_defs );
180 const auto searchStr = aEvent.GetString();
187 wxString filename = wxFileSelector(
_(
"Import Hotkeys File:" ),
m_frame->
GetMruPath(),
191 if( filename.IsEmpty() )
194 std::map<std::string, int> importedHotKeys;
201 for(
HOTKEY& hotkey: section.m_HotKeys )
203 if( importedHotKeys.count( hotkey.
m_Actions[ 0 ]->GetName() ) )
214 wxString filename = wxFileSelector( wxT(
"Hotkeys File" ),
m_frame->
GetMruPath(),
218 if( filename.IsEmpty() )
221 wxFileName fn( filename );
223 wxFFileOutputStream fileStream( fn.GetFullPath(),
"w" );
224 wxTextOutputStream stream( fileStream );
226 if( !fn.IsDirWritable() || ( fn.Exists() && !fn.IsFileWritable() ) )
231 stream << wxT(
"=== " ) << section.m_SectionName << endl << endl;
233 stream << wxT(
"[width=\"100%\",options=\"header\",cols=\"20%,15%,65%\"]" ) << endl;
234 stream << wxT(
"|===" ) << endl;
235 stream <<
_(
"| Action | Default Hotkey | Description" ) << endl;
237 for(
HOTKEY& hk : section.m_HotKeys )
239 stream << wxT(
"| " ) << hk.
m_Actions[0]->GetLabel() << endl;
248 stream << wxT(
" |" ) << endl;
251 stream << wxT(
" | " ) << hk.
m_Actions[0]->GetDescription(
false ) << endl;
254 stream << wxT(
"|===" ) << endl << endl;
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
The base frame for deriving all KiCad main window classes.
wxString GetMruPath() const
void SetMruPath(const wxString &aPath)
void Init(std::vector< TOOL_ACTION * > aActionsList, bool aIncludeReadOnlyCmds)
std::vector< HOTKEY_SECTION > & GetSections()
Get the list of sections managed by this store.
HOTKEY_STORE m_hotkeyStore
PANEL_HOTKEYS_EDITOR(EDA_BASE_FRAME *aFrame, wxWindow *aWindow, bool aReadOnly)
void OnFilterSearch(wxCommandEvent &aEvent)
Handle a change in the hotkey filter text.
void ResetPanel() override
Reset the contents of this panel.
std::vector< TOOL_ACTION * > m_actions
void installButtons(wxSizer *aSizer)
Install the button panel (global reset/default, import/export)
WIDGET_HOTKEY_LIST * m_hotkeyListCtrl
bool TransferDataToWindow() override
void ImportHotKeys()
Put up a dialog allowing the user to select a hotkeys file and then overlays those hotkeys onto the c...
void dumpHotkeys()
Dump all actions and their hotkeys to a text file for inclusion in documentation.
bool TransferDataFromWindow() override
A wxPanel that is designed to be reset in a standard manner.
const std::string HotkeyFileExtension
const std::string TextFileExtension
wxString TextFileWildcard()
wxString HotkeyFileWildcard()
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
int WriteHotKeyConfig(const std::vector< TOOL_ACTION * > &aActions)
Update the hotkeys config file with the hotkeys from the given actions map.
void ReadHotKeyConfig(const wxString &aFileName, std::map< std::string, int > &aHotKeys)
Reads a hotkey config file into a map.
int GetStdMargin()
Get the standard margin around a widget in the KiCad UI.
static wxSearchCtrl * CreateTextFilterBox(wxWindow *aParent, const wxString &aDescriptiveText)
Helper function to add a filter box to a panel, with some sensible defaults for that purpose.
std::vector< TOOL_ACTION * > m_Actions
Functions to provide common constants and other functions to assist in making a consistent UI.
Definition of file extensions used in Kicad.