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 );
87 mainSizer->Add( bMargins, 1, wxEXPAND, 0 );
92#if wxVERSION_NUMBER < 3203
101 SetSizer( mainSizer );
103 mainSizer->Fit(
this );
128 _(
"Undo All Changes" ),
129 _(
"Undo all changes made so far in this dialog" ),
130 [
this]( wxCommandEvent& )
137 _(
"Import Hotkeys..." ),
138 _(
"Import hotkey definitions from an external file, replacing the current values" ),
139 [
this]( wxCommandEvent& )
149 l_btn_defs.push_back( {
150 wxID_ANY, wxT(
"Dump Hotkeys" ), wxEmptyString,
151 [
this]( wxCommandEvent& )
161 auto btnPanel = std::make_unique<BUTTON_ROW_PANEL>(
this, l_btn_defs, r_btn_defs );
194 const auto searchStr = aEvent.GetString();
201 wxString filename = wxFileSelector(
_(
"Import Hotkeys File:" ),
m_frame->
GetMruPath(),
204 wxGetTopLevelParent(
this ) );
206 if( filename.IsEmpty() )
209 std::map<std::string, std::pair<int, int>> importedHotKeys;
216 for(
HOTKEY& hotkey: section.m_HotKeys )
218 if( importedHotKeys.count( hotkey.
m_Actions[ 0 ]->GetName() ) )
232 wxString filename = wxFileSelector( wxT(
"Hotkeys File" ),
m_frame->
GetMruPath(),
235 wxFD_SAVE, wxGetTopLevelParent(
this ) );
237 if( filename.IsEmpty() )
240 wxFileName fn( filename );
242 wxFFileOutputStream fileStream( fn.GetFullPath(),
"w" );
243 wxTextOutputStream stream( fileStream );
245 if( !fn.IsDirWritable() || ( fn.Exists() && !fn.IsFileWritable() ) )
250 stream << wxT(
"=== " ) << section.m_SectionName << endl << endl;
252 stream << wxT(
"[width=\"100%\",options=\"header\",cols=\"20%,15%,65%\"]" ) << endl;
253 stream << wxT(
"|===" ) << endl;
254 stream <<
_(
"| Action | Default Hotkey | Description" ) << endl;
256 for(
HOTKEY& hk : section.m_HotKeys )
258 stream << wxT(
"| " ) << hk.
m_Actions[0]->GetFriendlyName() << endl;
267 stream << wxT(
" |" ) << endl;
270 stream << wxT(
" | " ) << hk.
m_Actions[0]->GetDescription() << endl;
273 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.
wxSearchCtrl * m_filterSearch
bool TransferDataFromWindow() override
A wxPanel that is designed to be reset in a standard manner.
static const std::string TextFileExtension
static const std::string HotkeyFileExtension
static wxString HotkeyFileWildcard()
static wxString TextFileWildcard()
void ReadHotKeyConfig(const wxString &aFileName, std::map< std::string, std::pair< int, int > > &aHotKeys)
Reads a hotkey config file into a map.
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.
KICOMMON_API 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.