/* * Rosalie's Mupen GUI - https://github.com/Rosalie241/RMG * Copyright (C) 2020 Rosalie Wanders * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3. * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef HOTKEYBUTTON_HPP #define HOTKEYBUTTON_HPP #include #include #include "common.hpp" namespace UserInterface { // we can't include HotkeysDialog.hpp // because that header includes this header, // so forward-declare it to prevent issues class HotkeysDialog; namespace Widget { struct HotkeyButtonInputDataType { InputType Type; int Data; int ExtraData; QString Text; }; class HotkeyButton : public QPushButton { private: QSize initialSize; QTimer* countDownTimer = nullptr; HotkeysDialog* hotkeysDialog = nullptr; int currentCountDownNum = 0; std::vector inputData; std::vector savedInputData; void reloadText(); std::vector::iterator getInputDataIter(InputType type, int value, int extraValue); public: HotkeyButton(QWidget* parent); ~HotkeyButton(); void Initialize(HotkeysDialog* dialog); void Clear(); void StartTimer(); void StopTimer(); void AddInputData(InputType type, int value, int extraValue, QString name); bool HasInputData(InputType type, int value = -1, int extraValue = -1); std::vector GetInputType(); std::vector GetInputData(); std::vector GetExtraInputData(); std::vector GetInputText(); void SaveState(); void RestoreState(); void FinishState(); protected: void mousePressEvent(QMouseEvent* event); private slots: void on_countDownTimer_triggered(); }; } } #endif // HOTKEYBUTTON_HPP