2024-03-07 17:37:18 +01:00
|
|
|
//
|
|
|
|
// Created by grimmauld on 07.03.24.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SWAYMUX_CLOSEHELPKEYLISTENER_H
|
|
|
|
#define SWAYMUX_CLOSEHELPKEYLISTENER_H
|
|
|
|
|
|
|
|
#include <QStackedWidget>
|
|
|
|
#include "AbstractKeyListener.h"
|
|
|
|
|
|
|
|
class CloseHelpKeyListener : public AbstractKeyListener {
|
|
|
|
public:
|
|
|
|
explicit CloseHelpKeyListener(QWidget *pWidget) : stackPage(pWidget) {}
|
|
|
|
|
|
|
|
void handleKeyEvent(const QKeyEvent *keyEvent) const override {
|
|
|
|
auto* stackWidget = qobject_cast<QStackedWidget*>(stackPage->parent());
|
|
|
|
if (stackWidget != nullptr) {
|
|
|
|
stackWidget->setCurrentWidget(stackPage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-13 21:43:57 +01:00
|
|
|
const std::string getDescription() override {
|
2024-03-07 17:37:18 +01:00
|
|
|
return "Close help menu";
|
|
|
|
}
|
|
|
|
|
2024-03-13 21:43:57 +01:00
|
|
|
const std::string getKeyText() override {
|
2024-03-07 17:37:18 +01:00
|
|
|
return "?, ESC, q";
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool canAcceptKey(int key) const override {
|
|
|
|
return key == Qt::Key_Question || key == Qt::Key_Q || key == Qt::Key_Escape;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *stackPage{};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SWAYMUX_CLOSEHELPKEYLISTENER_H
|