1 | // Copyright (C) 2019 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QACTIONGROUP_H |
5 | #define QACTIONGROUP_H |
6 | |
7 | #include <QtGui/qtguiglobal.h> |
8 | #include <QtGui/qaction.h> |
9 | |
10 | QT_REQUIRE_CONFIG(action); |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QActionGroupPrivate; |
15 | |
16 | class Q_GUI_EXPORT QActionGroup : public QObject |
17 | { |
18 | Q_OBJECT |
19 | Q_DECLARE_PRIVATE(QActionGroup) |
20 | |
21 | Q_PROPERTY(QActionGroup::ExclusionPolicy exclusionPolicy READ exclusionPolicy WRITE setExclusionPolicy) |
22 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) |
23 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible) |
24 | |
25 | public: |
26 | enum class ExclusionPolicy { |
27 | None, |
28 | Exclusive, |
29 | ExclusiveOptional |
30 | }; |
31 | Q_ENUM(ExclusionPolicy) |
32 | |
33 | explicit QActionGroup(QObject *parent); |
34 | ~QActionGroup(); |
35 | |
36 | QAction *addAction(QAction *a); |
37 | QAction *addAction(const QString &text); |
38 | QAction *addAction(const QIcon &icon, const QString &text); |
39 | void removeAction(QAction *a); |
40 | QList<QAction*> actions() const; |
41 | QAction *checkedAction() const; |
42 | |
43 | bool isExclusive() const; |
44 | bool isEnabled() const; |
45 | bool isVisible() const; |
46 | ExclusionPolicy exclusionPolicy() const; |
47 | |
48 | |
49 | public Q_SLOTS: |
50 | void setEnabled(bool); |
51 | inline void setDisabled(bool b) { setEnabled(!b); } |
52 | void setVisible(bool); |
53 | void setExclusive(bool); |
54 | void setExclusionPolicy(ExclusionPolicy policy); |
55 | |
56 | Q_SIGNALS: |
57 | void triggered(QAction *); |
58 | void hovered(QAction *); |
59 | |
60 | private Q_SLOTS: |
61 | void _q_actionTriggered(); |
62 | void _q_actionHovered(); |
63 | void _q_actionChanged(); |
64 | |
65 | protected: |
66 | QActionGroup(QActionGroupPrivate &dd, QObject *parent); |
67 | |
68 | private: |
69 | Q_DISABLE_COPY(QActionGroup) |
70 | }; |
71 | |
72 | QT_END_NAMESPACE |
73 | |
74 | #endif // QACTIONGROUP_H |
75 | |