Save hotkeys to combined app-based file
Unifies the different sections of hotkeys so that we are not storing two [eeschema] or [pcbnew] sections in two different files. Previous hotkey definitions are loaded at start if they exist but are overwritten by the new format, if it exists. Changes to hotkeys save only in the combined format. Hotkey editor for each application only shows the hotkeys relevant to that application. Fixes: lp:1741757 * https://bugs.launchpad.net/kicad/+bug/1741757 Fixes: lp:1668799 * https://bugs.launchpad.net/kicad/+bug/1668799
This commit is contained in:
parent
d22fceca7c
commit
d62b4f36a6
|
@ -23,9 +23,13 @@
|
|||
|
||||
#include <dialog_hotkeys_editor.h>
|
||||
|
||||
void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
|
||||
void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys,
|
||||
EDA_HOTKEY_CONFIG* aShowHotkeys )
|
||||
{
|
||||
HOTKEYS_EDITOR_DIALOG dialog( aParent, aHotkeys );
|
||||
if( !aShowHotkeys )
|
||||
aShowHotkeys = aHotkeys;
|
||||
|
||||
HOTKEYS_EDITOR_DIALOG dialog( aParent, aHotkeys, aShowHotkeys );
|
||||
|
||||
int diag = dialog.ShowModal();
|
||||
|
||||
|
@ -38,12 +42,13 @@ void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
|
|||
|
||||
|
||||
HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent,
|
||||
EDA_HOTKEY_CONFIG* aHotkeys ) :
|
||||
EDA_HOTKEY_CONFIG* aHotkeys, EDA_HOTKEY_CONFIG* aShowHotkeys ) :
|
||||
HOTKEYS_EDITOR_DIALOG_BASE( aParent ),
|
||||
m_hotkeys( aHotkeys )
|
||||
m_hotkeys( aHotkeys ),
|
||||
m_showhotkeys( aShowHotkeys )
|
||||
{
|
||||
m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys,
|
||||
WIDGET_HOTKEY_LIST::GenSections( aHotkeys ) );
|
||||
WIDGET_HOTKEY_LIST::GenSections( aShowHotkeys ) );
|
||||
m_hotkeyListCtrl->InstallOnPanel( m_panelHotkeys );
|
||||
|
||||
m_sdbSizerOK->SetDefault();
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <macros.h>
|
||||
#include <dialog_hotkeys_editor.h>
|
||||
#include <menus_helpers.h>
|
||||
#include <draw_frame.h>
|
||||
#include <tool/tool_manager.h>
|
||||
|
||||
#include <wx/apptrait.h>
|
||||
|
@ -570,6 +571,12 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
|
|||
else
|
||||
{
|
||||
wxString configName( ConfigBaseName() );
|
||||
if( configName == SCH_EDIT_FRAME_NAME || configName == LIB_EDIT_FRAME_NAME )
|
||||
configName = EESCHEMA_HOTKEY_NAME;
|
||||
else if( configName == PCB_EDIT_FRAME_NAME ||
|
||||
configName == FOOTPRINT_EDIT_FRAME_NAME )
|
||||
configName = PCBNEW_HOTKEY_NAME;
|
||||
|
||||
wxFileName fn( configName );
|
||||
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
|
||||
fn.SetPath( GetKicadConfigPath() );
|
||||
|
@ -624,7 +631,7 @@ int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* a
|
|||
data.Replace( "\\n", "\n", true );
|
||||
|
||||
// parse
|
||||
ParseHotkeyConfig( data, aDescList );
|
||||
ParseHotkeyConfig( data, aDescList, aFilename );
|
||||
|
||||
// cleanup
|
||||
cfgfile.Close();
|
||||
|
@ -634,6 +641,20 @@ int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* a
|
|||
|
||||
int ReadHotkeyConfig( const wxString& aAppname, struct EDA_HOTKEY_CONFIG* aDescList )
|
||||
{
|
||||
// For Eeschema and Pcbnew frames, we try twice.
|
||||
// The first time, we try to read the new combined file. If it doesn't exist,
|
||||
// we fall back to reading the old, frame-based file
|
||||
if( aAppname == LIB_EDIT_FRAME_NAME || aAppname == SCH_EDIT_FRAME_NAME )
|
||||
{
|
||||
if( ReadHotkeyConfigFile( EESCHEMA_HOTKEY_NAME, aDescList ) )
|
||||
return 1;
|
||||
}
|
||||
else if( aAppname == PCB_EDIT_FRAME_NAME || aAppname == FOOTPRINT_EDIT_FRAME_NAME )
|
||||
{
|
||||
if( ReadHotkeyConfigFile( PCBNEW_HOTKEY_NAME, aDescList ) )
|
||||
return 1;
|
||||
}
|
||||
|
||||
return ReadHotkeyConfigFile( aAppname, aDescList );
|
||||
}
|
||||
|
||||
|
@ -644,7 +665,8 @@ int ReadHotkeyConfig( const wxString& aAppname, struct EDA_HOTKEY_CONFIG* aDescL
|
|||
* lines like [xxx] are tags (example: [common] or [libedit] which identify sections
|
||||
*/
|
||||
void ParseHotkeyConfig( const wxString& data,
|
||||
struct EDA_HOTKEY_CONFIG* aDescList )
|
||||
struct EDA_HOTKEY_CONFIG* aDescList,
|
||||
const wxString& aAppname )
|
||||
{
|
||||
// Read the config
|
||||
wxStringTokenizer tokenizer( data, L"\r\n", wxTOKEN_STRTOK );
|
||||
|
@ -677,6 +699,19 @@ void ParseHotkeyConfig( const wxString& data,
|
|||
continue;
|
||||
}
|
||||
|
||||
// Do not accept hotkey assignments from hotkey files that don't match the application
|
||||
if( aAppname == LIB_EDIT_FRAME_NAME && line_type == wxT( "[eeschema]" ) )
|
||||
CurrentHotkeyList = nullptr;
|
||||
|
||||
if( aAppname == SCH_EDIT_FRAME_NAME && line_type == wxT( "[libedit]" ) )
|
||||
CurrentHotkeyList = nullptr;
|
||||
|
||||
if( aAppname == PCB_EDIT_FRAME_NAME && line_type == wxT( "[footprinteditor]" ) )
|
||||
CurrentHotkeyList = nullptr;
|
||||
|
||||
if( aAppname == FOOTPRINT_EDIT_FRAME_NAME && line_type == wxT( "[pcbnew]" ) )
|
||||
CurrentHotkeyList = nullptr;
|
||||
|
||||
if( line_type == wxT( "$Endlist" ) )
|
||||
break;
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS( SCH_EDIT_FRAME* parent ) :
|
|||
m_scaleSlider->SetStep( 25 );
|
||||
|
||||
// Embed the hotkeys list
|
||||
HOTKEY_SECTIONS sections = WIDGET_HOTKEY_LIST::GenSections( g_Eeschema_Hokeys_Descr );
|
||||
HOTKEY_SECTIONS sections = WIDGET_HOTKEY_LIST::GenSections( g_Schematic_Hokeys_Descr );
|
||||
m_hotkeyListCtrl = new WIDGET_HOTKEY_LIST( m_panelHotkeys, sections );
|
||||
m_hotkeyListCtrl->InstallOnPanel( m_panelHotkeys );
|
||||
|
||||
|
|
|
@ -135,7 +135,7 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
{
|
||||
// Hotkey IDs
|
||||
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
|
||||
InstallHotkeyFrame( this, g_Eeschema_Hokeys_Descr );
|
||||
InstallHotkeyFrame( this, g_Eeschema_Hokeys_Descr, g_Libedit_Hokeys_Descr );
|
||||
break;
|
||||
|
||||
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
|
||||
|
@ -206,7 +206,7 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
|
||||
InstallHotkeyFrame( this, g_Eeschema_Hokeys_Descr );
|
||||
InstallHotkeyFrame( this, g_Eeschema_Hokeys_Descr, g_Schematic_Hokeys_Descr );
|
||||
break;
|
||||
|
||||
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
|
||||
|
@ -514,6 +514,7 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
|
||||
long tmp;
|
||||
|
||||
ReadHotkeyConfig( SCH_EDIT_FRAME_NAME, g_Schematic_Hokeys_Descr );
|
||||
wxConfigLoadSetups( aCfg, GetConfigurationSettings() );
|
||||
|
||||
SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) );
|
||||
|
@ -682,6 +683,8 @@ void LIB_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
|||
{
|
||||
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
||||
|
||||
ReadHotkeyConfig( LIB_EDIT_FRAME_NAME, g_Libedit_Hokeys_Descr );
|
||||
|
||||
SetGridColor( GetLayerColor( LAYER_SCHEMATIC_GRID ) );
|
||||
SetDrawBgColor( GetLayerColor( LAYER_SCHEMATIC_BACKGROUND ) );
|
||||
|
||||
|
|
|
@ -202,8 +202,6 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
|
|||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#define LIB_EDIT_FRAME_NAME wxT( "LibeditFrame" )
|
||||
|
||||
LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
SCH_BASE_FRAME( aKiway, aParent, FRAME_SCH_LIB_EDITOR, _( "Library Editor" ),
|
||||
wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, LIB_EDIT_FRAME_NAME )
|
||||
|
|
|
@ -110,8 +110,6 @@ enum SCH_SEARCH_T {
|
|||
};
|
||||
|
||||
|
||||
#define SCH_EDIT_FRAME_NAME wxT( "SchematicFrame" )
|
||||
|
||||
/**
|
||||
* Schematic editor (Eeschema) main window.
|
||||
*/
|
||||
|
|
|
@ -41,6 +41,7 @@ class HOTKEYS_EDITOR_DIALOG : public HOTKEYS_EDITOR_DIALOG_BASE
|
|||
{
|
||||
protected:
|
||||
struct EDA_HOTKEY_CONFIG* m_hotkeys;
|
||||
struct EDA_HOTKEY_CONFIG* m_showhotkeys;
|
||||
|
||||
WIDGET_HOTKEY_LIST* m_hotkeyListCtrl;
|
||||
|
||||
|
@ -53,7 +54,8 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys );
|
||||
HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys,
|
||||
EDA_HOTKEY_CONFIG* aShowHotkeys );
|
||||
|
||||
~HOTKEYS_EDITOR_DIALOG() {};
|
||||
|
||||
|
@ -81,8 +83,10 @@ private:
|
|||
* Create a hotkey editor dialog window with the provided hotkey configuration array
|
||||
*
|
||||
* @param aParent is the parent window
|
||||
* @param aHotkeys is the hotkey configuration array
|
||||
* @param aHotkeys is the hotkey configuration array for read/writing
|
||||
* @param aShowHotkeys is the hotkey configuration array that is displayed (subset)
|
||||
*/
|
||||
void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys );
|
||||
void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys,
|
||||
EDA_HOTKEY_CONFIG* aShowHotkeys = NULL );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,6 +46,14 @@ namespace KIGFX
|
|||
|
||||
#define DEFAULT_MAX_UNDO_ITEMS 0
|
||||
#define ABS_MAX_UNDO_ITEMS (INT_MAX / 2)
|
||||
#define LIB_EDIT_FRAME_NAME wxT( "LibeditFrame" )
|
||||
#define SCH_EDIT_FRAME_NAME wxT( "SchematicFrame" )
|
||||
#define PL_EDITOR_FRAME_NAME wxT( "PlEditorFrame" )
|
||||
#define FOOTPRINT_WIZARD_FRAME_NAME wxT( "FootprintWizard" )
|
||||
#define FOOTPRINT_EDIT_FRAME_NAME wxT( "ModEditFrame" )
|
||||
#define FOOTPRINT_VIEWER_FRAME_NAME wxT( "ModViewFrame" )
|
||||
#define FOOTPRINT_VIEWER_FRAME_NAME_MODAL wxT( "ModViewFrameModal" )
|
||||
#define PCB_EDIT_FRAME_NAME wxT( "PcbFrame" )
|
||||
|
||||
/**
|
||||
* Class EDA_DRAW_FRAME
|
||||
|
|
|
@ -283,13 +283,6 @@ public:
|
|||
|
||||
// Read/Save and Import/export hotkeys config
|
||||
|
||||
/**
|
||||
* Function ReadHotkeyConfig
|
||||
* Read configuration data and fill the current hotkey list with hotkeys
|
||||
* @param aDescList = current hotkey list descr. to initialize.
|
||||
*/
|
||||
int ReadHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList );
|
||||
|
||||
/**
|
||||
* Function WriteHotkeyConfig
|
||||
* Store the current hotkey list
|
||||
|
@ -303,15 +296,6 @@ public:
|
|||
*/
|
||||
virtual int WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList, wxString* aFullFileName = NULL );
|
||||
|
||||
/**
|
||||
* Function ReadHotkeyConfigFile
|
||||
* Read an old configuration file (<file>.key) and fill the current hotkey list
|
||||
* with hotkeys
|
||||
* @param aFilename = file name to read.
|
||||
* @param aDescList = current hotkey list descr. to initialize.
|
||||
*/
|
||||
int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* aDescList );
|
||||
|
||||
/**
|
||||
* Function ImportHotkeyConfigFromFile
|
||||
* Prompt the user for an old hotkey file to read, and read it.
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include <common.h>
|
||||
|
||||
#define DEFAULT_HOTKEY_FILENAME_EXT wxT( "hotkeys" )
|
||||
#define EESCHEMA_HOTKEY_NAME wxT( "Eeschema" )
|
||||
#define PCBNEW_HOTKEY_NAME wxT( "PcbNew" )
|
||||
|
||||
// A define to allow translation of Hot Key message Info in hotkey help menu
|
||||
// We do not want to use the _( x ) usual macro from wxWidgets, which calls wxGetTranslation(),
|
||||
|
@ -218,7 +220,6 @@ EDA_HOTKEY* GetDescriptorFromHotkey( int aKey, EDA_HOTKEY** aList );
|
|||
*/
|
||||
EDA_HOTKEY* GetDescriptorFromCommand( int aCommand, EDA_HOTKEY** aList );
|
||||
|
||||
|
||||
/**
|
||||
* Function ReadHotkeyConfig
|
||||
* Read hotkey configuration for a given app,
|
||||
|
@ -239,7 +240,15 @@ int ReadHotkeyConfigFile( const wxString& aFilename, struct EDA_HOTKEY_CONFIG* a
|
|||
*/
|
||||
int ReadHotkeyConfig( const wxString& aAppname, struct EDA_HOTKEY_CONFIG* aDescList );
|
||||
|
||||
void ParseHotkeyConfig( const wxString& data, struct EDA_HOTKEY_CONFIG* aDescList );
|
||||
/**
|
||||
* Function ParseHotkeyConfig
|
||||
* Translates hotkey string data into application hotkeys
|
||||
* @param data The string of data read from the configuration files
|
||||
* @param aDescList The list of hotkeys to update
|
||||
* @param aAppname The application interface requesting hotkey updates or empty for all
|
||||
*/
|
||||
void ParseHotkeyConfig( const wxString& data, struct EDA_HOTKEY_CONFIG* aDescList,
|
||||
const wxString& aAppname );
|
||||
|
||||
|
||||
// common hotkeys event id
|
||||
|
|
|
@ -46,7 +46,6 @@ class WORKSHEET_DATAITEM;
|
|||
* Class PL_EDITOR_FRAME
|
||||
* is the main window used in the page layout editor.
|
||||
*/
|
||||
#define PL_EDITOR_FRAME_NAME wxT( "PlEditorFrame" )
|
||||
|
||||
class PL_EDITOR_FRAME : public EDA_DRAW_FRAME
|
||||
{
|
||||
|
|
|
@ -214,7 +214,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_EDIT_FRAME, PCB_BASE_FRAME )
|
|||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#define FOOTPRINT_EDIT_FRAME_NAME wxT( "ModEditFrame" )
|
||||
|
||||
FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||
PCB_BASE_EDIT_FRAME( aKiway, aParent, FRAME_PCB_MODULE_EDITOR, wxEmptyString,
|
||||
|
@ -833,7 +832,7 @@ void FOOTPRINT_EDIT_FRAME::ProcessPreferences( wxCommandEvent& event )
|
|||
break;
|
||||
|
||||
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
|
||||
InstallHotkeyFrame( this, g_Module_Editor_Hotkeys_Descr );
|
||||
InstallHotkeyFrame( this, g_Pcbnew_Editor_Hotkeys_Descr, g_Module_Editor_Hotkeys_Descr );
|
||||
break;
|
||||
|
||||
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
|
||||
|
|
|
@ -124,9 +124,6 @@ END_EVENT_TABLE()
|
|||
#define MODAL_MODE_EXTRASTYLE wxFRAME_FLOAT_ON_PARENT
|
||||
#endif
|
||||
|
||||
#define FOOTPRINT_VIEWER_FRAME_NAME "ModViewFrame"
|
||||
#define FOOTPRINT_VIEWER_FRAME_NAME_MODAL "ModViewFrameModal"
|
||||
|
||||
|
||||
FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType ) :
|
||||
PCB_BASE_FRAME( aKiway, aParent, aFrameType, _( "Footprint Library Browser" ),
|
||||
|
|
|
@ -91,8 +91,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
|
|||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
#define FOOTPRINT_WIZARD_FRAME_NAME wxT( "FootprintWizard" )
|
||||
|
||||
/* Note: our FOOTPRINT_WIZARD_FRAME is always modal.
|
||||
* Note:
|
||||
* On windows, when the frame with type wxFRAME_FLOAT_ON_PARENT is displayed
|
||||
|
|
|
@ -71,7 +71,6 @@ namespace PCB { struct IFACE; } // KIFACE_I is in pcbnew.cpp
|
|||
*
|
||||
* See also class PCB_BASE_FRAME(): Basic class for Pcbnew and GerbView.
|
||||
*/
|
||||
#define PCB_EDIT_FRAME_NAME wxT( "PcbFrame" )
|
||||
|
||||
|
||||
class PCB_EDIT_FRAME : public PCB_BASE_EDIT_FRAME
|
||||
|
|
|
@ -217,15 +217,15 @@ void PCB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
|||
|
||||
// Hotkey IDs
|
||||
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
|
||||
ExportHotkeyConfigToFile( g_Board_Editor_Hotkeys_Descr, wxT( "pcbnew" ) );
|
||||
ExportHotkeyConfigToFile( g_Pcbnew_Editor_Hotkeys_Descr, wxT( "pcbnew" ) );
|
||||
break;
|
||||
|
||||
case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
|
||||
ImportHotkeyConfigFromFile( g_Board_Editor_Hotkeys_Descr, wxT( "pcbnew" ) );
|
||||
ImportHotkeyConfigFromFile( g_Pcbnew_Editor_Hotkeys_Descr, wxT( "pcbnew" ) );
|
||||
break;
|
||||
|
||||
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
|
||||
InstallHotkeyFrame( this, g_Board_Editor_Hotkeys_Descr );
|
||||
InstallHotkeyFrame( this, g_Pcbnew_Editor_Hotkeys_Descr, g_Board_Editor_Hotkeys_Descr );
|
||||
break;
|
||||
|
||||
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
|
||||
|
|
Loading…
Reference in New Issue