#ifndef GETSUYOMI_SETTINGS_HPP #define GETSUYOMI_SETTINGS_HPP #include #include #include #include #include #include #include #include #include "config.hpp" namespace getsuyomi { class Settings : public QDialog { Q_OBJECT public: Settings(QWidget* parent, Shortcuts&& shortcuts); Settings(const Settings&) = delete; Settings(Settings&& rhs) = delete; ~Settings() = default; Settings& operator=(const Settings&) = delete; Settings& operator=(Settings&& rhs) = delete; [[nodiscard]] bool valid() const; const Shortcuts& shortcuts() const; private: Shortcuts m_shortcuts; }; class ShortcutDisplay; class ShortcutCollector : public QWidget { Q_OBJECT public: ShortcutCollector(QWidget* parent, ActionType action, Shortcuts& shortcuts); ~ShortcutCollector() = default; ShortcutCollector(const ShortcutCollector&) = delete; ShortcutCollector(ShortcutCollector&&) = delete; ShortcutCollector& operator=(const ShortcutCollector&) = delete; ShortcutCollector& operator=(ShortcutCollector&&) = delete; private: void createBinding(QKeySequence binding); private slots: void checkBinding(); void addBinding(); void removeBinding(QKeySequence shortcut); private: ActionType m_action; Shortcuts& m_shortcuts; std::map m_bindings; QKeySequenceEdit* m_shortcutEditor{nullptr}; QPushButton* m_acceptButton{nullptr}; QVBoxLayout* m_layout{nullptr}; }; class ShortcutDisplay : public QWidget { Q_OBJECT public: ShortcutDisplay(QWidget* parent, QKeySequence shortcut); signals: void removeClicked(QKeySequence shortcut); private: QKeySequence m_binding; private slots: void removeOnClicked(); }; } // namespace getsuyomi #endif