41 Qt::KeyboardModifiers modifiers,
43 bool wheel =
false ) :
44 m_buttons { buttons }, m_modifiers { modifiers }, m_key { key }, m_wheel { wheel } {}
50 Qt::KeyboardModifiers modifiers = Qt::NoModifier ) :
51 m_buttons { buttons }, m_modifiers { modifiers } {}
56 explicit EventBinding(
int key, Qt::KeyboardModifiers modifiers = Qt::NoModifier ) :
57 m_modifiers { modifiers }, m_key { key } {}
62 explicit EventBinding(
bool wheel, Qt::KeyboardModifiers modifiers = Qt::NoModifier ) :
63 m_modifiers { modifiers }, m_wheel { wheel } {}
65 bool isMouseEvent() {
return m_buttons != Qt::NoButton; }
66 bool isWheelEvent() {
return m_wheel; }
67 bool isKeyEvent() {
return !isMouseEvent() && !isWheelEvent(); }
68 bool operator<(
const EventBinding& b )
const;
71 Qt::MouseButtons m_buttons { Qt::NoButton };
72 Qt::KeyboardModifiers m_modifiers { Qt::NoModifier };
75 bool m_wheel {
false };
83 void loadConfiguration(
const std::string& filename = {} );
88 bool saveConfiguration(
const std::string& filename = {} );
91 void reloadConfiguration();
93 std::string getLoadedFilename() {
return m_file->fileName().toStdString(); }
101 KeyMappingAction getAction(
const Context& context,
102 const Qt::MouseButtons& buttons,
103 const Qt::KeyboardModifiers& modifiers,
105 bool wheel =
false );
107 getAction(
const Context& context,
const QEvent* event,
int key,
bool wheel =
false );
108 KeyMappingAction getAction(
const Context& context,
const EventBinding& binding );
112 std::optional<EventBinding> getBinding(
const Context& context, KeyMappingAction action );
116 KeyMappingAction addAction(
const Context& context,
const std::string& actionName );
121 addAction(
const Context& context,
const EventBinding& binding,
const std::string& actionName );
126 void setActionBinding(
const Context& context,
127 const EventBinding& binding,
128 const KeyMappingAction& action );
136 Context addContext(
const std::string& contextName );
141 Context getContext(
const std::string& contextName );
148 KeyMappingAction getAction(
const Context& context,
const std::string& actionName );
151 std::string getActionName(
const Context& context,
const KeyMappingAction& action );
154 std::string getContextName(
const Context& context );
157 int addListener( Observable::Observer callback );
161 void removeListener(
int callbackId );
168 static std::string enumNamesFromMouseButtons(
const Qt::MouseButtons& buttons );
172 static std::string enumNamesFromKeyboardModifiers(
const Qt::KeyboardModifiers& modifiers );
177 static EventBinding createEventBindingFromStrings(
const std::string& buttonsString =
"",
184 ~KeyMappingManager();
187 void saveNode( QXmlStreamWriter& stream,
const QDomNode& domNode );
188 void saveKeymap( QXmlStreamWriter& stream );
190 void loadConfigurationInternal(
const QDomDocument& domDocument );
191 void loadConfigurationTagsInternal( QDomElement& node );
192 KeyMappingAction loadConfigurationMappingInternal(
const std::string& context,
202 static Qt::KeyboardModifiers getQtModifiersValue(
const std::string& modifierString );
207 static Qt::MouseButtons getQtMouseButtonsValue(
const std::string& buttonsString );
208 static int getKeyCode(
const std::string& keyString );
217 ContextNameMap m_contextNameToIndex;