1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#ifndef QQUICKBUTTONGROUP_P_H
38#define QQUICKBUTTONGROUP_P_H
39
40//
41// W A R N I N G
42// -------------
43//
44// This file is not part of the Qt API. It exists purely as an
45// implementation detail. This header file may change from version to
46// version without notice, or even be removed.
47//
48// We mean it.
49//
50
51#include <QtCore/qobject.h>
52#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
53#include <QtQml/qqml.h>
54#include <QtQml/qqmlparserstatus.h>
55
56QT_BEGIN_NAMESPACE
57
58class QQuickAbstractButton;
59class QQuickButtonGroupPrivate;
60class QQuickButtonGroupAttached;
61class QQuickButtonGroupAttachedPrivate;
62
63class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickButtonGroup : public QObject, public QQmlParserStatus
64{
65 Q_OBJECT
66 Q_PROPERTY(QQuickAbstractButton *checkedButton READ checkedButton WRITE setCheckedButton NOTIFY checkedButtonChanged FINAL)
67 Q_PROPERTY(QQmlListProperty<QQuickAbstractButton> buttons READ buttons NOTIFY buttonsChanged FINAL)
68 // 2.3 (Qt 5.10)
69 Q_PROPERTY(bool exclusive READ isExclusive WRITE setExclusive NOTIFY exclusiveChanged FINAL REVISION 3)
70 // 2.4 (Qt 5.11)
71 Q_PROPERTY(Qt::CheckState checkState READ checkState WRITE setCheckState NOTIFY checkStateChanged FINAL REVISION 4)
72 Q_INTERFACES(QQmlParserStatus)
73
74public:
75 explicit QQuickButtonGroup(QObject *parent = nullptr);
76 ~QQuickButtonGroup();
77
78 static QQuickButtonGroupAttached *qmlAttachedProperties(QObject *object);
79
80 QQuickAbstractButton *checkedButton() const;
81 void setCheckedButton(QQuickAbstractButton *checkedButton);
82
83 QQmlListProperty<QQuickAbstractButton> buttons();
84
85 bool isExclusive() const;
86 void setExclusive(bool exclusive);
87
88 // 2.4 (Qt 5.11)
89 Qt::CheckState checkState() const;
90 void setCheckState(Qt::CheckState state);
91
92public Q_SLOTS:
93 void addButton(QQuickAbstractButton *button);
94 void removeButton(QQuickAbstractButton *button);
95
96Q_SIGNALS:
97 void checkedButtonChanged();
98 void buttonsChanged();
99 // 2.1 (Qt 5.8)
100 Q_REVISION(1) void clicked(QQuickAbstractButton *button);
101 // 2.3 (Qt 5.10)
102 Q_REVISION(3) void exclusiveChanged();
103 // 2.4 (Qt 5.11)
104 Q_REVISION(4) void checkStateChanged();
105
106protected:
107 void classBegin() override;
108 void componentComplete() override;
109
110private:
111 Q_DISABLE_COPY(QQuickButtonGroup)
112 Q_DECLARE_PRIVATE(QQuickButtonGroup)
113
114 Q_PRIVATE_SLOT(d_func(), void _q_updateCurrent())
115};
116
117class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickButtonGroupAttached : public QObject
118{
119 Q_OBJECT
120 Q_PROPERTY(QQuickButtonGroup *group READ group WRITE setGroup NOTIFY groupChanged FINAL)
121
122public:
123 explicit QQuickButtonGroupAttached(QObject *parent = nullptr);
124
125 QQuickButtonGroup *group() const;
126 void setGroup(QQuickButtonGroup *group);
127
128Q_SIGNALS:
129 void groupChanged();
130
131private:
132 Q_DISABLE_COPY(QQuickButtonGroupAttached)
133 Q_DECLARE_PRIVATE(QQuickButtonGroupAttached)
134};
135
136QT_END_NAMESPACE
137
138QML_DECLARE_TYPE(QQuickButtonGroup)
139QML_DECLARE_TYPEINFO(QQuickButtonGroup, QML_HAS_ATTACHED_PROPERTIES)
140
141#endif // QQUICKBUTTONGROUP_P_H
142

source code of qtquickcontrols2/src/quicktemplates2/qquickbuttongroup_p.h