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 QQUICKDIALOGBUTTONBOX_P_H |
38 | #define QQUICKDIALOGBUTTONBOX_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 <QtQuickTemplates2/private/qquickcontainer_p.h> |
52 | #include <QtGui/qpa/qplatformdialoghelper.h> |
53 | |
54 | QT_BEGIN_NAMESPACE |
55 | |
56 | class QQmlComponent; |
57 | class QQuickAbstractButton; |
58 | class QQuickDialogButtonBoxPrivate; |
59 | class QQuickDialogButtonBoxAttached; |
60 | class QQuickDialogButtonBoxAttachedPrivate; |
61 | |
62 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialogButtonBox : public QQuickContainer |
63 | { |
64 | Q_OBJECT |
65 | Q_PROPERTY(Position position READ position WRITE setPosition NOTIFY positionChanged FINAL) |
66 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment RESET resetAlignment NOTIFY alignmentChanged FINAL) |
67 | Q_PROPERTY(QPlatformDialogHelper::StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged FINAL) |
68 | Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) |
69 | // 2.5 (Qt 5.12) |
70 | Q_PROPERTY(QPlatformDialogHelper::ButtonLayout buttonLayout READ buttonLayout WRITE setButtonLayout RESET resetButtonLayout NOTIFY buttonLayoutChanged FINAL REVISION 5) |
71 | Q_FLAGS(QPlatformDialogHelper::StandardButtons) |
72 | |
73 | public: |
74 | explicit QQuickDialogButtonBox(QQuickItem *parent = nullptr); |
75 | ~QQuickDialogButtonBox(); |
76 | |
77 | enum Position { |
78 | , |
79 | |
80 | }; |
81 | Q_ENUM(Position) |
82 | |
83 | Position position() const; |
84 | void setPosition(Position position); |
85 | |
86 | Qt::Alignment alignment() const; |
87 | void setAlignment(Qt::Alignment alignment); |
88 | void resetAlignment(); |
89 | |
90 | QPlatformDialogHelper::StandardButtons standardButtons() const; |
91 | void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons); |
92 | Q_INVOKABLE QQuickAbstractButton *standardButton(QPlatformDialogHelper::StandardButton button) const; |
93 | |
94 | QQmlComponent *delegate() const; |
95 | void setDelegate(QQmlComponent *delegate); |
96 | |
97 | static QQuickDialogButtonBoxAttached *qmlAttachedProperties(QObject *object); |
98 | |
99 | // 2.5 (Qt 5.12) |
100 | Q_ENUMS(QPlatformDialogHelper::ButtonLayout) |
101 | |
102 | QPlatformDialogHelper::ButtonLayout buttonLayout() const; |
103 | void setButtonLayout(QPlatformDialogHelper::ButtonLayout layout); |
104 | void resetButtonLayout(); |
105 | |
106 | Q_SIGNALS: |
107 | void accepted(); |
108 | void rejected(); |
109 | void helpRequested(); |
110 | void clicked(QQuickAbstractButton *button); |
111 | void positionChanged(); |
112 | void alignmentChanged(); |
113 | void standardButtonsChanged(); |
114 | void delegateChanged(); |
115 | // 2.3 (Qt 5.10) |
116 | Q_REVISION(3) void applied(); |
117 | Q_REVISION(3) void reset(); |
118 | Q_REVISION(3) void discarded(); |
119 | // 2.5 (Qt 5.12) |
120 | Q_REVISION(5) void buttonLayoutChanged(); |
121 | |
122 | protected: |
123 | void updatePolish() override; |
124 | void componentComplete() override; |
125 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
126 | void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; |
127 | bool isContent(QQuickItem *item) const override; |
128 | void itemAdded(int index, QQuickItem *item) override; |
129 | void itemRemoved(int index, QQuickItem *item) override; |
130 | |
131 | #if QT_CONFIG(accessibility) |
132 | QAccessible::Role accessibleRole() const override; |
133 | #endif |
134 | bool event(QEvent *e) override; |
135 | |
136 | private: |
137 | Q_DISABLE_COPY(QQuickDialogButtonBox) |
138 | Q_DECLARE_PRIVATE(QQuickDialogButtonBox) |
139 | }; |
140 | |
141 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDialogButtonBoxAttached : public QObject |
142 | { |
143 | Q_OBJECT |
144 | Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox NOTIFY buttonBoxChanged FINAL) |
145 | Q_PROPERTY(QPlatformDialogHelper::ButtonRole buttonRole READ buttonRole WRITE setButtonRole NOTIFY buttonRoleChanged FINAL) |
146 | Q_ENUMS(QPlatformDialogHelper::ButtonRole) |
147 | |
148 | public: |
149 | explicit QQuickDialogButtonBoxAttached(QObject *parent = nullptr); |
150 | |
151 | QQuickDialogButtonBox *buttonBox() const; |
152 | |
153 | QPlatformDialogHelper::ButtonRole buttonRole() const; |
154 | void setButtonRole(QPlatformDialogHelper::ButtonRole role); |
155 | |
156 | Q_SIGNALS: |
157 | void buttonBoxChanged(); |
158 | void buttonRoleChanged(); |
159 | |
160 | private: |
161 | Q_DISABLE_COPY(QQuickDialogButtonBoxAttached) |
162 | Q_DECLARE_PRIVATE(QQuickDialogButtonBoxAttached) |
163 | }; |
164 | |
165 | QT_END_NAMESPACE |
166 | |
167 | QML_DECLARE_TYPE(QQuickDialogButtonBox) |
168 | QML_DECLARE_TYPEINFO(QQuickDialogButtonBox, QML_HAS_ATTACHED_PROPERTIES) |
169 | |
170 | #endif // QQUICKDIALOGBUTTONBOX_P_H |
171 | |