1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-31 20:45:34 +00:00
openmw/apps/opencs/model/prefs/shortcutsetting.hpp

58 lines
1.1 KiB
C++
Raw Normal View History

#ifndef CSM_PREFS_SHORTCUTSETTING_H
#define CSM_PREFS_SHORTCUTSETTING_H
2022-10-19 17:02:00 +00:00
#include <string>
#include <string_view>
2022-10-19 17:02:00 +00:00
#include <utility>
#include <QKeySequence>
#include "setting.hpp"
class QEvent;
2022-10-19 17:02:00 +00:00
class QMutex;
class QObject;
class QPushButton;
2022-10-19 17:02:00 +00:00
class QWidget;
namespace CSMPrefs
{
2022-10-19 17:02:00 +00:00
class Category;
2023-11-11 23:52:09 +00:00
class ShortcutSetting final : public TypedSetting<std::string>
{
2022-09-22 18:26:05 +00:00
Q_OBJECT
2022-09-22 18:26:05 +00:00
public:
2023-11-11 23:52:09 +00:00
explicit ShortcutSetting(
Category* parent, QMutex* mutex, std::string_view key, const QString& label, Settings::Index& index);
SettingWidgets makeWidgets(QWidget* parent) override;
2022-09-22 18:26:05 +00:00
void updateWidget() override;
2022-09-22 18:26:05 +00:00
protected:
bool eventFilter(QObject* target, QEvent* event) override;
2022-09-22 18:26:05 +00:00
private:
bool handleEvent(QObject* target, int mod, int value, bool active);
2022-09-22 18:26:05 +00:00
void storeValue(const QKeySequence& sequence);
void resetState();
2022-09-22 18:26:05 +00:00
static constexpr int MaxKeys = 4;
2022-09-22 18:26:05 +00:00
QPushButton* mButton;
2022-09-22 18:26:05 +00:00
bool mEditorActive;
int mEditorPos;
int mEditorKeys[MaxKeys];
2022-09-22 18:26:05 +00:00
private slots:
2022-09-22 18:26:05 +00:00
void buttonToggled(bool checked);
};
}
#endif