Add a helper to generate action documentation
This commit is contained in:
parent
a6c5c40f02
commit
7b64389062
|
@ -149,6 +149,8 @@ static const wxChar SkipBoundingBoxFpLoad[] = wxT( "SkipBoundingBoxFpLoad" );
|
||||||
*/
|
*/
|
||||||
static const wxChar SmallDrillMarkSize[] = wxT( "SmallDrillMarkSize" );
|
static const wxChar SmallDrillMarkSize[] = wxT( "SmallDrillMarkSize" );
|
||||||
|
|
||||||
|
static const wxChar HotkeysDumper[] = wxT( "HotkeysDumper" );
|
||||||
|
|
||||||
|
|
||||||
} // namespace KEYS
|
} // namespace KEYS
|
||||||
|
|
||||||
|
@ -247,10 +249,9 @@ ADVANCED_CFG::ADVANCED_CFG()
|
||||||
|
|
||||||
m_DebugZoneFiller = false;
|
m_DebugZoneFiller = false;
|
||||||
m_DebugPDFWriter = false;
|
m_DebugPDFWriter = false;
|
||||||
|
|
||||||
m_SkipBoundingBoxOnFpLoad = false;
|
m_SkipBoundingBoxOnFpLoad = false;
|
||||||
|
m_SmallDrillMarkSize = 0.35;
|
||||||
m_SmallDrillMarkSize = 0.35;
|
m_HotkeysDumper = false;
|
||||||
|
|
||||||
loadFromConfigFile();
|
loadFromConfigFile();
|
||||||
}
|
}
|
||||||
|
@ -338,6 +339,9 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
|
||||||
configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::SmallDrillMarkSize,
|
configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::SmallDrillMarkSize,
|
||||||
&m_SmallDrillMarkSize, 0.35, 0.0, 3.0 ) );
|
&m_SmallDrillMarkSize, 0.35, 0.0, 3.0 ) );
|
||||||
|
|
||||||
|
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::HotkeysDumper,
|
||||||
|
&m_HotkeysDumper, false ) );
|
||||||
|
|
||||||
wxConfigLoadSetups( &aCfg, configParams );
|
wxConfigLoadSetups( &aCfg, configParams );
|
||||||
|
|
||||||
for( PARAM_CFG* param : configParams )
|
for( PARAM_CFG* param : configParams )
|
||||||
|
|
|
@ -21,17 +21,21 @@
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <panel_hotkeys_editor.h>
|
#include <advanced_config.h>
|
||||||
#include <kiway_player.h>
|
#include <gestfich.h>
|
||||||
#include <wx/srchctrl.h>
|
|
||||||
#include <wx/panel.h>
|
|
||||||
#include <wx/sizer.h>
|
|
||||||
#include <hotkeys_basic.h>
|
#include <hotkeys_basic.h>
|
||||||
|
#include <kiway_player.h>
|
||||||
|
#include <locale_io.h>
|
||||||
|
#include <panel_hotkeys_editor.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
#include <widgets/button_row_panel.h>
|
#include <widgets/button_row_panel.h>
|
||||||
#include <widgets/ui_common.h>
|
#include <widgets/ui_common.h>
|
||||||
#include <tool/tool_manager.h>
|
#include <wx/panel.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/srchctrl.h>
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
#include <gestfich.h>
|
#include <wx/txtstrm.h>
|
||||||
|
#include <wx/wfstream.h>
|
||||||
|
|
||||||
static const wxSize default_dialog_size { 500, 350 };
|
static const wxSize default_dialog_size { 500, 350 };
|
||||||
|
|
||||||
|
@ -108,7 +112,7 @@ void PANEL_HOTKEYS_EDITOR::ResetPanel()
|
||||||
|
|
||||||
void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer )
|
void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer )
|
||||||
{
|
{
|
||||||
const BUTTON_ROW_PANEL::BTN_DEF_LIST l_btn_defs = {
|
BUTTON_ROW_PANEL::BTN_DEF_LIST l_btn_defs = {
|
||||||
{
|
{
|
||||||
wxID_RESET,
|
wxID_RESET,
|
||||||
_( "Undo All Changes" ),
|
_( "Undo All Changes" ),
|
||||||
|
@ -129,6 +133,19 @@ void PANEL_HOTKEYS_EDITOR::installButtons( wxSizer* aSizer )
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if( ADVANCED_CFG::GetCfg().m_HotkeysDumper )
|
||||||
|
{
|
||||||
|
// Add hotkeys dumper (does not need translation, it's a dev tool only)
|
||||||
|
l_btn_defs.push_back( {
|
||||||
|
wxID_ANY, wxT( "Dump Hotkeys" ), wxEmptyString,
|
||||||
|
[this]( wxCommandEvent& )
|
||||||
|
{
|
||||||
|
dumpHotkeys();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
const BUTTON_ROW_PANEL::BTN_DEF_LIST r_btn_defs = {
|
const BUTTON_ROW_PANEL::BTN_DEF_LIST r_btn_defs = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -196,4 +213,47 @@ void PANEL_HOTKEYS_EDITOR::ImportHotKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PANEL_HOTKEYS_EDITOR::dumpHotkeys()
|
||||||
|
{
|
||||||
|
wxString filename = EDA_FILE_SELECTOR( wxT( "Dump Hotkeys File:" ), m_frame->GetMruPath(),
|
||||||
|
wxEmptyString, wxT( "txt" ), wxT( "*.txt" ), this,
|
||||||
|
wxFD_SAVE, true );
|
||||||
|
|
||||||
|
if( filename.IsEmpty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxFileName fn( filename );
|
||||||
|
|
||||||
|
LOCALE_IO locale;
|
||||||
|
wxFFileOutputStream fileStream( fn.GetFullPath(), "w" );
|
||||||
|
wxTextOutputStream stream( fileStream );
|
||||||
|
|
||||||
|
if( !fn.IsDirWritable() || ( fn.Exists() && !fn.IsFileWritable() ) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for( HOTKEY_SECTION& section : m_hotkeyStore.GetSections() )
|
||||||
|
{
|
||||||
|
stream << wxT( "=== " ) << section.m_SectionName << endl << endl;
|
||||||
|
|
||||||
|
stream << wxT( "[width=\"100%\",options=\"header\",cols=\"20%,15%,65%\"]" ) << endl;
|
||||||
|
stream << wxT( "|===" ) << endl;
|
||||||
|
stream << wxT( "| Action | Default Hotkey | Description" ) << endl;
|
||||||
|
|
||||||
|
for( HOTKEY& hk : section.m_HotKeys )
|
||||||
|
{
|
||||||
|
stream << wxT( "| " ) << hk.m_Actions[0]->GetLabel() << endl;
|
||||||
|
|
||||||
|
if( hk.m_EditKeycode > 0 )
|
||||||
|
stream << wxT( " | `" ) << KeyNameFromKeyCode( hk.m_EditKeycode ) << '`' << endl;
|
||||||
|
else
|
||||||
|
stream << wxT( " |" ) << endl;
|
||||||
|
|
||||||
|
stream << wxT( " | " ) << hk.m_Actions[0]->GetDescription( false ) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream << wxT( "|===" ) << endl << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.Flush();
|
||||||
|
fileStream.Close();
|
||||||
|
}
|
||||||
|
|
|
@ -155,6 +155,11 @@ public:
|
||||||
*/
|
*/
|
||||||
double m_SmallDrillMarkSize;
|
double m_SmallDrillMarkSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable the hotkeys dumper feature, used for generating documentation
|
||||||
|
*/
|
||||||
|
bool m_HotkeysDumper;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ADVANCED_CFG();
|
ADVANCED_CFG();
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,13 @@ private:
|
||||||
*/
|
*/
|
||||||
void ImportHotKeys();
|
void ImportHotKeys();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dumps all actions and their hotkeys to a text file for inclusion in documentation.
|
||||||
|
* The format is asciidoc-compatible table rows.
|
||||||
|
* This function is hidden behind an advanced config flag and not intended for users.
|
||||||
|
*/
|
||||||
|
void dumpHotkeys();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
EDA_BASE_FRAME* m_frame;
|
EDA_BASE_FRAME* m_frame;
|
||||||
bool m_readOnly;
|
bool m_readOnly;
|
||||||
|
|
Loading…
Reference in New Issue