Update hotkey maps when the hotkeys are edited.
Also removes some legacy code dealing with conflicts. Also disambiguates zoom in/out commands for hotkey list.
This commit is contained in:
parent
2348537769
commit
97d2800f16
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <hotkey_store.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tool/action_manager.h>
|
||||
#include <tool/tool_action.h>
|
||||
|
||||
|
||||
|
@ -115,6 +116,9 @@ void HOTKEY_STORE::SaveAllHotkeys()
|
|||
for( HOTKEY& hotkey: section.m_HotKeys )
|
||||
hotkey.m_Parent->SetHotKey( hotkey.m_EditKeycode );
|
||||
}
|
||||
|
||||
if( !m_toolManagers.empty() )
|
||||
m_toolManagers[ 0 ]->GetActionManager()->UpdateHotKeys( false );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -140,9 +140,7 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
|||
{
|
||||
if( action->GetScope() == AS_GLOBAL )
|
||||
{
|
||||
// Store the global action for the hot key in case there was no possible
|
||||
// context actions to run
|
||||
wxASSERT( global == NULL ); // there should be only one global action per hot key
|
||||
// Store the global action in case there are no context actions to run
|
||||
global = action;
|
||||
continue;
|
||||
}
|
||||
|
@ -195,41 +193,35 @@ int ACTION_MANAGER::GetHotKey( const TOOL_ACTION& aAction ) const
|
|||
}
|
||||
|
||||
|
||||
void ACTION_MANAGER::UpdateHotKeys()
|
||||
void ACTION_MANAGER::UpdateHotKeys( bool aFullUpdate )
|
||||
{
|
||||
std::map<std::string, int> legacyHotKeyMap;
|
||||
std::map<std::string, int> userHotKeyMap;
|
||||
|
||||
m_actionHotKeys.clear();
|
||||
m_hotkeys.clear();
|
||||
|
||||
ReadLegacyHotkeyConfig( m_toolMgr->GetEditFrame()->ConfigBaseName(), legacyHotKeyMap );
|
||||
ReadHotKeyConfig( wxEmptyString, userHotKeyMap );
|
||||
|
||||
if( aFullUpdate )
|
||||
{
|
||||
ReadLegacyHotkeyConfig( m_toolMgr->GetEditFrame()->ConfigBaseName(), legacyHotKeyMap );
|
||||
ReadHotKeyConfig( wxEmptyString, userHotKeyMap );
|
||||
}
|
||||
|
||||
for( const auto& actionName : m_actionNameIndex )
|
||||
{
|
||||
TOOL_ACTION* action = actionName.second;
|
||||
int hotkey = processHotKey( action, legacyHotKeyMap, userHotKeyMap );
|
||||
int hotkey = 0;
|
||||
|
||||
if( hotkey <= 0 )
|
||||
continue;
|
||||
if( aFullUpdate )
|
||||
hotkey = processHotKey( action, legacyHotKeyMap, userHotKeyMap );
|
||||
else
|
||||
hotkey = action->GetHotKey();
|
||||
|
||||
// Second hotkey takes priority as defaults are loaded first and updates
|
||||
// are loaded after
|
||||
if( action->GetScope() == AS_GLOBAL && m_actionHotKeys.count( hotkey ) )
|
||||
if( hotkey > 0 )
|
||||
{
|
||||
for( auto it = m_actionHotKeys[hotkey].begin();
|
||||
it != m_actionHotKeys[hotkey].end(); )
|
||||
{
|
||||
if( (*it)->GetScope() == AS_GLOBAL )
|
||||
it = m_actionHotKeys[hotkey].erase( it );
|
||||
else
|
||||
it++;
|
||||
}
|
||||
m_actionHotKeys[hotkey].push_back( action );
|
||||
m_hotkeys[action->GetId()] = hotkey;
|
||||
}
|
||||
|
||||
m_actionHotKeys[hotkey].push_back( action );
|
||||
m_hotkeys[action->GetId()] = hotkey;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ TOOL_ACTION ACTIONS::zoomIn( "common.Control.zoomIn",
|
|||
WXK_F1,
|
||||
#endif
|
||||
LEGACY_HK_NAME( "Zoom In" ),
|
||||
_( "Zoom In" ), "",
|
||||
_( "Zoom In at Cursor" ), "",
|
||||
zoom_in_xpm );
|
||||
|
||||
TOOL_ACTION ACTIONS::zoomOut( "common.Control.zoomOut",
|
||||
|
@ -246,7 +246,7 @@ TOOL_ACTION ACTIONS::zoomOut( "common.Control.zoomOut",
|
|||
WXK_F2,
|
||||
#endif
|
||||
LEGACY_HK_NAME( "Zoom Out" ),
|
||||
_( "Zoom Out" ), "",
|
||||
_( "Zoom Out at Cursor" ), "",
|
||||
zoom_out_xpm );
|
||||
|
||||
TOOL_ACTION ACTIONS::zoomInCenter( "common.Control.zoomInCenter",
|
||||
|
|
|
@ -322,12 +322,6 @@ int TOOL_MANAGER::GetHotKey( const TOOL_ACTION& aAction )
|
|||
}
|
||||
|
||||
|
||||
void TOOL_MANAGER::UpdateHotKeys()
|
||||
{
|
||||
m_actionMgr->UpdateHotKeys();
|
||||
}
|
||||
|
||||
|
||||
bool TOOL_MANAGER::invokeTool( TOOL_BASE* aTool )
|
||||
{
|
||||
wxASSERT( aTool != NULL );
|
||||
|
@ -469,7 +463,7 @@ void TOOL_MANAGER::InitTools()
|
|||
}
|
||||
}
|
||||
|
||||
m_actionMgr->UpdateHotKeys();
|
||||
m_actionMgr->UpdateHotKeys( true );
|
||||
|
||||
ResetTools( TOOL_BASE::RUN );
|
||||
}
|
||||
|
|
|
@ -103,10 +103,10 @@ public:
|
|||
int GetHotKey( const TOOL_ACTION& aAction ) const;
|
||||
|
||||
/**
|
||||
* Function ReadHotKeyConfig()
|
||||
* Updates TOOL_ACTIONs hot key assignment according to the current frame's Hot Key Editor settings.
|
||||
* Function UpdateHotKeys()
|
||||
* Optionally reads the hotkey config files and then rebuilds the internal hotkey maps.
|
||||
*/
|
||||
void UpdateHotKeys();
|
||||
void UpdateHotKeys( bool aFullUpdate );
|
||||
|
||||
/**
|
||||
* Function GetActionList()
|
||||
|
|
|
@ -163,8 +163,7 @@ public:
|
|||
///> @copydoc ACTION_MANAGER::GetHotKey()
|
||||
int GetHotKey( const TOOL_ACTION& aAction );
|
||||
|
||||
///> @copydoc ACTION_MANAGER::UpdateHotKeys()
|
||||
void UpdateHotKeys();
|
||||
ACTION_MANAGER* GetActionManager() { return m_actionMgr; }
|
||||
|
||||
/**
|
||||
* Function FindTool()
|
||||
|
|
Loading…
Reference in New Issue