1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "command.h"
6
7#include <QAction>
8
9class ActionPrivate
10{
11public:
12 ActionPrivate();
13 virtual ~ActionPrivate();
14
15private:
16 QString id;
17 QKeySequence shortcutKey;
18 QString description;
19 QAction *action;
20
21 friend class Action;
22};
23
24ActionPrivate::ActionPrivate()
25 : action(nullptr)
26{
27
28}
29
30ActionPrivate::~ActionPrivate()
31{
32
33}
34
35Action::Action(QString id, QAction *action)
36 : d(new ActionPrivate())
37{
38 d->id = id;
39 d->action = action;
40}
41
42Action::~Action()
43{
44 if (d) {
45 delete d;
46 }
47}
48
49QString Action::id() const
50{
51 return d->id;
52}
53
54QAction *Action::action() const
55{
56 return d->action;
57}
58
59void Action::setKeySequence(const QKeySequence &key)
60{
61 d->shortcutKey = key;
62 if (d->action)
63 d->action->setShortcut(key);
64}
65
66QKeySequence Action::keySequence() const
67{
68 return d->shortcutKey;
69}
70
71void Action::setDescription(const QString &text)
72{
73 d->description = text;
74 if (d->action)
75 d->action->setText(text);
76}
77
78QString Action::description() const
79{
80 return d->description;
81}
82
83
84
85