Radium Engine
1.5.20
|
An utility class used to map a (combination of) key / modifiers / mouse buttons to a specific action. Configuration can be loaded/saved to files, or use dynamic binding management. See KeyMapping API documentation for detailed concept and usage description. More...
#include <Gui/Utils/KeyMappingManager.hpp>
Classes | |
class | EventBinding |
Inner class to store event binding. More... | |
Public Types | |
using | KeyMappingAction = Ra::Core::Utils::Index |
handle to an action | |
using | Context = Ra::Core::Utils::Index |
handle to a Context | |
Public Member Functions | |
void | loadConfiguration (const std::string &filename={}) |
bool | saveConfiguration (const std::string &filename={}) |
void | reloadConfiguration () |
reload last open file. | |
std::string | getLoadedFilename () |
KeyMappingAction | getAction (const Context &context, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key, bool wheel=false) |
KeyMappingAction | getAction (const Context &context, const QEvent *event, int key, bool wheel=false) |
KeyMappingAction | getAction (const Context &context, const EventBinding &binding) |
std::optional< EventBinding > | getBinding (const Context &context, KeyMappingAction action) |
KeyMappingAction | addAction (const Context &context, const std::string &actionName) |
KeyMappingAction | addAction (const Context &context, const EventBinding &binding, const std::string &actionName) |
void | setActionBinding (const Context &context, const EventBinding &binding, const KeyMappingAction &action) |
Bind binding to action, in context. | |
Context | addContext (const std::string &contextName) |
Creates the context index for the given context name. | |
Context | getContext (const std::string &contextName) |
KeyMappingAction | getAction (const Context &context, const std::string &actionName) |
std::string | getActionName (const Context &context, const KeyMappingAction &action) |
std::string | getContextName (const Context &context) |
int | addListener (Observable::Observer callback) |
Add a callback, triggered when configuration is load or reloaded. | |
void | removeListener (int callbackId) |
std::string | getHelpText () |
Return a string corresponding to the current dom document. | |
Static Public Member Functions | |
static std::string | enumNamesFromMouseButtons (const Qt::MouseButtons &buttons) |
static std::string | enumNamesFromKeyboardModifiers (const Qt::KeyboardModifiers &modifiers) |
static EventBinding | createEventBindingFromStrings (const std::string &buttonsString="", const std::string &modifiersString="", const std::string &keyString="", const std::string &wheelString="") |
An utility class used to map a (combination of) key / modifiers / mouse buttons to a specific action. Configuration can be loaded/saved to files, or use dynamic binding management. See KeyMapping API documentation for detailed concept and usage description.
Definition at line 22 of file KeyMappingManager.hpp.
using Ra::Gui::KeyMappingManager::Context = Ra::Core::Utils::Index |
handle to a Context
Definition at line 79 of file KeyMappingManager.hpp.
using Ra::Gui::KeyMappingManager::KeyMappingAction = Ra::Core::Utils::Index |
handle to an action
Definition at line 78 of file KeyMappingManager.hpp.
KeyMappingManager::KeyMappingAction Ra::Gui::KeyMappingManager::addAction | ( | const Context & | context, |
const EventBinding & | binding, | ||
const std::string & | actionName ) |
Add an action from its name, with the given binding. If the actionName was already present, the privously added action is returned.
Definition at line 409 of file KeyMappingManager.cpp.
KeyMappingManager::KeyMappingAction Ra::Gui::KeyMappingManager::addAction | ( | const Context & | context, |
const std::string & | actionName ) |
Add an action from its name. If the actionName was already present, the privously added action is returned.
Definition at line 396 of file KeyMappingManager.cpp.
KeyMappingManager::Context Ra::Gui::KeyMappingManager::addContext | ( | const std::string & | contextName | ) |
Creates the context index for the given context name.
If the context already exist, return the existing index. If not, the context is created and its index is returned.
contextName | the name of the context |
Definition at line 85 of file KeyMappingManager.cpp.
int Ra::Gui::KeyMappingManager::addListener | ( | Observable::Observer | callback | ) |
Add a callback, triggered when configuration is load or reloaded.
Definition at line 159 of file KeyMappingManager.cpp.
|
static |
EventBinding factory from string description of buttons, modifiers, key and wheel.
Definition at line 591 of file KeyMappingManager.cpp.
|
static |
return a string of enum names from keyboard modifiers, comma separated, without space.
Definition at line 572 of file KeyMappingManager.cpp.
|
static |
return a string of enum names from mouse buttons, comma separated, without space.
Definition at line 534 of file KeyMappingManager.cpp.
KeyMappingManager::KeyMappingAction Ra::Gui::KeyMappingManager::getAction | ( | const Context & | context, |
const EventBinding & | binding ) |
Definition at line 69 of file KeyMappingManager.cpp.
KeyMappingManager::KeyMappingAction Ra::Gui::KeyMappingManager::getAction | ( | const Context & | context, |
const QEvent * | event, | ||
int | key, | ||
bool | wheel = false ) |
Definition at line 33 of file KeyMappingManager.cpp.
KeyMappingManager::KeyMappingAction Ra::Gui::KeyMappingManager::getAction | ( | const Context & | context, |
const Qt::MouseButtons & | buttons, | ||
const Qt::KeyboardModifiers & | modifiers, | ||
int | key, | ||
bool | wheel = false ) |
Return the action associated to the binding buttons + modifiers + key
context | is the context to get action from (e.g. camera or gizmo) |
buttons | are the mouse buttons pressed, could be NoButton |
modifiers | are the keyboard modifiers, could be NoModifier |
key | is the key pressed, could be -1 |
wheel | specifies if we consider a wheel event |
Definition at line 49 of file KeyMappingManager.cpp.
KeyMappingManager::KeyMappingAction Ra::Gui::KeyMappingManager::getAction | ( | const Context & | context, |
const std::string & | actionName ) |
Return the action index corresponding to a context index and actionName
context | the index of the context |
actionName | the name of the action |
Definition at line 112 of file KeyMappingManager.cpp.
std::string Ra::Gui::KeyMappingManager::getActionName | ( | const Context & | context, |
const KeyMappingAction & | action ) |
Definition at line 132 of file KeyMappingManager.cpp.
std::optional< KeyMappingManager::EventBinding > Ra::Gui::KeyMappingManager::getBinding | ( | const Context & | context, |
KeyMappingAction | action ) |
Return, if exists, the event binding associated with a context/action. if such binding doesn't exists, the optional does not contain a value.
Definition at line 78 of file KeyMappingManager.cpp.
KeyMappingManager::Context Ra::Gui::KeyMappingManager::getContext | ( | const std::string & | contextName | ) |
Return the context index corresponding to contextName
contextName | the name of the context |
Definition at line 105 of file KeyMappingManager.cpp.
std::string Ra::Gui::KeyMappingManager::getContextName | ( | const Context & | context | ) |
Definition at line 149 of file KeyMappingManager.cpp.
std::string Ra::Gui::KeyMappingManager::getHelpText | ( | ) |
Return a string corresponding to the current dom document.
Definition at line 483 of file KeyMappingManager.cpp.
|
inline |
Definition at line 93 of file KeyMappingManager.hpp.
void Ra::Gui::KeyMappingManager::loadConfiguration | ( | const std::string & | filename = {} | ) |
load configuration from filename, or default configration filename. It calls listeners callbacks then.
Definition at line 230 of file KeyMappingManager.cpp.
void Ra::Gui::KeyMappingManager::reloadConfiguration | ( | ) |
reload last open file.
Definition at line 474 of file KeyMappingManager.cpp.
void Ra::Gui::KeyMappingManager::removeListener | ( | int | callbackId | ) |
Remove a callback. To be called when the related Context/Actions are no more needed.
callbackId | the Id, returned by addListener, of the Observer to be removed. |
Definition at line 167 of file KeyMappingManager.cpp.
bool Ra::Gui::KeyMappingManager::saveConfiguration | ( | const std::string & | filename = {} | ) |
Save the configuration
filename | the file to write to. It will be replaced |
Definition at line 273 of file KeyMappingManager.cpp.
void Ra::Gui::KeyMappingManager::setActionBinding | ( | const Context & | context, |
const EventBinding & | binding, | ||
const KeyMappingAction & | action ) |
Bind binding to action, in context.
It replaces previously binded action, with a warning if binding was already present.
Definition at line 171 of file KeyMappingManager.cpp.