2024-03-07 17:37:18 +01:00
|
|
|
//
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2024-03-13 21:43:57 +01:00
|
|
|
virtual const std::string getDescription() = 0;
|
2024-03-07 17:37:18 +01:00
|
|
|
|
2024-03-13 21:43:57 +01:00
|
|
|
virtual const std::string getKeyText() = 0;
|
2024-03-07 17:37:18 +01:00
|
|
|
|
|
|
|
[[nodiscard]] virtual bool canAcceptKey(int key) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //SWAYMUX_ABSTRACTKEYLISTENER_H
|