1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef PROJECTACTIONINFO_H |
6 | #define PROJECTACTIONINFO_H |
7 | |
8 | #include <QString> |
9 | #include <QAction> |
10 | |
11 | namespace dpfservice { |
12 | |
13 | struct ProjectMenuActionInfo |
14 | { |
15 | QString displyText; |
16 | QString tooltip; |
17 | QString buildProgram; |
18 | QStringList buildArguments; |
19 | QString workingDirectory; |
20 | |
21 | inline bool isInvalid() { |
22 | if (displyText.isEmpty() |
23 | || buildProgram.isEmpty() |
24 | || buildArguments.isEmpty() |
25 | || workingDirectory.isEmpty() |
26 | || workingDirectory.isEmpty()) |
27 | return true; |
28 | return false; |
29 | } |
30 | |
31 | static void set(QAction *action, const ProjectMenuActionInfo &info) { |
32 | action->setProperty("ProjectActionInfo", |
33 | QVariant::fromValue<ProjectMenuActionInfo>(info)); |
34 | } |
35 | |
36 | static ProjectMenuActionInfo get(QAction *action) { |
37 | if (!action) return {}; |
38 | QVariant variant = action->property("ProjectActionInfo"); |
39 | if (variant.canConvert<ProjectMenuActionInfo>()) { |
40 | return qvariant_cast<ProjectMenuActionInfo>(variant); |
41 | } |
42 | return {}; |
43 | } |
44 | }; |
45 | |
46 | typedef QList<ProjectMenuActionInfo> ProjectActionInfos; |
47 | |
48 | } // namespace dpfservice |
49 | |
50 | Q_DECLARE_METATYPE(dpfservice::ProjectMenuActionInfo); |
51 | |
52 | #endif // PROJECTACTIONINFO_H |
53 |