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