Performance enhancements for hotkeys.
Fixes https://gitlab.com/kicad/code/kicad/issues/11592
This commit is contained in:
parent
857990a883
commit
7ede2c70bd
|
@ -247,16 +247,18 @@ int ACTION_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const
|
||||||
|
|
||||||
void ACTION_MANAGER::UpdateHotKeys( bool aFullUpdate )
|
void ACTION_MANAGER::UpdateHotKeys( bool aFullUpdate )
|
||||||
{
|
{
|
||||||
std::map<std::string, int> legacyHotKeyMap;
|
static std::map<std::string, int> legacyHotKeyMap;
|
||||||
std::map<std::string, int> userHotKeyMap;
|
static std::map<std::string, int> userHotKeyMap;
|
||||||
|
static bool mapsInitialized = false;
|
||||||
|
|
||||||
m_actionHotKeys.clear();
|
m_actionHotKeys.clear();
|
||||||
m_hotkeys.clear();
|
m_hotkeys.clear();
|
||||||
|
|
||||||
if( aFullUpdate && m_toolMgr->GetToolHolder() )
|
if( aFullUpdate && !mapsInitialized && m_toolMgr->GetToolHolder() )
|
||||||
{
|
{
|
||||||
ReadLegacyHotkeyConfig( m_toolMgr->GetToolHolder()->ConfigBaseName(), legacyHotKeyMap );
|
ReadLegacyHotkeyConfig( m_toolMgr->GetToolHolder()->ConfigBaseName(), legacyHotKeyMap );
|
||||||
ReadHotKeyConfig( wxEmptyString, userHotKeyMap );
|
ReadHotKeyConfig( wxEmptyString, userHotKeyMap );
|
||||||
|
mapsInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const auto& ii : m_actionNameIndex )
|
for( const auto& ii : m_actionNameIndex )
|
||||||
|
@ -277,16 +279,17 @@ void ACTION_MANAGER::UpdateHotKeys( bool aFullUpdate )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ACTION_MANAGER::processHotKey( TOOL_ACTION* aAction, std::map<std::string, int> aLegacyMap,
|
int ACTION_MANAGER::processHotKey( TOOL_ACTION* aAction,
|
||||||
std::map<std::string, int> aHotKeyMap )
|
const std::map<std::string, int>& aLegacyMap,
|
||||||
|
const std::map<std::string, int>& aHotKeyMap )
|
||||||
{
|
{
|
||||||
aAction->m_hotKey = aAction->m_defaultHotKey;
|
aAction->m_hotKey = aAction->m_defaultHotKey;
|
||||||
|
|
||||||
if( !aAction->m_legacyName.empty() && aLegacyMap.count( aAction->m_legacyName ) )
|
if( !aAction->m_legacyName.empty() && aLegacyMap.count( aAction->m_legacyName ) )
|
||||||
aAction->SetHotKey( aLegacyMap[ aAction->m_legacyName ] );
|
aAction->SetHotKey( aLegacyMap.at( aAction->m_legacyName ) );
|
||||||
|
|
||||||
if( aHotKeyMap.count( aAction->m_name ) )
|
if( aHotKeyMap.count( aAction->m_name ) )
|
||||||
aAction->SetHotKey( aHotKeyMap[ aAction->m_name ] );
|
aAction->SetHotKey( aHotKeyMap.at( aAction->m_name ) );
|
||||||
|
|
||||||
return aAction->m_hotKey;
|
return aAction->m_hotKey;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,8 +175,8 @@ public:
|
||||||
private:
|
private:
|
||||||
// Resolve a hotkey by applying legacy and current settings over the action's
|
// Resolve a hotkey by applying legacy and current settings over the action's
|
||||||
// default hotkey.
|
// default hotkey.
|
||||||
int processHotKey( TOOL_ACTION* aAction, std::map<std::string, int> aLegacyMap,
|
int processHotKey( TOOL_ACTION* aAction, const std::map<std::string, int>& aLegacyMap,
|
||||||
std::map<std::string, int> aHotKeyMap );
|
const std::map<std::string, int>& aHotKeyMap );
|
||||||
|
|
||||||
///< Tool manager needed to run actions
|
///< Tool manager needed to run actions
|
||||||
TOOL_MANAGER* m_toolMgr;
|
TOOL_MANAGER* m_toolMgr;
|
||||||
|
|
Loading…
Reference in New Issue