1 | // Copyright (C) 2017 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 QQUICKDIALOGBUTTONBOX_P_H |
5 | #define QQUICKDIALOGBUTTONBOX_P_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtQuickTemplates2/private/qquickabstractbutton_p.h> |
19 | #include <QtQuickTemplates2/private/qquickcontainer_p.h> |
20 | #include <QtGui/qpa/qplatformdialoghelper.h> |
21 | |
22 | QT_REQUIRE_CONFIG(quicktemplates2_container); |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QQmlComponent; |
27 | class QQuickDialogButtonBoxPrivate; |
28 | class QQuickDialogButtonBoxAttached; |
29 | class QQuickDialogButtonBoxAttachedPrivate; |
30 | |
31 | class Q_QUICKTEMPLATES2_EXPORT QQuickDialogButtonBox : public QQuickContainer |
32 | { |
33 | Q_OBJECT |
34 | Q_PROPERTY(Position position READ position WRITE setPosition NOTIFY positionChanged FINAL) |
35 | Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment RESET resetAlignment NOTIFY alignmentChanged FINAL) |
36 | Q_PROPERTY(QPlatformDialogHelper::StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged FINAL) |
37 | Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) |
38 | // 2.5 (Qt 5.12) |
39 | Q_PROPERTY(QPlatformDialogHelper::ButtonLayout buttonLayout READ buttonLayout WRITE setButtonLayout RESET resetButtonLayout NOTIFY buttonLayoutChanged FINAL REVISION(2, 5)) |
40 | QML_NAMED_ELEMENT(DialogButtonBox) |
41 | QML_ATTACHED(QQuickDialogButtonBoxAttached) |
42 | QML_EXTENDED_NAMESPACE(QPlatformDialogHelper) |
43 | QML_ADDED_IN_VERSION(2, 1) |
44 | |
45 | public: |
46 | explicit QQuickDialogButtonBox(QQuickItem *parent = nullptr); |
47 | ~QQuickDialogButtonBox(); |
48 | |
49 | enum Position { |
50 | , |
51 | |
52 | }; |
53 | Q_ENUM(Position) |
54 | |
55 | Position position() const; |
56 | void setPosition(Position position); |
57 | |
58 | Qt::Alignment alignment() const; |
59 | void setAlignment(Qt::Alignment alignment); |
60 | void resetAlignment(); |
61 | |
62 | QPlatformDialogHelper::StandardButtons standardButtons() const; |
63 | void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons); |
64 | Q_INVOKABLE QQuickAbstractButton *standardButton(QPlatformDialogHelper::StandardButton button) const; |
65 | |
66 | QQmlComponent *delegate() const; |
67 | void setDelegate(QQmlComponent *delegate); |
68 | |
69 | static QQuickDialogButtonBoxAttached *qmlAttachedProperties(QObject *object); |
70 | |
71 | QPlatformDialogHelper::ButtonLayout buttonLayout() const; |
72 | void setButtonLayout(QPlatformDialogHelper::ButtonLayout layout); |
73 | void resetButtonLayout(); |
74 | |
75 | Q_SIGNALS: |
76 | void accepted(); |
77 | void rejected(); |
78 | void helpRequested(); |
79 | void clicked(QQuickAbstractButton *button); |
80 | void positionChanged(); |
81 | void alignmentChanged(); |
82 | void standardButtonsChanged(); |
83 | void delegateChanged(); |
84 | // 2.3 (Qt 5.10) |
85 | Q_REVISION(2, 3) void applied(); |
86 | Q_REVISION(2, 3) void reset(); |
87 | Q_REVISION(2, 3) void discarded(); |
88 | // 2.5 (Qt 5.12) |
89 | Q_REVISION(2, 5) void buttonLayoutChanged(); |
90 | |
91 | protected: |
92 | void updatePolish() override; |
93 | void componentComplete() override; |
94 | void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
95 | void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; |
96 | bool isContent(QQuickItem *item) const override; |
97 | void itemAdded(int index, QQuickItem *item) override; |
98 | void itemRemoved(int index, QQuickItem *item) override; |
99 | |
100 | #if QT_CONFIG(accessibility) |
101 | QAccessible::Role accessibleRole() const override; |
102 | #endif |
103 | bool event(QEvent *e) override; |
104 | |
105 | private: |
106 | Q_DISABLE_COPY(QQuickDialogButtonBox) |
107 | Q_DECLARE_PRIVATE(QQuickDialogButtonBox) |
108 | }; |
109 | |
110 | class Q_QUICKTEMPLATES2_EXPORT QQuickDialogButtonBoxAttached : public QObject |
111 | { |
112 | Q_OBJECT |
113 | Q_PROPERTY(QQuickDialogButtonBox *buttonBox READ buttonBox NOTIFY buttonBoxChanged FINAL) |
114 | Q_PROPERTY(QPlatformDialogHelper::ButtonRole buttonRole READ buttonRole WRITE setButtonRole NOTIFY buttonRoleChanged FINAL) |
115 | |
116 | public: |
117 | explicit QQuickDialogButtonBoxAttached(QObject *parent = nullptr); |
118 | |
119 | QQuickDialogButtonBox *buttonBox() const; |
120 | |
121 | QPlatformDialogHelper::ButtonRole buttonRole() const; |
122 | void setButtonRole(QPlatformDialogHelper::ButtonRole role); |
123 | |
124 | Q_SIGNALS: |
125 | void buttonBoxChanged(); |
126 | void buttonRoleChanged(); |
127 | |
128 | private: |
129 | Q_DISABLE_COPY(QQuickDialogButtonBoxAttached) |
130 | Q_DECLARE_PRIVATE(QQuickDialogButtonBoxAttached) |
131 | }; |
132 | |
133 | QT_END_NAMESPACE |
134 | |
135 | #endif // QQUICKDIALOGBUTTONBOX_P_H |
136 | |