swaymux/Keys/HelpKeyListener.h

38 lines
866 B
C++

//
// Created by grimmauld on 07.03.24.
//
#ifndef SWAYMUX_HELPKEYLISTENER_H
#define SWAYMUX_HELPKEYLISTENER_H
#include "AbstractKeyListener.h"
class HelpKeyListener : public AbstractKeyListener {
public:
explicit HelpKeyListener(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 "View this help menu";
}
std::string getKeyText() override {
return "?";
}
[[nodiscard]] bool canAcceptKey(int key) const override {
return key == Qt::Key_Question;
}
QWidget *stackPage;
};
#endif //SWAYMUX_HELPKEYLISTENER_H