| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #ifndef COMMAND_H |
| 6 | #define COMMAND_H |
| 7 | |
| 8 | #include <QObject> |
| 9 | #include <QKeySequence> |
| 10 | |
| 11 | class QAction; |
| 12 | class QKeySequence; |
| 13 | class ActionPrivate; |
| 14 | class Command : public QObject |
| 15 | { |
| 16 | Q_OBJECT |
| 17 | public: |
| 18 | virtual QString id() const = 0; |
| 19 | virtual QAction *action() const = 0; |
| 20 | |
| 21 | virtual void setKeySequence(const QKeySequence &key) = 0; |
| 22 | virtual QKeySequence keySequence() const = 0; |
| 23 | |
| 24 | virtual void setDescription(const QString &text) = 0; |
| 25 | virtual QString description() const = 0; |
| 26 | |
| 27 | signals: |
| 28 | void keySequenceChanged(); |
| 29 | }; |
| 30 | |
| 31 | class Action : public Command |
| 32 | { |
| 33 | Q_OBJECT |
| 34 | public: |
| 35 | Action(QString id, QAction *action); |
| 36 | virtual ~Action() override; |
| 37 | |
| 38 | QString id() const override; |
| 39 | QAction *action() const override; |
| 40 | |
| 41 | void setKeySequence(const QKeySequence &key) override; |
| 42 | QKeySequence keySequence() const override; |
| 43 | |
| 44 | void setDescription(const QString &text) override; |
| 45 | QString description() const override; |
| 46 | |
| 47 | private: |
| 48 | ActionPrivate *const d; |
| 49 | }; |
| 50 | |
| 51 | #endif // COMMAND_H |
| 52 | |