Loading common/tool/action_manager.cpp +12 −0 Original line number Original line Diff line number Diff line Loading @@ -53,7 +53,13 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction ) m_actionIdIndex[aAction->m_id] = aAction; m_actionIdIndex[aAction->m_id] = aAction; if( aAction->HasHotKey() ) if( aAction->HasHotKey() ) { // Duplication of hot keys leads to unexpected behaviour // The right way to change a hotkey is to use ACTION_MANAGER::ClearHotKey() first assert( m_actionHotKeys.find( aAction->m_currentHotKey ) == m_actionHotKeys.end() ); m_actionHotKeys[aAction->m_currentHotKey] = aAction; m_actionHotKeys[aAction->m_currentHotKey] = aAction; } aAction->setActionMgr( this ); aAction->setActionMgr( this ); } } Loading Loading @@ -107,6 +113,12 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const } } void ACTION_MANAGER::ClearHotKey( int aHotKey ) { m_actionHotKeys.erase( aHotKey ); } void ACTION_MANAGER::runAction( const TOOL_ACTION* aAction ) const void ACTION_MANAGER::runAction( const TOOL_ACTION* aAction ) const { { TOOL_EVENT event = aAction->MakeEvent(); TOOL_EVENT event = aAction->MakeEvent(); Loading include/tool/action_manager.h +8 −5 Original line number Original line Diff line number Diff line Loading @@ -81,18 +81,21 @@ public: */ */ bool RunAction( const std::string& aActionName ) const; bool RunAction( const std::string& aActionName ) const; // TODO to be considered // bool RunAction( int aActionId ) const; // bool RunAction( TOOL_ACTION* aAction ) const; /** /** * Function RunHotKey() * Function RunHotKey() * Runs an action associated with a hotkey (if there is one available). * Runs an action associated with a hotkey (if there is one available). * @param aHotKey is the hotkey to be served. * @param aHotKey is the hotkey to be handled. * @return True if there was an action associated with the hotkey, false otherwise. * @return True if there was an action associated with the hotkey, false otherwise. */ */ bool RunHotKey( int aHotKey ) const; bool RunHotKey( int aHotKey ) const; /** * Function ClearHotKey() * Removes an action associated with a hotkey. * @param aHotKey is the hotkey to be cleared. */ void ClearHotKey( int aHotKey ); private: private: ///> Tool manager needed to run actions ///> Tool manager needed to run actions TOOL_MANAGER* m_toolMgr; TOOL_MANAGER* m_toolMgr; Loading Loading
common/tool/action_manager.cpp +12 −0 Original line number Original line Diff line number Diff line Loading @@ -53,7 +53,13 @@ void ACTION_MANAGER::RegisterAction( TOOL_ACTION* aAction ) m_actionIdIndex[aAction->m_id] = aAction; m_actionIdIndex[aAction->m_id] = aAction; if( aAction->HasHotKey() ) if( aAction->HasHotKey() ) { // Duplication of hot keys leads to unexpected behaviour // The right way to change a hotkey is to use ACTION_MANAGER::ClearHotKey() first assert( m_actionHotKeys.find( aAction->m_currentHotKey ) == m_actionHotKeys.end() ); m_actionHotKeys[aAction->m_currentHotKey] = aAction; m_actionHotKeys[aAction->m_currentHotKey] = aAction; } aAction->setActionMgr( this ); aAction->setActionMgr( this ); } } Loading Loading @@ -107,6 +113,12 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const } } void ACTION_MANAGER::ClearHotKey( int aHotKey ) { m_actionHotKeys.erase( aHotKey ); } void ACTION_MANAGER::runAction( const TOOL_ACTION* aAction ) const void ACTION_MANAGER::runAction( const TOOL_ACTION* aAction ) const { { TOOL_EVENT event = aAction->MakeEvent(); TOOL_EVENT event = aAction->MakeEvent(); Loading
include/tool/action_manager.h +8 −5 Original line number Original line Diff line number Diff line Loading @@ -81,18 +81,21 @@ public: */ */ bool RunAction( const std::string& aActionName ) const; bool RunAction( const std::string& aActionName ) const; // TODO to be considered // bool RunAction( int aActionId ) const; // bool RunAction( TOOL_ACTION* aAction ) const; /** /** * Function RunHotKey() * Function RunHotKey() * Runs an action associated with a hotkey (if there is one available). * Runs an action associated with a hotkey (if there is one available). * @param aHotKey is the hotkey to be served. * @param aHotKey is the hotkey to be handled. * @return True if there was an action associated with the hotkey, false otherwise. * @return True if there was an action associated with the hotkey, false otherwise. */ */ bool RunHotKey( int aHotKey ) const; bool RunHotKey( int aHotKey ) const; /** * Function ClearHotKey() * Removes an action associated with a hotkey. * @param aHotKey is the hotkey to be cleared. */ void ClearHotKey( int aHotKey ); private: private: ///> Tool manager needed to run actions ///> Tool manager needed to run actions TOOL_MANAGER* m_toolMgr; TOOL_MANAGER* m_toolMgr; Loading