Gui: add function to check matches of key event and key sequence

This commit is contained in:
wmayer
2021-12-31 17:02:12 +01:00
parent fd8f860223
commit 311ab4e391
2 changed files with 8 additions and 0 deletions

View File

@@ -1192,6 +1192,7 @@ SET(FreeCADGui_SRCS
SpaceballEvent.h
PreferencePackManager.h
Thumbnail.h
Tools.h
Utilities.h
WaitCursor.h
ManualAlignment.h

View File

@@ -24,6 +24,9 @@
#define GUI_TOOLS_H
#include <QFontMetrics>
#include <QKeyEvent>
#include <QKeySequence>
#include <FCGlobal.h>
namespace Gui {
@@ -47,6 +50,10 @@ public:
return fm.width(text, len);
#endif
}
static bool matches(QKeyEvent* ke, const QKeySequence& ks) {
uint searchkey = (ke->modifiers() | ke->key()) & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier);
return ks == QKeySequence(searchkey);
}
};
} // namespace Gui