2024-03-07 17:37:18 +01:00
|
|
|
//
|
|
|
|
// Created by grimmauld on 07.03.24.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include "KeyHandler.h"
|
|
|
|
|
|
|
|
bool KeyHandler::eventFilter(QObject *obj, QEvent *event) {
|
|
|
|
if (event->type() == QEvent::KeyPress) {
|
|
|
|
auto *key = dynamic_cast<QKeyEvent *>(event);
|
|
|
|
|
|
|
|
return std::any_of(listeners.cbegin(), listeners.cend(),
|
2024-03-07 20:44:00 +01:00
|
|
|
[key](auto* listener) {
|
2024-03-07 17:37:18 +01:00
|
|
|
return listener->testAndInvoke(key);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
return QObject::eventFilter(obj, event);
|
|
|
|
}
|
|
|
|
}
|