swaymux/Keys/AbstractKeyListener.h

33 lines
694 B
C
Raw Normal View History

//
// Created by grimmauld on 07.03.24.
//
#ifndef SWAYMUX_ABSTRACTKEYLISTENER_H
#define SWAYMUX_ABSTRACTKEYLISTENER_H
#include <set>
#include <Qt>
#include <QKeyEvent>
class AbstractKeyListener {
public:
virtual void handleKeyEvent(const QKeyEvent *keyEvent) const = 0;
bool testAndInvoke(const QKeyEvent *keyEvent) const {
if (canAcceptKey(keyEvent->key())) {
handleKeyEvent(keyEvent);
return true;
}
return false;
}
virtual const std::string getDescription() = 0;
virtual const std::string getKeyText() = 0;
[[nodiscard]] virtual bool canAcceptKey(int key) const = 0;
};
#endif //SWAYMUX_ABSTRACTKEYLISTENER_H