39 lines
968 B
C
39 lines
968 B
C
|
//
|
||
|
// 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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
std::string getDescription() override {
|
||
|
return "Close help menu";
|
||
|
}
|
||
|
|
||
|
std::string getKeyText() override {
|
||
|
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
|