1 // For license of this file, see <project-root-folder>/LICENSE.md. 2 3 #ifndef SHORTCUTCATCHER_H 4 #define SHORTCUTCATCHER_H 5 6 #include <QWidget> 7 8 class PlainToolButton; 9 class QHBoxLayout; 10 class QKeySequenceEdit; 11 12 class ShortcutCatcher : public QWidget { 13 Q_OBJECT 14 15 public: 16 explicit ShortcutCatcher(QWidget* parent = nullptr); 17 18 QKeySequence shortcut() const; 19 void setDefaultShortcut(const QKeySequence& key); 20 void setShortcut(const QKeySequence& key); 21 22 public slots: 23 void resetShortcut(); 24 void clearShortcut(); 25 26 signals: 27 void shortcutChanged(const QKeySequence& seguence); 28 29 private: 30 PlainToolButton* m_btnReset; 31 PlainToolButton* m_btnClear; 32 QKeySequenceEdit* m_shortcutBox; 33 QHBoxLayout* m_layout; 34 QKeySequence m_currentSequence; 35 QKeySequence m_defaultSequence; 36 bool m_isRecording; 37 int m_numKey; 38 int m_modifierKeys; 39 }; 40 41 #endif // KEYSEQUENCECATCHER_H 42