33#include <wx/filedlg.h> 
   35#include <wx/srchctrl.h> 
   36#include <wx/txtstrm.h> 
   37#include <wx/wfstream.h> 
   50    wxSearchCtrl* search_widget = 
new wxSearchCtrl( aParent, wxID_ANY );
 
   52    search_widget->ShowSearchButton( 
false );
 
   53    search_widget->ShowCancelButton( 
true );
 
   55    search_widget->SetDescriptiveText( aDescriptiveText );
 
   60    search_widget->SetMinSize( wxSize( -1, aParent->GetTextExtent( wxT( 
"qb" ) ).y + 10 ) );
 
 
   74    wxBoxSizer* mainSizer = 
new wxBoxSizer( wxVERTICAL );
 
   75    wxBoxSizer* bMargins = 
new wxBoxSizer( wxVERTICAL );
 
   86    mainSizer->Add( bMargins, 1, wxEXPAND, 0 );
 
   91#if wxVERSION_NUMBER < 3203 
  100    SetSizer( mainSizer );
 
  102    mainSizer->Fit( 
this );
 
 
  127            _( 
"Undo All Changes" ),
 
  128            _( 
"Undo all changes made so far in this dialog" ),
 
  129            [
this]( wxCommandEvent& )
 
  136            _( 
"Import Hotkeys..." ),
 
  137            _( 
"Import hotkey definitions from an external file, replacing the current values" ),
 
  138            [
this]( wxCommandEvent& )
 
  148        l_btn_defs.push_back( {
 
  149                wxID_ANY, wxT( 
"Dump Hotkeys" ), wxEmptyString,
 
  150                [
this]( wxCommandEvent& )
 
  160    auto btnPanel = std::make_unique<BUTTON_ROW_PANEL>( 
this, l_btn_defs, r_btn_defs );
 
 
  193    const auto searchStr = aEvent.GetString();
 
 
  200    wxString filename = wxFileSelector( 
_( 
"Import Hotkeys File:" ), 
m_frame->GetMruPath(),
 
  203                                        wxGetTopLevelParent( 
this ) );
 
  205    if( filename.IsEmpty() )
 
  208    std::map<std::string, std::pair<int, int>> importedHotKeys;
 
  210    m_frame->SetMruPath( wxFileName( filename ).GetPath() );
 
  215        for( 
HOTKEY& hotkey: section.m_HotKeys )
 
  217            if( importedHotKeys.count( hotkey.
m_Actions[ 0 ]->GetName() ) )
 
 
  231    wxString filename = wxFileSelector( wxT( 
"Hotkeys File" ), 
m_frame->GetMruPath(),
 
  234                                        wxFD_SAVE, wxGetTopLevelParent( 
this ) );
 
  236    if( filename.IsEmpty() )
 
  239    wxFileName fn( filename );
 
  241    wxFFileOutputStream fileStream( fn.GetFullPath(), 
"w" );
 
  242    wxTextOutputStream stream( fileStream );
 
  244    if( !fn.IsDirWritable() || ( fn.Exists() && !fn.IsFileWritable() ) )
 
  249        stream << wxT( 
"=== " ) << section.m_SectionName << endl << endl;
 
  251        stream << wxT( 
"[width=\"100%\",options=\"header\",cols=\"20%,15%,65%\"]" ) << endl;
 
  252        stream << wxT( 
"|===" ) << endl;
 
  253        stream << 
_( 
"| Action | Default Hotkey | Description" ) << endl;
 
  255        for( 
HOTKEY& hk : section.m_HotKeys )
 
  257            stream << wxT( 
"| " ) << hk.
m_Actions[0]->GetFriendlyName() << endl;
 
  266                stream << wxT( 
"  |" ) << endl;
 
  269            stream << wxT( 
"  | " ) << hk.
m_Actions[0]->GetDescription() << endl;
 
  272        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.
 
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
 
RESETTABLE_PANEL(wxWindow *aParent, wxWindowID aId=wxID_ANY, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxSize(-1,-1), long aStyle=wxTAB_TRAVERSAL, const wxString &aName=wxEmptyString)
 
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)
Read 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.