Gui: add function to check matches of key event and key sequence
This commit is contained in:
@@ -1192,6 +1192,7 @@ SET(FreeCADGui_SRCS
|
||||
SpaceballEvent.h
|
||||
PreferencePackManager.h
|
||||
Thumbnail.h
|
||||
Tools.h
|
||||
Utilities.h
|
||||
WaitCursor.h
|
||||
ManualAlignment.h
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user