| 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 | QAction* action() const; |
| 23 | void setAction(QAction* act); |
| 24 | |
| 25 | public slots: |
| 26 | void resetShortcut(); |
| 27 | void clearShortcut(); |
| 28 | |
| 29 | signals: |
| 30 | void shortcutChanged(const QKeySequence& seguence); |
| 31 | |
| 32 | private: |
| 33 | QAction* m_action; |
| 34 | PlainToolButton* m_btnReset; |
| 35 | PlainToolButton* m_btnClear; |
| 36 | QKeySequenceEdit* m_shortcutBox; |
| 37 | QHBoxLayout* m_layout; |
| 38 | QKeySequence m_currentSequence; |
| 39 | QKeySequence m_defaultSequence; |
| 40 | bool m_isRecording; |
| 41 | int m_numKey; |
| 42 | int m_modifierKeys; |
| 43 | }; |
| 44 | |
| 45 | #endif // KEYSEQUENCECATCHER_H |