Commit 2804d2e5 authored by jean-pierre charras's avatar jean-pierre charras
Browse files

Add hotkeys to Kicad manager, and some rework on hotkeys management.

parent 399ab4ba
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
/*
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 *
 * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
 * Copyright (C) 2015 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
 * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
 * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
 *
 *
 * This program is free software; you can redistribute it and/or
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * modify it under the terms of the GNU General Public License
@@ -225,7 +225,7 @@ bool EDA_ITEM::operator<( const EDA_ITEM& aItem ) const
    return false;
    return false;
}
}



#ifdef USE_EDA_ITEM_OP_EQ   // see base_struct.h for explanations
EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )
{
{
    if( &aItem != this )
    if( &aItem != this )
@@ -241,7 +241,7 @@ EDA_ITEM& EDA_ITEM::operator=( const EDA_ITEM& aItem )


    return *this;
    return *this;
}
}

#endif


const BOX2I EDA_ITEM::ViewBBox() const
const BOX2I EDA_ITEM::ViewBBox() const
{
{
+2 −2
Original line number Original line Diff line number Diff line
@@ -251,7 +251,7 @@ void HOTKEY_SECTION_PAGE::Restore()
}
}




void InstallHotkeyFrame( EDA_DRAW_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
void InstallHotkeyFrame( EDA_BASE_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
{
{
    HOTKEYS_EDITOR_DIALOG dialog( aParent, aHotkeys );
    HOTKEYS_EDITOR_DIALOG dialog( aParent, aHotkeys );


@@ -264,7 +264,7 @@ void InstallHotkeyFrame( EDA_DRAW_FRAME* aParent, EDA_HOTKEY_CONFIG* aHotkeys )
}
}




HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_DRAW_FRAME*    aParent,
HOTKEYS_EDITOR_DIALOG::HOTKEYS_EDITOR_DIALOG( EDA_BASE_FRAME*    aParent,
                                              EDA_HOTKEY_CONFIG* aHotkeys ) :
                                              EDA_HOTKEY_CONFIG* aHotkeys ) :
    HOTKEYS_EDITOR_DIALOG_BASE( aParent ),
    HOTKEYS_EDITOR_DIALOG_BASE( aParent ),
    m_parent( aParent ),
    m_parent( aParent ),
+24 −14
Original line number Original line Diff line number Diff line
@@ -419,7 +419,7 @@ int KeyCodeFromKeyName( const wxString& keyname )
 * Displays the current hotkey list
 * Displays the current hotkey list
 * aList = a EDA_HOTKEY_CONFIG list(Null terminated)
 * aList = a EDA_HOTKEY_CONFIG list(Null terminated)
 */
 */
void DisplayHotkeyList( EDA_DRAW_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescList )
void DisplayHotkeyList( EDA_BASE_FRAME* aFrame, struct EDA_HOTKEY_CONFIG* aDescList )
{
{
    wxString     keyname;
    wxString     keyname;
    EDA_HOTKEY** list;
    EDA_HOTKEY** list;
@@ -534,7 +534,9 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
    }
    }
    else
    else
    {
    {
        wxConfigBase* config = GetNewConfig( m_FrameName );
        wxFileName fn( m_FrameName );
        fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
        wxConfigBase* config = GetNewConfig( fn.GetFullPath() );
        config->Write( HOTKEYS_CONFIG_KEY, msg );
        config->Write( HOTKEYS_CONFIG_KEY, msg );
        delete config;
        delete config;
    }
    }
@@ -546,7 +548,10 @@ int EDA_BASE_FRAME::WriteHotkeyConfig( struct EDA_HOTKEY_CONFIG* aDescList,
int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString&           aFilename,
int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString&           aFilename,
                                          struct EDA_HOTKEY_CONFIG* aDescList )
                                          struct EDA_HOTKEY_CONFIG* aDescList )
{
{
    wxFile cfgfile( aFilename );
    wxFileName fn( aFilename );
    fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );

    wxFile cfgfile( fn.GetFullPath() );


    if( !cfgfile.IsOpened() )       // There is a problem to open file
    if( !cfgfile.IsOpened() )       // There is a problem to open file
        return 0;
        return 0;
@@ -574,7 +579,10 @@ int EDA_BASE_FRAME::ReadHotkeyConfigFile( const wxString& aFilename,


void ReadHotkeyConfig( const wxString& Appname, struct EDA_HOTKEY_CONFIG* aDescList )
void ReadHotkeyConfig( const wxString& Appname, struct EDA_HOTKEY_CONFIG* aDescList )
{
{
    wxConfigBase* config = GetNewConfig( Appname );
    wxFileName fn( Appname );
    fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );

    wxConfigBase* config = GetNewConfig( fn.GetFullPath() );


    if( !config->HasEntry( HOTKEYS_CONFIG_KEY ) )
    if( !config->HasEntry( HOTKEYS_CONFIG_KEY ) )
    {
    {
@@ -677,7 +685,8 @@ void ParseHotkeyConfig( const wxString& data,
}
}




void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList )
void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList,
                                            const wxString& aDefaultShortname )
{
{
    wxString ext  = DEFAULT_HOTKEY_FILENAME_EXT;
    wxString ext  = DEFAULT_HOTKEY_FILENAME_EXT;
    wxString mask = wxT( "*." ) + ext;
    wxString mask = wxT( "*." ) + ext;
@@ -687,12 +696,12 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList )
#else
#else
    wxString path = wxGetCwd();
    wxString path = wxGetCwd();
#endif
#endif
    wxFileName fn( aDefaultShortname );
    fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );


    wxString filename = Kiface().Name() + wxT( '.' ) + ext;
    wxString  filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ),

    filename = EDA_FileSelector( _( "Read Hotkey Configuration File:" ),
                                 path,
                                 path,
                                 filename,
                                 fn.GetFullPath(),
                                 ext,
                                 ext,
                                 mask,
                                 mask,
                                 this,
                                 this,
@@ -706,7 +715,8 @@ void EDA_BASE_FRAME::ImportHotkeyConfigFromFile( EDA_HOTKEY_CONFIG* aDescList )
}
}




void EDA_BASE_FRAME::ExportHotkeyConfigToFile( EDA_HOTKEY_CONFIG* aDescList )
void EDA_BASE_FRAME::ExportHotkeyConfigToFile( EDA_HOTKEY_CONFIG* aDescList,
                                        const wxString& aDefaultShortname )
{
{
    wxString ext  = DEFAULT_HOTKEY_FILENAME_EXT;
    wxString ext  = DEFAULT_HOTKEY_FILENAME_EXT;
    wxString mask = wxT( "*." ) + ext;
    wxString mask = wxT( "*." ) + ext;
@@ -716,12 +726,12 @@ void EDA_BASE_FRAME::ExportHotkeyConfigToFile( EDA_HOTKEY_CONFIG* aDescList )
#else
#else
    wxString path = wxGetCwd();
    wxString path = wxGetCwd();
#endif
#endif
    wxFileName fn( aDefaultShortname );
    fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );


    wxString filename = Kiface().Name() + wxT( "." ) + ext;
    wxString filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ),

    filename = EDA_FileSelector( _( "Write Hotkey Configuration File:" ),
                                 path,
                                 path,
                                 filename,
                                 fn.GetFullPath(),
                                 ext,
                                 ext,
                                 mask,
                                 mask,
                                 this,
                                 this,
+1 −1
Original line number Original line Diff line number Diff line
@@ -229,7 +229,7 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )


    // Must be called before creating the main frame in order to
    // Must be called before creating the main frame in order to
    // display the real hotkeys in menus or tool tips
    // display the real hotkeys in menus or tool tips
    ReadHotkeyConfig( wxT("SchematicFrame"), g_Eeschema_Hokeys_Descr );
    ReadHotkeyConfig( SCH_EDIT_FRAME_NAME, g_Eeschema_Hokeys_Descr );


    wxConfigLoadSetups( KifaceSettings(), cfg_params() );
    wxConfigLoadSetups( KifaceSettings(), cfg_params() );


+4 −4
Original line number Original line Diff line number Diff line
@@ -177,11 +177,11 @@ void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
        break;
        break;


    case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
    case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
        ExportHotkeyConfigToFile( g_Eeschema_Hokeys_Descr );
        ExportHotkeyConfigToFile( g_Eeschema_Hokeys_Descr, wxT( "eeschema" ) );
        break;
        break;


    case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
    case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
        ImportHotkeyConfigFromFile( g_Eeschema_Hokeys_Descr );
        ImportHotkeyConfigFromFile( g_Eeschema_Hokeys_Descr, wxT( "eeschema" ) );
        break;
        break;


    case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
    case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
@@ -282,11 +282,11 @@ void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )


    // Hotkey IDs
    // Hotkey IDs
    case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
    case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
        ExportHotkeyConfigToFile( g_Eeschema_Hokeys_Descr );
        ExportHotkeyConfigToFile( g_Eeschema_Hokeys_Descr, wxT( "eeschema" ) );
        break;
        break;


    case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
    case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
        ImportHotkeyConfigFromFile( g_Eeschema_Hokeys_Descr );
        ImportHotkeyConfigFromFile( g_Eeschema_Hokeys_Descr, wxT( "eeschema" ) );
        break;
        break;


    case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
    case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
Loading